Providers / Infobip

Test Infobip SMS without sending real messages

otpmock emulates the Infobip SMS v2 (/sms/2/text/advanced) and v3 (/sms/3/messages) API. In your test environment, the official @infobip-api/sdk SDK talks to otpmock instead of Infobip; your end-to-end tests read each code over HTTP.

Updated October 8, 2026Tested with the official @infobip-api/sdk SDK
Short answer

Set OTPMOCK_URL=https://api.otpmock.com in your test environment, point the Infobip client at it, and use your otpmock API key as the Infobip credential. Your application code doesn't change, and production keeps sending real SMS through Infobip.

Setup

Infobip gives every account its own base URL, so baseUrl is already a required option.

sms.js
import { Infobip, AuthType } from "@infobip-api/sdk";

export const infobip = new Infobip({
  baseUrl: process.env.OTPMOCK_URL ?? process.env.INFOBIP_BASE_URL,
  apiKey: process.env.INFOBIP_API_KEY, // otpmock API key in tests
  authType: AuthType.ApiKey,
});

Credentials. In the test environment, set your Infobip API key variable to your otpmock API key. App, Basic and Bearer authorization are accepted.

What otpmock emulates

EndpointWhat it does
POST /sms/2/text/advancedSend SMS (v2), used by the Node.js SDK
POST /sms/3/messagesSend SMS (v3)

Responses and errors follow Infobip's own format, so the SDK parses them as usual. Authentication failures and an exhausted monthly allowance also come back in Infobip's error shape.

Phone numbers

Infobip sends numbers without a leading +. otpmock stores them in E.164 form.

Read the code in your tests

signup.spec.ts
const phone = otp.randomPhone();
const since = Date.now() - 5_000;
await page.getByRole("button", { name: "Send code" }).click(); // your app calls Infobip
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 Infobip?

No. In the test environment your app's Infobip requests go to otpmock, which stores the message for 10 minutes and never contacts Infobip or any carrier. Production keeps using Infobip because otpmock is only enabled when OTPMOCK_URL is set.

Is the official @infobip-api/sdk SDK supported?

Yes. otpmock's Infobip endpoints are tested end to end with the official @infobip-api/sdk package for Node.js. Other languages work too if their Infobip client lets you change the API host.

Which Infobip APIs does otpmock support?

POST /sms/2/text/advanced (Send SMS (v2), used by the Node.js SDK); POST /sms/3/messages (Send SMS (v3)).

Test Infobip flows today

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

Other providers