Set OTPMOCK_URL=https://api.otpmock.com in your test environment, point the Verimor client at it, and use your otpmock API key as the Verimor credential. Your application code doesn't change, and production keeps sending real SMS through Verimor.
Setup
Verimor has no official Node.js SDK; apps call the HTTP API directly, so only the host changes. Responses are plain text: the campaign ID on success, INSUFFICIENT_CREDITS, MISSING_MESSAGE and similar codes on 400.
const VERIMOR_URL = process.env.OTPMOCK_URL ?? "https://sms.verimor.com.tr";
const res = await fetch(`${VERIMOR_URL}/v2/send.json`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
username: process.env.VERIMOR_USERNAME,
password: process.env.VERIMOR_PASSWORD, // otpmock API key in tests
source_addr: "BASLIGIM",
messages: [{ msg: `Doğrulama kodunuz: ${code}`, dest: "905321234567" }],
}),
});
const campaignId = await res.text();import os
import requests
VERIMOR_URL = os.environ.get("OTPMOCK_URL", "https://sms.verimor.com.tr")
res = requests.post(f"{VERIMOR_URL}/v2/send.json", json={
"username": os.environ["VERIMOR_USERNAME"],
"password": os.environ["VERIMOR_PASSWORD"], # otpmock API key in tests
"source_addr": "BASLIGIM",
"messages": [{"msg": f"Doğrulama kodunuz: {code}", "dest": "905321234567"}],
})
campaign_id = res.textString base = System.getenv().getOrDefault("OTPMOCK_URL", "https://sms.verimor.com.tr");
// json: {"username":"...","password":"<VERIMOR_PASSWORD, otpmock API key in tests>","source_addr":"BASLIGIM",
// "messages":[{"msg":"...","dest":"905321234567"}]}
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/v2/send.json"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
// Response body is the campaign ID as plain text.var verimorUrl = Environment.GetEnvironmentVariable("OTPMOCK_URL") ?? "https://sms.verimor.com.tr";
var http = new HttpClient { BaseAddress = new Uri(verimorUrl) };
var res = await http.PostAsJsonAsync("/v2/send.json", new
{
username = Environment.GetEnvironmentVariable("VERIMOR_USERNAME"),
password = Environment.GetEnvironmentVariable("VERIMOR_PASSWORD"), // otpmock API key in tests
source_addr = "BASLIGIM",
messages = new[] { new { msg = $"Doğrulama kodunuz: {code}", dest = "905321234567" } },
});
var campaignId = await res.Content.ReadAsStringAsync();use GuzzleHttp\Client;
$verimorUrl = getenv('OTPMOCK_URL') ?: 'https://sms.verimor.com.tr';
$campaignId = (string) (new Client())->post("$verimorUrl/v2/send.json", [
'json' => [
'username' => getenv('VERIMOR_USERNAME'),
'password' => getenv('VERIMOR_PASSWORD'), // otpmock API key in tests
'source_addr' => 'BASLIGIM',
'messages' => [['msg' => "Doğrulama kodunuz: $code", 'dest' => '905321234567']],
],
])->getBody();require "net/http"
require "json"
# Verimor has no official Ruby SDK; apps call the REST API, so only the host changes.
VERIMOR_URL = ENV.fetch("OTPMOCK_URL", "https://sms.verimor.com.tr")
res = Net::HTTP.post(
URI("#{VERIMOR_URL}/v2/send.json"),
{
username: ENV["VERIMOR_USERNAME"],
password: ENV["VERIMOR_PASSWORD"], # otpmock API key in tests
source_addr: "BASLIGIM",
messages: [{ msg: "Doğrulama kodunuz: #{code}", dest: "905321234567" }],
}.to_json,
"Content-Type" => "application/json"
)
campaign_id = res.body// Verimor has no official Go SDK; call its HTTP API with net/http, only the host changes.
base := os.Getenv("OTPMOCK_URL")
if base == "" {
base = "https://sms.verimor.com.tr"
}
body, _ := json.Marshal(map[string]any{
"username": os.Getenv("VERIMOR_USERNAME"),
"password": os.Getenv("VERIMOR_PASSWORD"), // otpmock API key in tests
"source_addr": "BASLIGIM",
"messages": []map[string]string{{"msg": msg, "dest": "905321234567"}},
})
res, err := http.Post(base+"/v2/send.json", "application/json", bytes.NewReader(body)) // plain-text campaign IDEach language is tested in CI against otpmock with the provider's official SDK, or its plain HTTP API where no SDK can be pointed at another host.
Credentials. In the test environment, use your otpmock API key as the Verimor password. The username can stay as it is.
What otpmock emulates
| Endpoint | What it does |
|---|---|
GET /v2/send | Query string: username, password, source_addr, msg, dest (comma-separated) |
POST /v2/send.json | JSON: username, password, source_addr, messages[] with msg and dest |
Responses and errors follow Verimor's own format, so the SDK parses them as usual. Authentication failures and an exhausted monthly allowance also come back in Verimor's error shape.
Try it with cURL
Before wiring your app, check the emulation by hand. Put your own key in OTPMOCK_API_KEY; the number is made up. Keep the message text ASCII when you run this from a Windows terminal, which can garble accented letters on the command line.
curl https://api.otpmock.com/v2/send.json \
-H "content-type: application/json" \
-d '{"username":"x","password":"'"$OTPMOCK_API_KEY"'","source_addr":"BASLIGIM","messages":[{"msg":"Dogrulama kodunuz: 336699","dest":"905321230001"}]}'16168421The response has Verimor's own shape. Now read the code your test would read:
curl https://api.otpmock.com/v1/inbox/%2B905321230001/code \
-H "Authorization: Bearer $OTPMOCK_API_KEY"
{"code":"336699","messageSid":"SM…","receivedAt":1795257752284}Phone numbers
Verimor uses 905321234567. otpmock stores it as +905321234567; local 5321234567 also works.
How to tell your app uses Verimor
Look for any of these in your codebase to confirm where the SMS is sent, and therefore where the otpmock option has to be set:
- requests to
sms.verimor.com.tr/v2/send
Read the code in your tests
const phone = otp.randomPhone();
const since = Date.now() - 5_000;
await page.getByRole("button", { name: "Send code" }).click(); // your app calls Verimor
const { code } = await otp.waitForCode(phone, { since });The otp helper is a single file: get it from the docs. Full walkthroughs: Playwright, Cypress.
FAQ
Does otpmock send real SMS through Verimor?
No. In the test environment your app's Verimor requests go to otpmock, which stores the message for 10 minutes and never contacts Verimor or any carrier. Production keeps using Verimor because otpmock is only enabled when OTPMOCK_URL is set.
Is the official HTTP API SDK supported?
Yes. otpmock's Verimor endpoints are tested end to end with the official HTTP API package for Node.js. Other languages work too if their Verimor client lets you change the API host.
Which Verimor APIs does otpmock support?
GET /v2/send (Query string: username, password, source_addr, msg, dest (comma-separated)); POST /v2/send.json (JSON: username, password, source_addr, messages[] with msg and dest).
The free plan includes 300 messages a month. Using an AI coding assistant? Point it at otpmock.com/llms-full.txt.
Get a free API key