Free setup on annual plans

Sign up today!

WhatsApp and SMS

API Reference: WhatsApp and SMS endpoints

WhatsApp and SMS channels send and receive messages through the Twilio account of the customer. These endpoints cover two things: connecting a WhatsApp number with Meta’s Embedded Signup, as the Connect WhatsApp wizard in AnswerPal does, and the callbacks Twilio uses to bring in incoming messages and delivery updates. You do not call the callbacks yourself; they are described so you know what happens to a message. Channels themselves, also WhatsApp and SMS channels, are managed on the Channels page.

Endpoints

WhatsApp signup

  • GET /api/whatsapp-signup/config
    Access: Bearer JWT (Configurator or Administrator)
    Whether the signup is available, and the public Meta settings the browser needs to open Meta’s signup dialog.
  • POST /api/whatsapp-signup/start
    Access: Bearer JWT (Configurator or Administrator)
    Start a signup, or resume the one that is still running. Returns the flow and a signed state for the Meta step.
  • GET /api/whatsapp-signup/active
    Access: Bearer JWT (Configurator or Administrator)
    The running signup of the account, or { "flow": null }.
  • GET /api/whatsapp-signup/{flowId}
    Access: Bearer JWT (Configurator or Administrator)
    The current state of one signup. The wizard polls it until the number is active or the signup ends.
  • POST /api/whatsapp-signup/{flowId}/meta-callback
    Access: Bearer JWT (Configurator or Administrator)
    Hand over the result of Meta’s dialog: the WhatsApp Business Account, the phone number and the display name. AnswerPal then registers the number at Twilio.
  • POST /api/whatsapp-signup/{flowId}/cancel
    Access: Bearer JWT (Configurator or Administrator)
    Stop a signup that has not finished. A finished signup is returned unchanged.

SMS callbacks

  • POST /api/webhooks/twilio/sms/inbound
    Access: Public (no bearer token)
    Called by Twilio for every SMS that arrives on a number of an SMS channel. Adds the message to a ticket.
  • POST /api/webhooks/twilio/sms/status
    Access: Public (no bearer token)
    Called by Twilio when the delivery state of an SMS sent by AnswerPal changes.

WhatsApp callbacks

  • POST /api/webhooks/twilio/whatsapp/inbound
    Access: Public (no bearer token)
    Called by Twilio for every WhatsApp message that arrives on a connected number. Adds the message to a ticket.
  • POST /api/webhooks/twilio/whatsapp/status
    Access: Public (no bearer token)
    Called by Twilio when the delivery state of a WhatsApp message sent by AnswerPal changes.

Connecting a WhatsApp number

  • Steps
    1. GET .../config tells whether the signup is available. 2. POST .../start creates the flow and a state. 3. The browser opens Meta’s signup dialog with the Meta settings from config; there the customer chooses or creates the WhatsApp Business Account and the number. 4. The browser sends the result with state to POST .../{flowId}/meta-callback. 5. AnswerPal registers the number as a WhatsApp sender in the customer’s Twilio account and waits until Meta and Twilio approve it; poll GET .../{flowId} (AnswerPal checks about every 5 minutes). 6. When the sender is online, AnswerPal creates an active WhatsApp channel named WhatsApp +number, and channelId is filled.
  • Conditions
    The account needs its own Twilio account in AnswerPal; otherwise start answers 409 SubaccountMissing. An account has at most one running signup: start resumes it instead of making a second one. A number that is already a WhatsApp sender of another channel is refused; a number of an SMS channel of the same account can be used, so WhatsApp and SMS share one number.
  • Time limits
    The Meta step must be finished before expiresAt (60 minutes after start; resuming extends it, up to 24 hours after the signup began). After the Meta step, registration and approval may take up to 48 hours; after that the flow fails with ReviewTimeout or RegistrationTimedOut.

Flow (response)

  • flowId (integer)
  • status
    AwaitingMeta (waiting for Meta’s dialog), MetaCompleted, RegisteringSender, PendingReview (Meta or Twilio still checks the number), and the end states Active, Failed, Cancelled and Expired.
  • senderAddress (the number in E.164 format), wabaId, displayName
  • channelId
    The new WhatsApp channel, once the flow is Active.
  • lastErrorCode, lastError
    Why the flow stopped or waits, for example ProviderRejected, DisplayNameRequired, WabaMismatch, SenderAlreadyRegistered, ReviewTimeout.
  • expiresAt, updatedAt

