Skip to main content

Subscribe to WABA-related events

Agent Skill

Automate this endpoint with an AI agent using the 2chat-whatsapp-waba skill:

npx skills add 2ChatCo/agent-skills -s 2chat-whatsapp-waba

Posting a request to this endpoint will create a new webhook subscription to the specified event on your WhatsApp Business API (WABA) number.

List of accepted events

Any of these events can be specified as a query parameter in the invocation URL.

info

Check out some of the payload examples.

💡 You can also subscribe and unsubscribe to events manually. Learn more here.

EventDescription
whatsapp.waba.message.sentTriggers when a new WhatsApp message is sent. Example.
whatsapp.waba.message.receivedTriggers when a new WhatsApp message is received on your WABA number. Example.
whatsapp.waba.message.receipt.sentTriggers when a message you sent has been transmitted to the WhatsApp network and is on its way to the recipient. Example.
whatsapp.waba.message.receipt.receivedTriggers when a message you sent is received on the app of its intended receiver. Example.
whatsapp.waba.template.createdTriggers when a new message template is submitted to WhatsApp through 2Chat — via the API or the web app. Example.
whatsapp.waba.template.status.updatedTriggers when WhatsApp finishes reviewing one of your message templates, or changes its status later on. Example.
whatsapp.waba.template.deletedTriggers when one of your message templates is deleted — through 2Chat or directly in WhatsApp Manager. Example.

Parameters

info

These parameters should be sent as JSON payload in the request body.

FieldDescription
hook_urlA valid and publicly reachable URL that 2Chat will invoke when the event is triggered
on_numberThe WABA phone number you have configured and connected to 2Chat. Always make sure it is connected

Invocation

Assume we want to subscribe to the event whatsapp.waba.message.sent as example:

curl --location --request POST 'https://api.p.2chat.io/open/webhooks/subscribe/whatsapp.waba.message.sent' \
--header 'X-User-API-Key: your_api_key_here' \
--header 'Content-Type: application/json' \
--data-raw '{
"hook_url": "https://www.toptal.com/developers/postbin/1681755466939-3421728690154",
"on_number": "+16173518454"
}'

Response

The API will return the newly configured webhook if successful.

{
"success": true,
"data": {
"uuid": "WHK530c9d58-2259-4ce2-82a8-1941f3a60665",
"event_name": "whatsapp.waba.message.sent",
"channel_uuid": "WAN95841312-b54d-46e3-b0bc-6414f4a5296b",
"hook_url": "https://www.toptal.com/developers/postbin/1681755466939-3421728690154",
"hook_params": {
"waweb_uuid": "WAN95841312-b54d-46e3-b0bc-6414f4a5296b"
},
"created_at": "2023-04-18T01:58:02Z"
}
}
FieldDescriptionExample values
uuidThe unique identifier of the webhook that you will need to make changes to itWHK530c9d58-2259-4ce2-82a8-1941f3a60665
event_nameThe name of the event this webhook is subscribed towhatsapp.waba.message.sent
channel_uuidThe unique UUID of the WABA channel this webhook is subscribed toWAN95841312-b54d-46e3-b0bc-6414f4a5296b
hook_urlThe URL 2Chat will call when the event is triggeredhttps://www.toptal.com/develop...
hook_paramsCustom parameters 2Chat sets to make the webhook functional{"waweb_uuid": "WAN95841312-b54d-46e3-b0bc-6414f4a5296b"}
created_atUTC timestamp for when the webhook was created2023-04-18T01:58:02Z