WhatsApp API
This page contains simple examples for WhatsApp API
This API has been developed in accordance with the OpenAPI specification defined here.
You can send a WhatsApp message to the following endpoints using the cURL utility
Curl
POST /messages is the endpoint to send (create) new whatsapp MT messages
curl -X POST \
--url https://api.modicagroup.com/rest/wab/v1/messages \
-H 'accept: application/json' \
-H 'authorization: Basic <token>' \
-H 'content-type: application/json' \
-D '{
"destination": "+64123456879",
"type": "text",
"text": {
"body": "Hello"
},
"source": "1234567890"
}'
202 response:
[
{
"id": "b95fc11e-37f0-4770-a082-6ea22d4c4d12",
"status": "accepted",
"reference": ""
}
]
400 response:
{
"error": "bad request error message",
"message": "Whatsapp Cloud API error",
"statusCode": 400
}
POST /messages/broadcast
curl \
-X POST 'https://api.modicagroup.com/rest/wab/v1/messages/broadcast' \
-H 'accept: application/json' \
-H 'authorization: Basic <token>' \
-H 'content-type: application/json' \
-D '{
"destination": [
"+64123456789",
"+64223456788"
],
"type": "text",
"text": {
"body": "Hello"
},
"source": "1234567890"
}'
202 response:
[
{
"destination": "+64123456789",
"id": "a6c566d8-59f8-4187-9906-c296ae41bf13",
"status": "accepted"
},
{
"destination": "+64223456788",
"id": "cd415c6d-2fe8-4cb0-b5d7-135674fcf5e5",
"status": "accepted"
}
]
POST \media
curl \
-X POST 'https://api.modicagroup.com/rest/wab/v1/media?source=string' \
-H 'accept: application/json' \
-H 'authorization: Basic <token>' \
-H 'x-xsrf-token: string' \
-F file=string
200 response:
[
{
"id": "string"
}
]
422 response:
{
"errors": [
{
"field": "",
"code": "",
"description": "Unprocessable Entity"
}
]
}
GET \messages
curl 'https://api.modicagroup.com/rest/wab/v1/messages?id=uuid' \
-H 'accept: application/json' \
-H 'authorization: Basic <token>'
200 response (MT):
{
"id":"53a3e147-0cc5-4001-874a-000000000000",
"source":"167141142137144145111111",
"destination":"+64123456789",
"direction":"MT",
"reference":"c15e301d-ab04-46a0-8a76-9bfb589a5df9",
"content":"{\"messaging_product\":\"whatsapp\",\"to\":\"+64123456789\",\"type\":\"template\",\"template\":{\"name\":\"sample_flight_confirmation\",\"language\":{\"policy\":\"\",\"code\":\"en_US\"},\"components\":[{\"type\":\"header\",\"parameters\":[{\"type\":\"document\",\"parameter_name\":\"\",\"text\":\"\",\"document\":{\"link\":\"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf\"}}]},{\"type\":\"body\",\"parameters\":[{\"type\":\"text\",\"parameter_name\":\"\",\"text\":\"Home\"},{\"type\":\"text\",\"parameter_name\":\"\",\"text\":\"Away\"},{\"type\":\"text\",\"parameter_name\":\"\",\"text\":\"December 23rd\"}]}]},\"biz_opaque_callback_data\":\"53a3e147-0cc5-4001-874a-000000000000\"}"
}
200 response (MO):
{
"id":"c1fc05e6-863e-43bf-86dc-000000000000",
"source":"+64123456789",
"destination":"167141142137144145111111",
"direction":"MO",
"reference":"",
"content":"{\"errors\":null,\"from\":\"+64123456789\",\"id\":\"wamid.e53f1ea5-bec5-4376-9470-b06a90e4b260\",\"order\":null,\"reaction\":null,\"text\":{\"preview_url\":false,\"body\":\"This is an automated reply from the mock API\"},\"timestamp\":\"1767739600\",\"type\":\"text\"}"
}
422 response:
{
"errors": [
{
"field": "",
"code": "",
"description": "Unprocessable Entity"
}
]
}