Set OTPMOCK_URL=https://api.otpmock.com in your test environment, point the İleti Merkezi client at it, and use your otpmock API key as the İleti Merkezi credential. Your application code doesn't change, and production keeps sending real SMS through İleti Merkezi.
Setup
The SDK has no base URL option, but its HTTP client's baseUrl can be set after construction.
import { IletiMerkeziClient } from "@iletimerkezi/iletimerkezi-node";
export const ileti = new IletiMerkeziClient(
process.env.ILETIMERKEZI_API_KEY, // otpmock API key in tests
process.env.ILETIMERKEZI_API_HASH,
process.env.ILETIMERKEZI_SENDER,
);
if (process.env.OTPMOCK_URL) (ileti as any).httpClient.baseUrl = `${process.env.OTPMOCK_URL}/v1/`;import os
import requests
ILETI_URL = os.environ.get("OTPMOCK_URL", "https://api.iletimerkezi.com")
res = requests.post(f"{ILETI_URL}/v1/send-sms/json", json={"request": {
"authentication": {
"key": os.environ["ILETIMERKEZI_API_KEY"], # otpmock API key in tests
"hash": os.environ["ILETIMERKEZI_API_HASH"],
},
"order": {"sender": "BASLIGIM", "sendDateTime": [], "iys": "0",
"message": {"text": f"Doğrulama kodunuz: {code}", "receipents": {"number": ["5321234567"]}}},
}})String base = System.getenv().getOrDefault("OTPMOCK_URL", "https://api.iletimerkezi.com");
// json: {"request":{"authentication":{"key":"<ILETIMERKEZI_API_KEY, otpmock API key in tests>","hash":"..."},
// "order":{"sender":"...","iys":"0","message":{"text":"...","receipents":{"number":["5051234567"]}}}}}
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/v1/send-sms/json"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();// İleti Merkezi has no official .NET SDK; call the JSON API with HttpClient.
var iletiUrl = Environment.GetEnvironmentVariable("OTPMOCK_URL") ?? "https://api.iletimerkezi.com";
await new HttpClient().PostAsJsonAsync(iletiUrl + "/v1/send-sms/json", new
{
request = new
{
authentication = new
{
key = Environment.GetEnvironmentVariable("ILETIMERKEZI_API_KEY"), // otpmock API key in tests
hash = Environment.GetEnvironmentVariable("ILETIMERKEZI_API_HASH"),
},
order = new
{
sender = "BASLIGIM", sendDateTime = Array.Empty<string>(), iys = "0",
message = new { text = $"Doğrulama kodunuz: {code}", receipents = new { number = new[] { "5051234567" } } },
},
},
});use IletiMerkezi\IletiMerkeziClient;
$ileti = new IletiMerkeziClient(
getenv('ILETIMERKEZI_API_KEY'), // otpmock API key in tests
getenv('ILETIMERKEZI_API_HASH'),
getenv('ILETIMERKEZI_SENDER'),
);
if ($otpmock = getenv('OTPMOCK_URL')) {
// The SDK has no base URL option; its HTTP client keeps the URL in a private property.
$http = (fn () => $this->httpClient)->call($ileti);
(fn () => $this->baseUrl = rtrim($otpmock, '/') . '/v1/')->call($http);
}require "net/http"
require "json"
# İleti Merkezi has no official Ruby SDK; apps call the REST API, so only the host changes.
ILETI_URL = ENV.fetch("OTPMOCK_URL", "https://api.iletimerkezi.com")
res = Net::HTTP.post(
URI("#{ILETI_URL}/v1/send-sms/json"),
{ request: {
authentication: { key: ENV["ILETIMERKEZI_API_KEY"], hash: ENV["ILETIMERKEZI_API_HASH"] }, # key = otpmock API key in tests
order: { sender: ENV["ILETIMERKEZI_SENDER"], sendDateTime: [], iys: "0",
message: { text: "Doğrulama kodunuz: #{code}", receipents: { number: ["5051234567"] } } },
} }.to_json,
"Content-Type" => "application/json"
)// İleti Merkezi 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://api.iletimerkezi.com"
}
body, _ := json.Marshal(map[string]any{"request": map[string]any{
"authentication": map[string]string{
"key": os.Getenv("ILETIMERKEZI_API_KEY"), // otpmock API key in tests
"hash": os.Getenv("ILETIMERKEZI_API_HASH"),
},
"order": map[string]any{
"sender": os.Getenv("ILETIMERKEZI_SENDER"), "iys": "0",
"message": map[string]any{"text": msg, "receipents": map[string]any{"number": []string{"5051234567"}}},
},
}})
res, err := http.Post(base+"/v1/send-sms/json", "application/json", bytes.NewReader(body)) // HTTP 200 = successEach 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 İleti Merkezi API key. The hash can be any value.
What otpmock emulates
| Endpoint | What it does |
|---|---|
POST /v1/send-sms/json | Send SMS (request.authentication.key, order.message.receipents.number) |
Responses and errors follow İleti Merkezi's own format, so the SDK parses them as usual. Authentication failures and an exhausted monthly allowance also come back in İleti Merkezi'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/v1/send-sms/json \
-H "content-type: application/json" \
-d '{"request":{"authentication":{"key":"'"$OTPMOCK_API_KEY"'","hash":"x"},"order":{"sender":"BASLIGIM","message":{"text":"Dogrulama kodunuz: 705114","receipents":{"number":["5051234567"]}}}}}'{"response":{"status":{"code":"200","message":"İşlem başarılı"},"order":{"id":"93602279"}}}The response has İleti Merkezi's own shape. Now read the code your test would read:
curl https://api.otpmock.com/v1/inbox/%2B905051234567/code \
-H "Authorization: Bearer $OTPMOCK_API_KEY"
{"code":"705114","messageSid":"SM…","receivedAt":1795257752284}Phone numbers
İleti Merkezi uses Turkish local numbers (5051234567). otpmock stores them as +905051234567.
How to tell your app uses İleti Merkezi
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:
@iletimerkezi/iletimerkezi-nodein package.jsonIletiMerkeziClient- requests to
api.iletimerkezi.com/v1/send-sms/json
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 İleti Merkezi
const { code } = await otp.waitForCode(phone, { since });The otp helper is a single file: get it from the docs. Full walkthroughs: Playwright, Cypress.
Good to know
- As with the real API, the HTTP status equals the status code in the body, so the SDK's
ok()works unchanged.
FAQ
Does otpmock send real SMS through İleti Merkezi?
No. In the test environment your app's İleti Merkezi requests go to otpmock, which stores the message for 10 minutes and never contacts İleti Merkezi or any carrier. Production keeps using İleti Merkezi because otpmock is only enabled when OTPMOCK_URL is set.
Is the official @iletimerkezi/iletimerkezi-node SDK supported?
Yes. otpmock's İleti Merkezi endpoints are tested end to end with the official @iletimerkezi/iletimerkezi-node package for Node.js. Other languages work too if their İleti Merkezi client lets you change the API host.
Which İleti Merkezi APIs does otpmock support?
POST /v1/send-sms/json (Send SMS (request.authentication.key, order.message.receipents.number)).
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