Providers / Plivo

Test Plivo SMS without sending real messages

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

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.

Language
sms.jsNode.js · plivo
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}` } : {},
);

Each 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, 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 <)
POST /v1/Account/{auth_id}/Verify/Session/Verify: create a session (otpmock generates the OTP; code_length 4–8, default 6; brand_name used in the text)
POST /v1/Account/{auth_id}/Verify/Session/{uuid}/Verify: validate the otp (400 on a wrong OTP, up to 10 attempts)
GET /v1/Account/{auth_id}/Verify/Session/{uuid}/Verify: get the session (status in-progress, verified or expired)

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 +.

How to tell your app uses Plivo

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:

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 <)); POST /v1/Account/{auth_id}/Verify/Session/ (Verify: create a session (otpmock generates the OTP; code_length 4–8, default 6; brand_name used in the text)); POST /v1/Account/{auth_id}/Verify/Session/{uuid}/ (Verify: validate the otp (400 on a wrong OTP, up to 10 attempts)); GET /v1/Account/{auth_id}/Verify/Session/{uuid}/ (Verify: get the session (status in-progress, verified or expired)).

Test Plivo flows today

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

Related guides

Other providers