In this section, we cover the webhook responses used by the WhatsApp Web API.
Your endpoint must accept POST requests to receive event notifications.
Remember: when creating the instance, you need to provide the URLs where you want to receive notifications.
Webhooks are used to inform you about the sending and receiving of messages, as well as the current status of your instance.
The instance is the WhatsApp Web page we manage for your account.
If you are integrating your application with the WhatsApp Web API, you need to set up endpoints to receive notifications about all interactions that occur on the connected WhatsApp.
You can configure the webhook for your instance by accessing your account:
When creating a new instance, you can add configurations to receive messages.
Access the admin panel, click on "Instances", view the desired instance, and edit the configurations.
Attention!
Never share your ID and token with third parties to ensure the security of your instance.
This API allows you to change the webhook URL for sending messages through a PUT request.
Base URL: https://apiwhatsappweb.com/api/config/sent
To authenticate the requests, you must include the API Key (apiKey) and the instance ID ID in the request header.
{
"apiKey": "Your API key here",
"id": "Your instance ID here"
}
The request body should be a JSON object with the following structure:
{
"URL": "https://Your_Website_here.com/api/config/sent"
// Send the URL where you want to receive notifications
}
The WhatsApp Web API does not accept webhooks that are not HTTPS.
The send webhook allows you to be notified as soon as a message is successfully sent.
{
"message": "Text sent successfully!",
"messageSent": "Message sent by you",
"number": "Contact number",
"messageId": "Message ID" // Allows you to check the message status later
}
Attention!
Never share your ID and token with third parties to ensure the security of your instance.
The WhatsApp Web API does not accept webhooks that are not HTTPS.
Return webhooks allow you to view the message received by the API.
{ messageId: 'Message ID', // Allows you to access the message status later, message: 'Message sent by another person', // Messages automatically expire in 30 days number: "Sent number", photo: 'Photo', // If it's not a photo, it will be null video: 'Video', // If it's not a video, it will be null, senderName: 'User name', // If not available, it will be 'Unknown' instanceName: 'Instance name registered on the platform', instanceId: "Instance ID registered on the platform", whatsappStatus: { message: "Received", description: 'Message sent by another person', title: 'Title' || null, url: 'URL sent by another person', // If not available, it will be null groupInvite: 'Group invitation' // If not available, it will be null } };
Attention!
Never share your ID and token with third parties to ensure the security of your instance.
The WhatsApp Web API does not accept webhooks that are not HTTPS.
This is the webhook response for the disconnection of the instance.
{ instanceName: "The name of the instance that disconnected", instanceId: "The ID of the instance that disconnected", status: 'Disconnected', whatsappStatus: { message: "Disconnected" } };
The WhatsApp Web API does not accept webhooks that are not HTTPS.
This is the webhook response for the instance connection.
{ instanceName: "The name of the instance that connected", instanceId: "The ID of the instance that connected", status: 'Connected', whatsappStatus: { message: "Connected" } };