Skip to main content

POST WhatsApp OTP

This endpoint sends a WhatsApp message containing a one-time password (OTP) or verification text to a specified phone number. The system dispatches the message through the WhatsApp Business API and returns a unique identifier that can be used to track the message status.

Configure the API Endpoint

https://api.betatel.com/api/v1/connect-hub/whatsapp/otp
  • Method: POST

Set Up the Headers

ParamValueDescription
Content-typeapplication/jsonSpecifies the payload format.
x-api-key{{x-api-key}}API key for authorization.
x-account-id{{x-account-id}}User identifier for added security and tracking.

Craft the Request Body

Design the JSON payload to include the recipient's phone number and the message text to be delivered.

Example of body
{
"to": "38761444555",
"text": "482910"
}
FieldTypeRequiredDescription
tostringYesThe recipient's phone number in E.164 format (without the + prefix).
textstringYesThe message text to be sent (maximum 4096 characters).
tip

Phone Number Formatting:

Provide the phone number without the + prefix. For example, use 38761444555 instead of +38761444555. The number must be a valid WhatsApp-registered phone number.

Code Snippets

Example - cURL
curl --location 'https://api.betatel.com/api/v1/connect-hub/whatsapp/otp' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-account-id: YOUR_ACCOUNT_ID' \
--data '{
"to": "38761444555",
"text": "482910"
}'

Understanding the Response

Once the API processes your request, it returns a response containing the unique identifier for the message and the recipient's phone number.

JSON Schema:

{
"uuid": "01JV5V54KPYK9GB29265EQRZ2P",
"to": "38761444555"
}
  • uuid: The unique identifier for the WhatsApp message. Use this to track the message status.
  • to: The recipient's phone number as provided in the request.

Message Status Lifecycle

After a message is sent, WhatsApp reports status updates through the webhook. A message progresses through the following states:

StatusDescription
PENDINGMessage accepted and queued for delivery.
SENTMessage dispatched to the WhatsApp platform.
DELIVEREDMessage delivered to the recipient's device.
READRecipient has opened and read the message.
FAILEDMessage could not be delivered.
EXPIREDMessage expired before delivery was confirmed.

Error Handling

  • 400 - Bad Request: Invalid parameters or malformed request
  • 401 - Unauthorized: Authentication failed
  • 402 - Payment Required: Insufficient account balance
  • 500 - Internal Server Error: An unexpected error occurred on the server