WhatsApp

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_…. Both full_access and sending_access keys can call every WhatsApp endpoint. A domain-scoped key (one created with a domain_id, e.g. for SMTP) can't — every /v1/whatsapp/* request with it is 403 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.

  1. POST /v1/whatsapp/verifications with the user's number. Keep the returned id.
  2. The user receives the code on WhatsApp.
  3. POST /v1/whatsapp/verifications/check with the id (or the number) and the code. Treat the user as verified only when valid is true.

Start a verification

POST/api/v1/whatsapp/verifications

Body

tostringrequired
The recipient's phone number (see Phone number format).
languagestring
Language of the message: th (Thai) or en(English). Defaults to the platform default. If that translation isn't approved yet, the default language is used; the response's language says 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"}'
201 Created
{
  "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_ready before anything is sent or charged. Template messages (below) are not affected.
  • The code is valid for 10 minutes by default — use expiresAt rather than hard-coding it.
  • Starting a new verification cancels any earlier pending verification 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 authentication message and is charged like one. messageId is 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

POST/api/v1/whatsapp/verifications/check

Body

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 id from the start call. Provide id or to.
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"}'
200 OK
{
  "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.

statusMeaning
pendingWaiting for the right code. The user can try again.
approvedThe code was correct. Only the check that approved it returns valid: true; later checks return valid: false.
expiredThe code passed expiresAt. Start a new verification.
canceledA newer verification was started for the same number, or the code could not be sent.
max_attemptsToo many wrong codes (5 by default). Start a new verification.
Any status other than 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

POST/api/v1/whatsapp/messages

Sends 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, th or en_US.
componentsarray
Up to 10 template components with the variable values, in the WhatsApp Cloud API format (header, body, button with their parameters). 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 returns 422 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"}]}]}'
201 Created
{
  "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

  1. 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).
  2. The Bytesms team reviews every request before the name can be used, usually within 1 business day. A request is pending until it is approved or rejected (with a reason shown in the dashboard). Bytesms can later revoke an approved name.
  3. 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 with 422 invalid_sender_name (the message says which rule failed). Requesting a name that is already pending or approved returns 409 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 (with limit); on a plan without sender names it returns 403 sender_name_not_in_plan. Removing a name frees its slot.

List sender names

GET/api/v1/whatsapp/sender-names

Returns 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'
Response
{
  "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"
}
FieldDescription
data[].statuspending, approved, rejected or revoked.
data[].isDefaultThe approved name used when a send doesn't pass sender_name.
data[].reviewNoteReviewer's reason for a rejected or revoked name, else null.
limitSender names the plan allows.
usedPending + approved names (they count against limit).
defaultThe 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.

OTP codes never show a sender name. Meta fixes the wording of authentication templates, so /v1/whatsapp/verifications messages contain only the code and the security text WhatsApp provides.

Retrieve a message

GET/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'
Response
{
  "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"
otp for messages sent by the Verify flow.
statusstring
See Message statuses.
priceThbnumber
Price charged for the message, in THB.
refundedboolean
true when the price was returned to your balance because the message failed.
errorobject | null
{ code, message } from WhatsApp when the message failed, otherwise null.
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.

statusMeaning
queuedCreated; the credit is reserved and the message is being handed to WhatsApp.
acceptedWhatsApp accepted the message. This is the status in a successful send response.
sentWhatsApp sent the message.
deliveredDelivered to the recipient's device.
readThe recipient opened it (only when they have read receipts on).
failedWhatsApp couldn't send or deliver it — at send time or reported later. The credit is refunded (refunded: true) and error holds the reason.
A refund returns the price to where it came from. The included monthly credit part is returned only while that month is still current — included credit that has expired is not given back.

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_credits and 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.
402 Payment Required
{
  "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.

StatusnameWhen
401unauthorizedMissing, malformed, unknown or expired API key.
402insufficient_creditsBalance too low for this message. Adds neededThb and availableThb.
402subscription_inactiveThe workspace's subscription doesn't allow sending (e.g. unpaid).
403suspended_api_keyThe API key was suspended.
403whatsapp_not_in_planWhatsApp is available on the Starter plan and above.
403workspace_pausedSending is paused for this workspace.
404template_not_foundNo approved template with that name in that language.
404not_foundUnknown message id, or no verification for that id / number.
422validation_errorBody 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.
422invalid_recipientto isn't a valid phone number.
422country_not_allowedSending to that country isn't enabled.
422sender_name_requiredThe template uses {{sender_name}} and the workspace has no approved sender name. See Sender name.
422sender_name_not_approvedThe sender_nameyou passed isn't an approved sender name of the workspace.
422template_not_supportedThe template's category isn't authentication, utility or marketing.
429rate_limit_exceededWorkspace request rate limit, or more than 5 verification codes to one number in an hour.
400 / 502whatsapp_send_failedWhatsApp rejected the message (400) or failed (502). The credit is refunded. metaCode is Meta's error code or null.
502whatsapp_unavailableThe template lookup at WhatsApp failed. Retry later.
503whatsapp_unavailableWhatsApp sending is temporarily unavailable on the platform.
503otp_template_not_readyVerifications only: Bytesms's OTP template is still waiting for Meta's approval. Nothing is charged; retry later.