Receive WhatsApp Message
Webhook
Webhook
Webhook endpoint for receiving incoming WhatsApp messages from WhatsApp servers
POST
Receive WhatsApp Message
The webhook endpoint allows you to receive incoming WhatsApp messages in real-time. When a message is received, it will be sent to your configured webhook URL with the following payload structure.
Think of it as setting up an automatic forwarding system - whenever someone messages your AI agent on WhatsApp, we’ll immediately forward that message to your specified webhook URL, so your agent can process and respond to it right away.
Webhook Payload
Unique identifier for the chat thread
Unique identifier for the specific message
Type of chat - can be “group”, “individual”, or “broadcast”
Phone number of the message sender with country code. e.g. “+61400123456”
Name of the message sender
Your A1Base account identifier
Your A1Base account identifier
The A1Base phone number that received the message. e.g. “+61400999888”
When the message was handled on WhatsApp, in ISO 8601 format. e.g. “2024-12-20T00:48:15+00:00”
The messaging service used (e.g. “whatsapp”)
Type of the message. Can be one of: “text”, “rich_text”, “image”, “video”, “audio”, “reaction”, “group_invite”, “location”, “unsupported_message_type”
Whether the message was sent by an agent
The complete message content object containing all message data. Structure varies by message_type:For message_type: “text” (simple text)For message_type: “rich_text” (rich text with optional quote)For message_type: “image”For message_type: “video”For message_type: “audio”For message_type: “reaction”For message_type: “group_invite”For message_type: “location”For message_type: “unsupported_message_type”
HMAC-SHA256 signature used to verify the authenticity of the webhook. Created using your API secret and the timestamp + request body.
Unix timestamp (in seconds) when the webhook was sent. Used to verify the request and prevent replay attacks.
Response Codes
200: Message received successfully403: Invalid secret key500: Internal server error
Setting up your webhook
Setting up your webhook
- Create an endpoint in your application to receive webhook events:
- Deploy your endpoint to a public URL (e.g. using ngrok for testing)
- Update your webhook URL on the A1Base dashboard at https://www.a1base.com/dashboard/phone-numbers
Security best practices
Security best practices
- Validate the webhook payload structure matches the expected format
- Check the sender_number to avoid infinite loops with your own agent
- Use HTTPS endpoints only
- Keep your webhook URL private
- Implement rate limiting if needed
- Add error handling for failed message processing
-
All webhook requests from A1Base include an
x-signatureandx-timestampheader. - You can verify the authenticity of each request using your API secret and the HMAC-SHA256 algorithm.
-
Here’s how the signature is generated on our side:
- Read the raw JSON body of the request
- Get the x-timestamp header
- Recreate the message string as timestamp + rawBody
- Generate your own HMAC signature with your API secret
- Compare it with the x-signature using a constant-time comparison
Body
application/json
Unique identifier for the chat thread
Unique identifier for the specific message
Type of chat
Available options:
group, individual, broadcast The message content/text
Phone number of the message sender
Name of the message sender
Your A1Base account identifier
A timestamp in ISO 8601 format
The messaging service
Available options:
whatsapp, telegram Type of message content
Available options:
text, image, video, audio, document Whether the message is from an agent
Structured message content
Response
Message received successfully

