Authentication & test mode
API keys, scopes, IP allow-lists, the sandbox and rate limits.
API keys
Every request is authenticated with a project API key. Send it in the X-API-Key header, or as Authorization: Bearer:
curl https://sms21.in/v1/api-keys/current -H "X-API-Key: $SMS21_API_KEY"
# {"success":true,"id":"key_…","environment":"test","scopes":["otp:send","otp:verify"],"projectId":"prj_…","companyId":"cmp_…"}- Keys look like
sms21_live_…orsms21_test_…and belong to one project. The secret is shown once; SMS21 stores only a hash and cannot show it again. - Rotate by creating a new key, deploying it, then revoking the old one. Keys can also be given an expiry date.
- Optionally restrict a key to IP addresses or CIDR ranges; other callers receive
403 IP_NOT_ALLOWED.
Keys belong on servers
Scopes
A key can only do what its scopes allow. Grant each application the minimum it needs.
| Scope | Allows |
|---|---|
otp:send | Send one-time passwords |
otp:verify | Verify one-time passwords |
sms:send | Send individual SMS messages |
whatsapp:send | Send WhatsApp messages |
reports:read | Read message status and delivery reports |
Test mode
Test keys use the sandbox. Requests are validated exactly like live traffic, but nothing reaches a handset or WhatsApp, nothing is charged, DLT templates are not required and every OTP code is 123456. Sandbox messages are reported delivered unless the number ends in:
| Number ends in | Sandbox result |
|---|---|
0001 | Rejected (status rejected) |
0002 | Provider temporarily unavailable |
0003 | Provider timeout — outcome uncertain, never resent |
0004 | Submitted but not delivered (status failed) |
- OTP requests created with a test key can only be verified with a test key.
- Messages carry
environment: "test"in responses, reports and webhooks. - Keep live and test keys in separate configuration (for example production vs. staging secrets).
Rate limits
Requests are limited per API key (600 per minute by default), per project and per client IP. Every response carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset; a 429 response carries Retry-After. OTPs have additional per-number, per-IP and per-project limits — see OTP limits.
Request IDs
Every response has an X-Request-Id header, repeated as requestId in error bodies. Log it with your own request and quote it when contacting support.