OTP API
Two endpoints implement a complete phone-verification flow. Chatrixa generates the code, delivers it over WhatsApp, stores only a SHA-256 hash, and verifies the customer's submission — your integration never handles raw codes.
Prerequisites
- An approved AUTHENTICATION-category WhatsApp template, synced into Chatrixa (see Quickstart)
- An API token
- An active subscription and a connected WhatsApp account
Send a code
POST https://chatrixa.com/api/otp/send
{
"phone": "+14155552671",
"template": "otp_login_code",
"language": "en_US",
"length": 6,
"expires_in": 300,
"first_name": "Jane",
"email": "[email protected]"
}
| Field | Required | Description |
|---|---|---|
phone |
yes | International format; normalised to E.164 server-side |
template |
no | AUTHENTICATION template name. Omit to auto-select your most recent approved one — every organization gets the default ramz_otp template created automatically on WhatsApp connect |
language |
no | Exact or prefix match (en matches en_US) |
length |
no | 4–8 digits, default 6 |
expires_in |
no | 60–1800 seconds, default 300 |
first_name / last_name / email |
no | Used if a new contact is created for this phone |
Success (200):
{
"statusCode": 200,
"code": "SENT",
"message": "Verification code sent.",
"data": {
"phone": "+14155552671",
"template": "otp_login_code",
"language": "en_US",
"expires_in": 300,
"message_id": "wamid.HBgLMTQxNTU1..."
}
}
Verify a code
POST https://chatrixa.com/api/otp/verify
{ "phone": "+14155552671", "code": "482913" }
Success (200):
{ "statusCode": 200, "code": "VERIFIED", "message": "Phone number verified.", "verified": true }
Codes are single-use: after one successful verification the same code is
rejected with EXPIRED.
Result codes
| HTTP | code |
Meaning |
|---|---|---|
| 200 | SENT |
Code generated and delivered |
| 200 | VERIFIED |
Code correct; phone confirmed |
| 401 | INVALID_CODE |
Wrong code — attempts remaining |
| 402 | INSUFFICIENT_CREDITS |
Allowance and prepaid credits exhausted — see Ramz pricing |
| 410 | EXPIRED |
Code expired, already used, or never sent |
| 422 | NO_AUTH_TEMPLATE |
No approved AUTHENTICATION template found |
| 429 | RESEND_COOLDOWN |
Called again within 60 s for the same phone |
| 429 | SEND_LIMIT_REACHED |
More than 5 sends per hour for the same phone |
| 429 | MAX_ATTEMPTS |
5 wrong verifications — request a new code |
| 502 | DELIVERY_FAILED |
WhatsApp could not deliver the message |
Abuse protection (built in)
Per organization + phone number:
- 60-second resend cooldown, maximum 5 sends per hour
- Maximum 5 verification attempts per code
- Codes stored only as SHA-256 hashes with strict TTL
Per API token:
/otp/sendthrottled to 30 requests/min/otp/verifythrottled to 60 requests/min
Recommended integration pattern
- Your frontend collects the phone number and calls your backend.
- Your backend calls
/otp/send(the API token never leaves your server). - The customer types the code from WhatsApp into your frontend.
- Your backend calls
/otp/verifyand unlocks the action whenverified: true.
This is exactly what the downloadable store plugins do for WooCommerce, OpenCart, and PrestaShop.