API reference
Start a WhatsApp conversation
POST /v1/whatsapp/conversations
Send a person an approved template from one of your WhatsApp numbers — an appointment reminder, a delivery notice — and the number's agent answers when they write back, with the template's words as its own first line and your variables. The conversation waits a day for an answer. A template Meta refuses ends the conversation failed, with Meta's reason in error. Needs whatsapp:write, a live key and an Idempotency-Key.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key |
header | string | Yes | Your own id for this message. Required. |
Body
Sent as JSON. A field this operation does not take is refused, so a typo fails loudly.
| Field | Type | Required | Description |
|---|---|---|---|
external_id |
string or null | No | |
metadata |
object | No | Your own data, returned on every read and event. The agent never sees it. |
sender_id |
string (uuid) | Yes | The WhatsApp number to send from. |
template |
WhatsappTemplateChoice | Yes | |
to_number |
string | Yes | The person's WhatsApp number, in international format, like +966501234567. |
variables |
object | No | Values for the agent's {{placeholders}}, for when the person answers. |
Answer
201 with Conversation.
Errors
Every error is a problem document with a stable code.
| Status | When |
|---|---|
401 |
The key is missing, mistyped, unknown, revoked or expired. |
402 |
The organization's credit is used up. |
403 |
A test key: there are no WhatsApp test numbers. |
404 |
This key reaches no such WhatsApp number. |
409 |
The person is on a block list, the number's agent is not published, or the connection is not ready. |
422 |
No such approved template, or the wrong number of values. |
429 |
Too many requests for this key or its organization; see Retry-After. |
500 |
Something went wrong on our side. Quote the request_id to support. |
501 |
This deployment does not run WhatsApp. |
Examples
#!/bin/sh
# Start a WhatsApp conversation. The agent answers when they write back. With a live key.
curl -sS --fail-with-body -X POST "https://api.aigently.ai/v1/whatsapp/conversations" \
-H "Authorization: Bearer $AIGENTLY_API_KEY" \
-H "Idempotency-Key: reminder-4471" \
--json '{
"sender_id": "7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f",
"to_number": "+966501234567",
"template": {
"name": "appointment_reminder",
"language": "en_US",
"parameters": [
"Sara",
"Monday at 10"
]
},
"variables": {
"first_name": "Sara"
},
"metadata": {
"booking": "4471"
}
}'
Try it
Sends this request to the API from your browser, with a test key. Nothing it does rings a phone.