Contents

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
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_… or sms21_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

Never put an API key in a browser, mobile app, public repository or log line. Front-ends call your own backend, which calls SMS21.

Scopes

A key can only do what its scopes allow. Grant each application the minimum it needs.

ScopeAllows
otp:sendSend one-time passwords
otp:verifyVerify one-time passwords
sms:sendSend individual SMS messages
whatsapp:sendSend WhatsApp messages
reports:readRead 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 inSandbox result
0001Rejected (status rejected)
0002Provider temporarily unavailable
0003Provider timeout — outcome uncertain, never resent
0004Submitted 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.