WhatsApp OTP API
The EmacronAI CRM OTP API lets you send one-time passwords via WhatsApp and verify them server-side. Delivery and cost depend on your selected package, destination, account configuration, approved template, and provider terms. Review current package pricing before enabling OTP.
For separate projects, create a WhatsApp OTP-only key in Settings → API Keys and assign an approved Copy Code template. The key uses that assignment for every send, delivers over WhatsApp only, and verifies requests from its own project. Use a key with whatsapp:otp, or an existing key with whatsapp:send for the legacy flow. Keep the key on your server. When you rotate it, use the replacement key to verify any outstanding requests.
See pricing
Current price
Depends on package, destination, and provider terms
Provider reported
Delivery status
Varies with sender, recipient, and account conditions
10 minutes
OTP expiry
Fixed per request
Authentication
All requests require a Bearer token. Get your API key from Settings → API Keys in your dashboard.
Send & verify OTP
Two API calls: send, then verify.
import { createClient } from '@emacrontechnologies/outreachagent';
// npm install @emacrontechnologies/outreachagent
const oa = createClient(process.env.OUTREACHAGENT_API_KEY);
// 1. Send OTP
const { request_id } = await oa.otp.send({
phone: '+919876543210',
context: 'login',
});
// 2. Verify OTP (after user enters it)
try {
const { valid } = await oa.otp.verify(request_id, userEnteredOtp);
if (valid) console.log('Phone verified ✅');
} catch (error) {
// A wrong or expired code is an HTTP 400 error, not a resolved false result.
if (error.status === 400) console.log('Invalid or expired OTP ❌');
else throw error;
}Install: npm install @emacrontechnologies/outreachagent
Endpoint reference
/whatsapp/otp/sendBy default, Emacron generates, sends, and later verifies a six-digit code. Your backend supplies the phone number and keeps the returned request_id bound to its application session. For a code generated securely by your backend, set code_source: "client" and provide code; Emacron sends and verifies that code over WhatsApp. Client mode has no SMS fallback. Provider acceptance does not confirm delivery.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
phone | string | Yes | E.164 format. Example: +919876543210 |
phone_number_id | string | No | Project keys use the assigned sender. If supplied, this ID must match. Legacy callers can choose a connected sender. |
context | string | No | Purpose label, such as login or signup. |
code_source | string | No | platform (default) or client. Client mode requires code and uses WhatsApp only. |
code | string | Client mode | 4–15 ASCII letters or digits generated securely by your backend. Never send from browser code. |
/whatsapp/otp/verifyVerify an OTP. Success returns HTTP 200 with valid: true. An invalid code returns HTTP 400 with valid: false; SDK clients throw on that response.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | The request_id returned by /whatsapp/otp/send |
code | string | Yes | The OTP entered by the user |
Error codes
| HTTP | code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Missing or invalid field (e.g. phone not in E.164 format) |
| 401 | UNAUTHORIZED | Missing or invalid API key |
| 422 | INVALID_OTP | OTP does not match or has expired |
| 429 | RATE_LIMIT_EXCEEDED | Too many OTP requests for this phone number. Wait 1 hour. |
| 500 | INTERNAL_ERROR | Server error. Retry with exponential backoff. |
Rate limits
| Endpoint | Limit |
|---|---|
| POST /whatsapp/otp/send | 5 per phone per workspace per 10 minutes |
| POST /whatsapp/otp/send | 1,000 per workspace per hour |
| Project OTP sends | 250 per project per hour, within the workspace limit |
| POST /whatsapp/otp/verify | 5 attempts per request_id |
| All API endpoints | 1,000 requests per hour per API key (workspace-configurable) |
Node.js SDK
The official npm package wraps the REST API with full TypeScript types, auto-retry, and clean error handling.