Send One-Time Code

One-time codes

Send One-Time Code

Sends a code you generated to a WhatsApp number, using your approved authentication template — the code goes into the message and the copy-code button. We do not generate, store, expire or check the code; that stays yours. One number may be sent at most 5 codes in 10 minutes, and the workspace at most 120 sends a minute (codes keep the top of the budget it shares with Send Message). Each code is charged at WhatsApp's authentication rate, which is far higher for numbers abroad. Needs a full key.

POST/codes

Headers

Idempotency-Keystring
Any unique string. A retry with the same key within 24 hours returns the first request's answer instead of acting twice.
Katexs-Workspacestring
Developers only: the customer workspace this request acts in — its org_… id from POST /customers. Leave it out to act in your own workspace. Refused with 404 (Workspace not found.) when the id is unknown, is not one of your customers, or is not an org_… id; 410 when that customer was deleted (restore it with POST /customers/{id}/restore until it is erased); 403 when the key belongs to one customer workspace (it cannot act as another); 400 when your workspace is not a developer workspace. /customers/* and GET /customers/usage are your own workspace's and refuse the header with 400: call them without it.

Request body

tostringrequired
The number to send the code to. Include the + and the country code (a leading 00 works too); spaces are fine. A number without its country code is refused: nothing is assumed about the country.
codestringrequired
The code you generated, 16 characters at most after trimming.
templatestring
Which approved authentication template, by name. Needed only when you have more than one.
languagestring
Which approved language version, exactly as approved — en, hi. Needed only when one template name is approved in several languages.
idempotencyKeystring
Same as the Idempotency-Key header, for clients that cannot set headers. The header wins when both are sent.

Example request

bash
curl -X POST "https://app.katexs.com/api/v1/codes" \
  -H "Authorization: Bearer $KATEXS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+1 415 555 0134",
  "code": "394812"
}'

Responses

StatusDescription
200WhatsApp accepted the code. A replay of an Idempotency-Key returns the first answer, whatever it was, with an Idempotent-Replayed: true header.
400The body is not JSON, to or code is missing, the code is over 16 characters, or the number cannot be read.
401The key is missing, wrong or revoked. The answer is always the same, whichever it is.
402The Free plan's WhatsApp messages are used up. Switching to pay-as-you-go lifts it.
403The key's access level (read-only or build) does not allow this request, the plan does not include it, or a customer's key named another workspace in Katexs-Workspace. code says which: key_scope_read, key_scope_build, workspace_header_forbidden, or forbidden.
404No approved authentication template (of that name and in that language, when you named them). When you sent a language and templates are approved in others, the sentence lists those languages; otherwise create one with Create Code Template and submit it for review.
409More than one approved code template matches — the answer lists them in templates; name one with template, or with language when one name is approved in several languages. Also: WhatsApp is not connected (whatsapp_not_connected), sending is restricted on the number (whatsapp_blocked), or a request with the same Idempotency-Key is still in flight (idempotency_in_progress).
410The customer named in Katexs-Workspace was deleted. POST /customers/{id}/restore brings it back until its erase date.
429Over 120 sends a minute for the workspace (code: rate_limit_codes, Retry-After: 60), or 5 codes to this number in the last 10 minutes (code: rate_limit_code_recipient, Retry-After: 600). limit names which. The Idempotency-Key is released, so a later retry with it is a real retry.
502WhatsApp refused the message, in its own words. Usually a bad moment — safe to retry.
503WhatsApp sending is not available right now. Retry later.

Response fields

sentbooleanrequired
WhatsApp accepted the code.
tostringrequired
The number it went to, digits only with the country code.
templatestringrequired
The template it was sent with.
languagestringrequired
The language version it was sent in.
messageRefstring | nullrequired
WhatsApp's receipt for the message.
200 response
{
  "sent": true,
  "to": "919812345678",
  "template": "login_code",
  "language": "en",
  "messageRef": "wamid.HBgMOTE5ODEyMzQ1Njc4FQIAERgSNEQ3QTlFMkI1QzFGOEQ2MEEA"
}

Last updated November 2026 · Found a problem? Email support@katexs.com