Send WhatsApp OTP codes and approved template messages from Bytesms's verified business number, paid from prepaid THB credit.
Send one-time passcodes and approved template messages over WhatsApp with the same API key you use for email. Messages are sent from Bytesms's own verified WhatsApp Business number — you don't need a Meta Business account, a WhatsApp Business Account or your own phone number.
Overview
- WhatsApp is available on the Starter plan and above. On other plans every endpoint returns
403 whatsapp_not_in_plan. - Messages are paid from a prepaid credit balance in Thai baht (THB). Each eligible plan includes a monthly credit; you can top up more in Dashboard → WhatsApp. See Pricing & credits.
- Workspace owners and admins can also send an approved template without code from Dashboard → WhatsApp → Send message (same pricing and rules as the API).
- Authenticate with
Authorization: Bearer tp_live_…. Bothfull_accessandsending_accesskeys can call every WhatsApp endpoint. A domain-scoped key (one created with adomain_id, e.g. for SMTP) can't — every/v1/whatsapp/*request with it is403 restricted_api_key, so an email-only credential never spends WhatsApp credit. The WhatsApp endpoints share the workspace's request rate limit with the rest of the API. - Response fields on the WhatsApp endpoints are
camelCase(expiresAt,priceThb, …).
Phone number format
Pass recipients in E.164 format, e.g. +66812345678. These forms are also accepted and normalized to E.164:
- Without the plus sign:
66812345678. - Thai local format with the leading zero:
0812345678(read as a Thai number).
Numbers that aren't valid phone numbers are rejected with 422 invalid_recipient. You can message every country WhatsApp supports, unless the platform has restricted destinations (to contain SMS-pumping fraud). A number in a country outside that list returns 422 country_not_allowed, with the allowed list in the message. The countries you can send to are shown in Dashboard → WhatsApp. Prices outside Thailand follow Meta's rate for the country (see Pricing & credits).
OTP Verify quickstart
The Verify flow generates a 6-digit code, sends it with Bytesms's authentication template, and checks the code your user types back. You never see or store the code.
POST /v1/whatsapp/verificationswith the user's number. Keep the returnedid.- The user receives the code on WhatsApp.
POST /v1/whatsapp/verifications/checkwith theid(or the number) and the code. Treat the user as verified only whenvalidistrue.
Start a verification
/api/v1/whatsapp/verificationsBody
tostringrequired- The recipient's phone number (see Phone number format).
languagestring- Language of the message:
th(Thai) oren(English). Defaults to the platform default. If that translation isn't approved yet, the default language is used; the response'slanguagesays which one was sent.
# Send a code
curl -X POST 'https://api.bytesms.com/api/v1/whatsapp/verifications' \
-H 'Authorization: Bearer tp_live_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"to":"+66812345678","language":"th"}'{
"id": "5b2f6c1e-8d4a-4f7b-9c3e-1a2b3c4d5e6f",
"to": "+66812345678",
"status": "pending",
"channel": "whatsapp",
"language": "th",
"expiresAt": "2026-11-22T08:40:00.000Z",
"messageId": "9e8d7c6b-5a4f-4e3d-8c2b-1a0f9e8d7c6b",
"priceThb": 0.6
}- OTP uses Bytesms's own authentication template, which Meta must approve first. Until it is approved, this endpoint returns
503 otp_template_not_readybefore anything is sent or charged. Template messages (below) are not affected. - The code is valid for 10 minutes by default — use
expiresAtrather than hard-coding it. - Starting a new verification cancels any earlier
pendingverification for the same number in your workspace, so only the latest code works. - At most 5 codes per number per hour (per workspace, counted per clock hour). More return
429 rate_limit_exceeded. - The OTP message is an
authenticationmessage and is charged like one.messageIdis the underlying message — retrieve it to follow delivery. If the send fails, the verification is canceled, the credit is refunded and the error is returned.
Check a code
/api/v1/whatsapp/verifications/checkBody
codestringrequired- The code the user entered, as a string of 4–10 digits (send it as a string so leading zeros survive).
idstring- The verification
idfrom the start call. Provideidorto. tostring- The phone number, used when you don't pass
id— the most recent verification for that number is checked.
# Check a code
curl -X POST 'https://api.bytesms.com/api/v1/whatsapp/verifications/check' \
-H 'Authorization: Bearer tp_live_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"id":"5b2f6c1e-8d4a-4f7b-9c3e-1a2b3c4d5e6f","code":"482913"}'{
"id": "5b2f6c1e-8d4a-4f7b-9c3e-1a2b3c4d5e6f",
"to": "+66812345678",
"status": "approved",
"valid": true
}A check always returns 200 with the verification's status and whether this code was valid. A wrong code returns status: "pending" and valid: false while attempts remain.
| status | Meaning |
|---|---|
pending | Waiting for the right code. The user can try again. |
approved | The code was correct. Only the check that approved it returns valid: true; later checks return valid: false. |
expired | The code passed expiresAt. Start a new verification. |
canceled | A newer verification was started for the same number, or the code could not be sent. |
max_attempts | Too many wrong codes (5 by default). Start a new verification. |
pending is final. Checking a finished verification never returns valid: true. Codes are compared in constant time and each attempt is counted before the comparison, so parallel guesses can't exceed the limit.Send a template message
/api/v1/whatsapp/messagesSends a template that is approved on Bytesms's WhatsApp Business Account. WhatsApp only allows business-initiated messages through approved templates; the template's category (authentication, utility or marketing), as set by Meta, decides the price.
Body
tostringrequired- The recipient's phone number (see Phone number format).
templatestringrequired- The approved template name: lowercase letters, digits and underscores (
^[a-z0-9_]{1,512}$). languagestringdefault"en"- The template language code, e.g.
en,thoren_US. componentsarray- Up to 10 template components with the variable values, in the WhatsApp Cloud API format (
header,body,buttonwith theirparameters). Passed to WhatsApp as is. sender_namestring- One of your workspace's approved sender names, used when the template has the
{{sender_name}}parameter. Omit it to use the workspace's default sender name. A name that isn't approved for the workspace returns422 sender_name_not_approved. Ignored by templates without the parameter. See Sender name.
# Send an order update
curl -X POST 'https://api.bytesms.com/api/v1/whatsapp/messages' \
-H 'Authorization: Bearer tp_live_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"to":"+66812345678","template":"order_shipped","language":"th","components":[{"type":"body","parameters":[{"type":"text","text":"A-10293"}]}]}'{
"id": "3c1d5e7f-9a2b-4c6d-8e0f-1a3b5c7d9e2f",
"to": "+66812345678",
"country": "TH",
"category": "utility",
"template": "order_shipped",
"language": "th",
"kind": "template",
"status": "accepted",
"priceThb": 0.6,
"refunded": false,
"error": null,
"verificationId": null,
"createdAt": "2026-11-22T08:30:00.000Z",
"sentAt": null,
"deliveredAt": null,
"readAt": null
}The price is debited before the message is handed to WhatsApp. If WhatsApp rejects the message, the credit is refunded and the call fails with whatsapp_send_failed (metaCodecarries Meta's error code when there is one). A template that doesn't exist or isn't approved in that language returns 404 template_not_found.
Sender name
Every message is sent from Bytesms's shared WhatsApp Business number, so the chat title your recipients see is Bytesms's verified business name, set by Meta. Your brand appears inside the message instead: templates with the {{sender_name}} parameter show one of your workspace's sender names.
Request and approval
- A workspace owner or admin requests a name in Dashboard → WhatsApp → Sender names, with an optional note for the reviewer (e.g. the registered company name or website).
- The Bytesms team reviews every request before the name can be used, usually within 1 business day. A request is
pendinguntil it isapprovedorrejected(with a reason shown in the dashboard). Bytesms can laterrevokean approved name. - The first approved name becomes the workspace's default. Owners and admins can make another approved name the default, or remove names they no longer use.
- Rules: 2–30 characters; letters, digits, spaces and
. & ' -only; no links; no platform brands such as WhatsApp, Meta or Bytesms. An invalid name is refused with422 invalid_sender_name(the message says which rule failed). Requesting a name that is already pending or approved returns409 sender_name_exists. - Each plan allows a number of sender names; pending and approved names both count. By default: Starter 1, Pro 3, Max 10, Enterprise 20. Past the quota a request returns
403 sender_name_limit(withlimit); on a plan without sender names it returns403 sender_name_not_in_plan. Removing a name frees its slot.
List sender names
/api/v1/whatsapp/sender-namesReturns every sender name of the workspace with its review status, the plan quota and the default. Only names with status: "approved" can be sent.
# List sender names
curl -X GET 'https://api.bytesms.com/api/v1/whatsapp/sender-names' \
-H 'Authorization: Bearer tp_live_xxxxxxxxx'{
"data": [
{
"id": "0b6f1c2e-3d4a-4b5c-8d6e-7f8a9b0c1d2e",
"name": "Acme Shop",
"status": "approved",
"isDefault": true,
"note": "Registered as Acme Shop Co., Ltd.",
"reviewNote": null,
"reviewedAt": "2026-11-21T03:12:00.000Z",
"createdAt": "2026-11-20T09:45:00.000Z"
},
{
"id": "6a7b8c9d-0e1f-4a2b-9c3d-4e5f6a7b8c9d",
"name": "Acme Rewards",
"status": "pending",
"isDefault": false,
"note": null,
"reviewNote": null,
"reviewedAt": null,
"createdAt": "2026-11-22T02:10:00.000Z"
}
],
"limit": 3,
"used": 2,
"default": "Acme Shop"
}| Field | Description |
|---|---|
data[].status | pending, approved, rejected or revoked. |
data[].isDefault | The approved name used when a send doesn't pass sender_name. |
data[].reviewNote | Reviewer's reason for a rejected or revoked name, else null. |
limit | Sender names the plan allows. |
used | Pending + approved names (they count against limit). |
default | The default approved name, or null when none is approved. |
The {{sender_name}} parameter
Any approved template whose body contains the named parameter {{sender_name}} gets a sender name filled in automatically when you call POST /v1/whatsapp/messages: the one you pass as sender_name, otherwise the workspace's default. Send only the template's other parameters; Bytesms adds the body parameter { "type": "text", "parameter_name": "sender_name", "text": "<approved name>" } for you. A sender_name body parameter of your own is replaced, so only approved names reach recipients.
# Default sender name
curl -X POST 'https://api.bytesms.com/api/v1/whatsapp/messages' \
-H 'Authorization: Bearer tp_live_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"to":"+66812345678","template":"order_shipped_branded","language":"th","components":[{"type":"body","parameters":[{"type":"text","parameter_name":"order_id","text":"A-10293"}]}]}'
# Pick an approved name
curl -X POST 'https://api.bytesms.com/api/v1/whatsapp/messages' \
-H 'Authorization: Bearer tp_live_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"to":"+66812345678","template":"order_shipped_branded","language":"th","sender_name":"Acme Rewards","components":[{"type":"body","parameters":[{"type":"text","parameter_name":"order_id","text":"A-10293"}]}]}'Both checks happen before any credit is debited: a template that needs a sender name while the workspace has no approved one fails with 422 sender_name_required, and a sender_namethat isn't approved for the workspace (pending, rejected, revoked or unknown) fails with 422 sender_name_not_approved.
/v1/whatsapp/verifications messages contain only the code and the security text WhatsApp provides.Retrieve a message
/api/v1/whatsapp/messages/{message_id}Returns a template or OTP message of your workspace, in the same shape as the send response. Unknown ids return 404 not_found.
# Retrieve a message
curl -X GET 'https://api.bytesms.com/api/v1/whatsapp/messages/3c1d5e7f-9a2b-4c6d-8e0f-1a3b5c7d9e2f' \
-H 'Authorization: Bearer tp_live_xxxxxxxxx'{
"id": "3c1d5e7f-9a2b-4c6d-8e0f-1a3b5c7d9e2f",
"to": "+66812345678",
"country": "TH",
"category": "utility",
"template": "order_shipped",
"language": "th",
"kind": "template",
"status": "read",
"priceThb": 0.6,
"refunded": false,
"error": null,
"verificationId": null,
"createdAt": "2026-11-22T08:30:00.000Z",
"sentAt": "2026-11-22T08:30:01.000Z",
"deliveredAt": "2026-11-22T08:30:02.000Z",
"readAt": "2026-11-22T08:31:15.000Z"
}Message fields
idstring- Message id.
tostring- Recipient in E.164 format.
countrystring- Recipient country (ISO 3166-1 alpha-2), used for pricing.
category"authentication" | "utility" | "marketing"- Template category from Meta.
templatestring- Template name.
languagestring- Template language code.
kind"template" | "otp"otpfor messages sent by the Verify flow.statusstring- See Message statuses.
priceThbnumber- Price charged for the message, in THB.
refundedbooleantruewhen the price was returned to your balance because the message failed.errorobject | null{ code, message }from WhatsApp when the message failed, otherwisenull.verificationIdstring | null- The verification this OTP message belongs to.
createdAtstring- When the message was created (ISO 8601).
sentAt / deliveredAt / readAtstring | null- When WhatsApp reported each status.
Message statuses
Statuses only move forward. WhatsApp reports them asynchronously; poll the message to follow them.
| status | Meaning |
|---|---|
queued | Created; the credit is reserved and the message is being handed to WhatsApp. |
accepted | WhatsApp accepted the message. This is the status in a successful send response. |
sent | WhatsApp sent the message. |
delivered | Delivered to the recipient's device. |
read | The recipient opened it (only when they have read receipts on). |
failed | WhatsApp couldn't send or deliver it — at send time or reported later. The credit is refunded (refunded: true) and error holds the reason. |
Pricing & credits
- Prepaid balance in THB.Each message's price is debited when you send it. If the balance can't cover it, the call fails with
402 insufficient_creditsand nothing is sent. - Included monthly credit. Eligible plans include a credit amount every calendar month (UTC). It resets at the start of each month and unused included credit does not roll over. Included credit is spent before top-up credit.
- One wallet for email and WhatsApp. WhatsApp is paid from the same prepaid credit as over-quota email. Top-ups (card or PromptPay), auto-recharge and credit expiry are described in Credits & billing; you can top up from Settings → Billing or Dashboard → WhatsApp.
- Price per message depends on your plan, the template category (
authentication,utility,marketing) and the destination country. Thailand has its own price list; other countries are priced from Meta's rate for that country times a plan multiplier. Your current prices, included credit and balance are shown in Dashboard → WhatsApp. - Every message response includes
priceThb, the amount charged.
{
"statusCode": 402,
"name": "insufficient_credits",
"message": "Not enough prepaid credit. Top up (or turn on auto-recharge) in the dashboard under Settings → Billing.",
"neededThb": 0.6,
"availableThb": 0.25
}Errors
Errors use the standard error envelope { statusCode, name, message }. Branch on name.
| Status | name | When |
|---|---|---|
| 401 | unauthorized | Missing, malformed, unknown or expired API key. |
| 402 | insufficient_credits | Balance too low for this message. Adds neededThb and availableThb. |
| 402 | subscription_inactive | The workspace's subscription doesn't allow sending (e.g. unpaid). |
| 403 | suspended_api_key | The API key was suspended. |
| 403 | whatsapp_not_in_plan | WhatsApp is available on the Starter plan and above. |
| 403 | workspace_paused | Sending is paused for this workspace. |
| 404 | template_not_found | No approved template with that name in that language. |
| 404 | not_found | Unknown message id, or no verification for that id / number. |
| 422 | validation_error | Body isn't a JSON object; bad template, language or components; code isn't 4–10 digits; neither id nor a valid to on a check. |
| 422 | invalid_recipient | to isn't a valid phone number. |
| 422 | country_not_allowed | Sending to that country isn't enabled. |
| 422 | sender_name_required | The template uses {{sender_name}} and the workspace has no approved sender name. See Sender name. |
| 422 | sender_name_not_approved | The sender_nameyou passed isn't an approved sender name of the workspace. |
| 422 | template_not_supported | The template's category isn't authentication, utility or marketing. |
| 429 | rate_limit_exceeded | Workspace request rate limit, or more than 5 verification codes to one number in an hour. |
| 400 / 502 | whatsapp_send_failed | WhatsApp rejected the message (400) or failed (502). The credit is refunded. metaCode is Meta's error code or null. |
| 502 | whatsapp_unavailable | The template lookup at WhatsApp failed. Retry later. |
| 503 | whatsapp_unavailable | WhatsApp sending is temporarily unavailable on the platform. |
| 503 | otp_template_not_ready | Verifications only: Bytesms's OTP template is still waiting for Meta's approval. Nothing is charged; retry later. |