Start answers { "flow": {...}, "state": "..." }; state is null when the resumed flow is already past the Meta step. Resuming a flow that waits for Meta gives a new state and makes the previous one invalid.

Meta result (body of meta-callback)

  • state (string, required)
    The state of the last start. It can be used once.
  • wabaId (string, required)
    The WhatsApp Business Account ID: letters and digits, at most 100.
  • phoneNumber (string, required)
    A valid phone number; stored in E.164 format.
  • displayName (string, required)
    The name customers see, 1 to 255 characters.
  • businessPortfolioId (string, optional)
    Letters and digits, at most 100.

The answer is the flow, now MetaCompleted. Sending the same result again after it was accepted returns the current flow.

Configuration (response)

enabled, metaAppId, metaConfigId and metaPartnerSolutionId: the public IDs of Meta’s dialog; they are null when the signup is not available. No secret is returned.

Errors

Start, meta-callback and cancel answer 409 with { "code": "...", "message": "..." }. Codes: SignupDisabled, SubaccountMissing, SignupBusy (another start runs; try again), FlowChanged (the flow changed meanwhile; read it again), FlowNotFound, FlowNotAwaitingMeta, InvalidState, StateAlreadyUsed, FlowExpired, InvalidSender, InvalidDisplayName, InvalidWaba, InvalidBusinessPortfolio, SenderAlreadyRegistered, SenderSignupInProgress (another signup claims the number), SharedSenderRolloutPending and WabaMismatch (the Twilio account already uses another WhatsApp Business Account). On meta-callback an unknown flow also answers 409 FlowNotFound; reading or cancelling an unknown flow answers 404.

POST /api/whatsapp-signup/start
Authorization: Bearer <token>

200 OK
{
  "flow": {
    "flowId": 87,
    "status": "AwaitingMeta",
    "senderAddress": null,
    "wabaId": null,
    "channelId": null,
    "lastErrorCode": null,
    "lastError": null,
    "expiresAt": "2026-12-01T11:05:00+00:00",
    "updatedAt": "2026-12-01T10:05:00+00:00",
    "displayName": null
  },
  "state": "eyJmIjo4Nywi..."
}
POST /api/whatsapp-signup/87/meta-callback
Authorization: Bearer <token>
Content-Type: application/json

{
  "state": "eyJmIjo4Nywi...",
  "wabaId": "102030405060708",
  "phoneNumber": "+32 470 00 00 33",
  "displayName": "Example Support",
  "businessPortfolioId": "908070605040302"
}

200 OK
{
  "flowId": 87,
  "status": "MetaCompleted",
  "senderAddress": "+32470000033",
  "wabaId": "102030405060708",
  "displayName": "Example Support",
  ...
}
GET /api/whatsapp-signup/87
Authorization: Bearer <token>

200 OK
{
  "flowId": 87,
  "status": "Active",
  "senderAddress": "+32470000033",
  "wabaId": "102030405060708",
  "channelId": 61,
  "lastErrorCode": null,
  "lastError": null,
  "expiresAt": "2026-12-01T11:05:00+00:00",
  "updatedAt": "2026-12-01T13:40:12+00:00",
  "displayName": "Example Support"
}
409 Conflict
{
  "code": "SenderAlreadyRegistered",
  "message": "..."
}

Twilio callbacks

AnswerPal sets these URLs on the number at Twilio itself, when a WhatsApp number is connected or an SMS channel is set up, and adds a token per channel to the URL for incoming messages. Every callback must carry a valid Twilio signature, made with the auth token of the Twilio account the number belongs to. The body is form-encoded (anything else gives 400) and at most 128 KB (413 above that); at most 600 callbacks per minute come in per source address (429 above that). AnswerPal stores the callback first and processes it right after, so the answer comes quickly.

