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/`;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.
Phone numbers
İleti Merkezi uses Turkish local numbers (5051234567). otpmock stores them as +905051234567.
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 100 messages a month. Using an AI coding assistant? Point it at otpmock.com/llms-full.txt.
Get a free API key