Providers / Plivo

Test Plivo SMS without sending real messages

otpmock emulates the Plivo Send message API API. In your test environment, the official plivo SDK talks to otpmock instead of Plivo; your end-to-end tests read each code over HTTP.

Updated October 8, 2026Tested with the official plivo SDK
Short answer

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

Setup

The Plivo SDK accepts a url option that replaces its account base URL. It works but isn't documented by Plivo.

sms.js
import plivo from "plivo";

const authId = process.env.PLIVO_AUTH_ID;
export const plivoClient = new plivo.Client(
  authId,
  process.env.PLIVO_AUTH_TOKEN, // otpmock API key in tests
  process.env.OTPMOCK_URL ? { url: `${process.env.OTPMOCK_URL}/v1/Account/${authId}` } : {},
);

Credentials. In the test environment, set PLIVO_AUTH_TOKEN to your otpmock API key. The Auth ID can stay as it is.

What otpmock emulates

EndpointWhat it does
POST /v1/Account/{auth_id}/Message/Send an SMS (multiple recipients separated by <)

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

Phone numbers

Send in E.164 (+15550142) or without +.

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 Plivo
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 Plivo?

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

Is the official plivo SDK supported?

Yes. otpmock's Plivo endpoints are tested end to end with the official plivo package for Node.js. Other languages work too if their Plivo client lets you change the API host.

Which Plivo APIs does otpmock support?

POST /v1/Account/{auth_id}/Message/ (Send an SMS (multiple recipients separated by <)).

Test Plivo 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