Incoming messages

  • Fields used
    AccountSid, MessageSid (or SmsSid), From, To, Body, ProfileName, WaId, NumMedia, MediaUrl0… and MediaContentType0…
  • Channel
    The message must match exactly one active channel: the Twilio account, the number in To (whatsapp:+number on the WhatsApp route, +number on the SMS route) and the channel type of the route. Otherwise the answer is 403 and no ticket is made.
  • Ticket
    The message goes to the open conversation of the sender on that channel. Without one, or when its ticket is closed, AnswerPal starts a new ticket (status Open, subject WhatsApp or SMS with the sender’s name or number); a closed ticket is not reopened. The sender becomes or updates an end user. Then topic detection and the automatic replies of the channel run as for any message.
  • Media
    WhatsApp: up to 10 photos, PDFs or voice messages per message are downloaded and added to the message. SMS: media is not downloaded; the message gets a note that it had attachments.
  • STOP and START (SMS only)
    A message that is only STOP, STOPALL, UNSUBSCRIBE, CANCEL, END, QUIT, REVOKE or OPTOUT records that the number no longer wants SMS; START, YES or UNSTOP records that it does again. Case and punctuation around the word do not matter. The message still appears on the ticket, and AnswerPal sends no reply of its own. On WhatsApp these words are ordinary text.
  • Answer
    200 with an empty TwiML document (<Response></Response>, application/xml): Twilio sends nothing back. A repeated delivery of the same message also gets 200 and is processed once.

Delivery updates

  • Fields used
    AccountSid, MessageSid (or SmsSid), MessageStatus (or SmsStatus) and ErrorCode.
  • Effect
    The state of the message AnswerPal sent moves forward: accepted, queued, sending, sent, delivered, read, or failed and undelivered, which mark the message as failed with Twilio’s error code. An update never moves a message back. When Twilio reports that the recipient unsubscribed, the opt-out is recorded.
  • Answer
    204 No Content, also for a repeated update.
POST /api/webhooks/twilio/sms/inbound?<channel token>
Content-Type: application/x-www-form-urlencoded

AccountSid=AC00000000000000000000000000000001
&MessageSid=SM00000000000000000000000000000002
&From=%2B32470000044
&To=%2B3290000055
&Body=Can+I+move+my+appointment+to+Friday%3F
&NumMedia=0

200 OK
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8"?><Response></Response>
POST /api/webhooks/twilio/whatsapp/status?<token>
Content-Type: application/x-www-form-urlencoded

AccountSid=AC00000000000000000000000000000001
&MessageSid=SM00000000000000000000000000000003
&MessageStatus=undelivered
&ErrorCode=63016

204 No Content

Access and status codes

The signup endpoints need a bearer token with the role Configurator or Administrator. The four callbacks take no bearer token; the Twilio signature protects them, and only Twilio can make it. The access line of each endpoint above is the reference.

  • 200 OK, 204 No Content
    Success; incoming messages answer an empty TwiML document, delivery updates no body.
  • 400 Bad Request
    A signup body that is not valid JSON or misses fields; a callback that is not form-encoded, cannot be read or has no message ID.
  • 401 Unauthorized, 403 Forbidden
    Signup: no valid token or a role without access. Callbacks: a missing or invalid Twilio signature, an unknown Twilio account, or an incoming message that matches no active channel (403, empty body).
  • 404 Not Found
    No signup with that ID for this account (read and cancel).
  • 409 Conflict
    A signup error with code and message, see above.
  • 413 Payload Too Large, 429 Too Many Requests
    A callback above 128 KB, or more than 600 callbacks per minute from one address.
  • 500 Internal Server Error
    The callback could not be stored; Twilio may try again.

FAQ

No. AnswerPal sets them on the number when it connects a WhatsApp number or sets up an SMS channel. The callbacks only work with Twilio's signature, so they cannot be called by hand.

Yes, when both channels belong to the same account. A number that is already a WhatsApp sender of another channel cannot be connected again.

The number is recorded as opted out of SMS and the message still appears on the ticket. A later START opts it in again. AnswerPal itself sends no reply to these words.

The number, the Twilio account and the channel type must match exactly one active channel. Check that the channel is active and its connection is ready on the Channels page.

Need more help?

Table of Contents

AnswerPal: AI-powered customer service solutions to elevate your support and communication effortlessly.

Contact

For all support, sales, and partnership inquiries, email us at info@answerpal.eu

AnswerPal
Bisschoppenhoflaan 380
2100 Antwerp
Belgium

+32.36416685

BE 0862.692.858