PrerequisitesMake sure that your webhook endpoint is listening for
whatsapp.smb.message.echoes
events. See also Configure Webhooks, Retrieve a webhook endpoint API.
Outbound Text message
In this case, your webhook endpoint received an outbound text message sent by a business customer to a WhatsApp user with the WhatsApp Business app or supported companion device.:
- Contains plain text sent before.
- Contains the mentioned message information in
context
.
Code sample
curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \
-H 'Content-Type: application/json' \
-d '{
"id": "evt_eEVCy8eNqD9EvcFI",
"type": "whatsapp.smb.message.echoes",
"apiVersion": "v2",
"createTime": "2023-02-22T12:00:00.000Z",
"whatsappMessage": {
"id": "63f5d602367ea403f8175a6c",
"wamid": "wamid.BgNODYxN...",
"status": "sent",
"from": "BUSINESS-PHONE-NUMBER",
"to": "CUSTOMER-PHONE-NUMBER",
"wabaId": "WABA-ID",
"createTime": "2022-03-01T12:00:00.000Z",
"sendTime": "2022-03-01T12:00:01.000Z",
"bizType": "whatsapp",
"type": "image",
"image": {
"link": "https://api.ycloud.com/v2/whatsapp/media/download/5926236...",
"id": "592623615738103",
"sha256": "LeRpQJq/h4HTjm...",
"mime_type": "image/jpeg"
}
}
}'
Outbound Image message
In this case, your webhook endpoint received an outbound image message sent by a business customer to a WhatsApp user with the WhatsApp Business app or supported companion device.:
- Contains image sent before.
Code sample
curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \
-H 'Content-Type: application/json' \
-d '{
"id": "evt_eEVCy8eNqD9EvcFI",
"type": "whatsapp.smb.message.echoes",
"apiVersion": "v2",
"createTime": "2023-02-22T12:00:00.000Z",
"whatsappMessage": {
"id": "63f5d602367ea403f8175a6c",
"wamid": "wamid.BgNODYxN...",
"status": "sent",
"from": "BUSINESS-PHONE-NUMBER",
"to": "CUSTOMER-PHONE-NUMBER",
"wabaId": "WABA-ID",
"createTime": "2022-03-01T12:00:00.000Z",
"sendTime": "2022-03-01T12:00:01.000Z",
"bizType": "whatsapp",
"type": "image",
"image": {
"link": "https://api.ycloud.com/v2/whatsapp/media/download/5926236...",
"id": "592623615738103",
"sha256": "LeRpQJq/h4HTjm...",
"mime_type": "image/jpeg"
}
}
}'
Note
- The
image.link
can be directly accessed in a few minutes for the convenience of the consumer, but you should always include anX-API-Key
header to download this file within 30 days.
Outbound Video message
In this case, your webhook endpoint received an outbound video message sent by a business customer to a WhatsApp user with the WhatsApp Business app or supported companion device.:
- Contains video sent before.
Code sample
curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \
-H 'Content-Type: application/json' \
-d '{
"id": "evt_eEVCy8eNqD9EvcFI",
"type": "whatsapp.smb.message.echoes",
"apiVersion": "v2",
"createTime": "2023-02-22T12:00:00.000Z",
"whatsappMessage": {
"id": "63f5d602367ea403f8175a6c",
"wamid": "wamid.BgNODYxN...",
"status": "sent",
"from": "BUSINESS-PHONE-NUMBER",
"to": "CUSTOMER-PHONE-NUMBER",
"wabaId": "WABA-ID",
"createTime": "2022-03-01T12:00:00.000Z",
"sendTime": "2022-03-01T12:00:01.000Z",
"bizType": "whatsapp",
"type": "video",
"video": {
"link": "https://api.ycloud.com/v2/whatsapp/media/download/5926236...",
"id": "592623615738103",
"sha256": "LeRpQJq/h4HTjm...",
"mime_type": "video/mp4"
}
}
}'
Note
- The
video.link
can be directly accessed in a few minutes for the convenience of the consumer, but you should always include anX-API-Key
header to download this file within 30 days.
Outbound Audio message
In this case, your webhook endpoint received an outbound audio message sent by a business customer to a WhatsApp user with the WhatsApp Business app or supported companion device.:
- Contains audio sent before.
Code sample
curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \
-H 'Content-Type: application/json' \
-d '{
"id": "evt_eEVCy8eNqD9EvcFI",
"type": "whatsapp.smb.message.echoes",
"apiVersion": "v2",
"createTime": "2023-02-22T12:00:00.000Z",
"whatsappMessage": {
"id": "63f5d602367ea403f8175a6c",
"wamid": "wamid.BgNODYxN...",
"status": "sent",
"from": "BUSINESS-PHONE-NUMBER",
"to": "CUSTOMER-PHONE-NUMBER",
"wabaId": "WABA-ID",
"createTime": "2022-03-01T12:00:00.000Z",
"sendTime": "2022-03-01T12:00:01.000Z",
"bizType": "whatsapp",
"type": "audio",
"audio": {
"link": "https://api.ycloud.com/v2/whatsapp/media/download/5926236...",
"id": "592623615738103",
"sha256": "LeRpQJq/h4HTjm...",
"mime_type": "audio/ogg; codecs=opus"
}
}
}'
Note
- The
audio.link
can be directly accessed in a few minutes for the convenience of the consumer, but you should always include anX-API-Key
header to download this file within 30 days.
Outbound Document message
In this case, your webhook endpoint received an outbound document message sent by a business customer to a WhatsApp user with the WhatsApp Business app or supported companion device.:
- Contains document sent before.
Code sample
curl 'https://YOUR-WEBHOOK-ENDPOINT-URL' \
-H 'Content-Type: application/json' \
-d '{
"id": "evt_eEVCy8eNqD9EvcFI",
"type": "whatsapp.smb.message.echoes",
"apiVersion": "v2",
"createTime": "2023-02-22T12:00:00.000Z",
"whatsappMessage": {
"id": "63f5d602367ea403f8175a6c",
"wamid": "wamid.BgNODYxN...",
"status": "sent",
"from": "BUSINESS-PHONE-NUMBER",
"to": "CUSTOMER-PHONE-NUMBER",
"wabaId": "WABA-ID",
"createTime": "2022-03-01T12:00:00.000Z",
"sendTime": "2022-03-01T12:00:01.000Z",
"bizType": "whatsapp",
"type": "document",
"document": {
"link": "https://api.ycloud.com/v2/whatsapp/media/download/5926236...",
"id": "592623615738103",
"caption": "图片",
"sha256": "LeRpQJq/h4HTjm...",
"mime_type": "image/jpeg"
}
}
}'
Note
- The
document.link
can be directly accessed in a few minutes for the convenience of the consumer, but you should always include anX-API-Key
header to download this file within 30 days.