Skip to main content
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.
This webhook will receive all incoming messages, including those created using the A1Base API. To prevent infinite loops, you may want to check the sender_number to avoid agents replying to themselves.

Webhook Payload

string
Unique identifier for the chat thread
string
Unique identifier for the specific message
string
Type of chat - can be “group”, “individual”, or “broadcast”
string
Phone number of the message sender with country code. e.g. “+61400123456”
string
Name of the message sender
string
deprecated
Your A1Base account identifier
string
Your A1Base account identifier
string
The A1Base phone number that received the message. e.g. “+61400999888”
string
When the message was handled on WhatsApp, in ISO 8601 format. e.g. “2024-12-20T00:48:15+00:00”
string
The messaging service used (e.g. “whatsapp”)
string
Type of the message. Can be one of: “text”, “rich_text”, “image”, “video”, “audio”, “reaction”, “group_invite”, “location”, “unsupported_message_type”
boolean
Whether the message was sent by an agent
object
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”
string
HMAC-SHA256 signature used to verify the authenticity of the webhook. Created using your API secret and the timestamp + request body.
string
Unix timestamp (in seconds) when the webhook was sent. Used to verify the request and prevent replay attacks.

Response Codes

  • 200: Message received successfully
  • 403: Invalid secret key
  • 500: Internal server error
  1. Create an endpoint in your application to receive webhook events:
  1. Deploy your endpoint to a public URL (e.g. using ngrok for testing)
  2. Update your webhook URL on the A1Base dashboard at https://www.a1base.com/dashboard/phone-numbers
For a complete implementation example including message handling and AI responses, see our chat agent example:
  • 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-signature and x-timestamp header.
  • 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:
On your server, do the following to verify the signature:
  1. Read the raw JSON body of the request
  2. Get the x-timestamp header
  3. Recreate the message string as timestamp + rawBody
  4. Generate your own HMAC signature with your API secret
  5. Compare it with the x-signature using a constant-time comparison
Example in Express (Node.js)
Reject any webhook requests with a timestamp older than 5 minutes to prevent replay attacks.

Authorizations

X-API-Key
string
header
required
X-API-Secret
string
header
required

Body

application/json
thread_id
string
required

Unique identifier for the chat thread

message_id
string
required

Unique identifier for the specific message

thread_type
enum<string>
required

Type of chat

Available options:
group,
individual,
broadcast
content
string
required

The message content/text

sender_number
string
required

Phone number of the message sender

sender_name
string
required

Name of the message sender

a1_account_id
string
required

Your A1Base account identifier

timestamp
string
required

A timestamp in ISO 8601 format

service
enum<string>
required

The messaging service

Available options:
whatsapp,
telegram
message_type
enum<string>
required

Type of message content

Available options:
text,
image,
video,
audio,
document
is_from_agent
boolean
required

Whether the message is from an agent

message_content
object
required

Structured message content

Response

Message received successfully