Webhooks

Base URL: https://chatsa.co/api/v1

ChatSa sends an HTTPS POST to your endpoint for every event you subscribe to: inbound messages, delivery statuses, opt-outs, connection changes, leads and more. Every delivery is signed, kept and retried until your endpoint accepts it.

Three kinds of endpoint#

EndpointSet up withReceives
Dashboard endpointDashboard → Developers → Outbound webhooksThe events it subscribes to, for every chatbot and number of the workspace
Connect endpointPUT /connect/webhook with a Connect token or chatbot key (Connect)Only that one chatbot's events
Partner account endpointPUT /partner/webhook with an account key (partner API)The account's events that none of your Connect endpoints takes, such as SMS numbers without a chatbot and leads

For one partner app, an event goes to that chatbot's Connect endpoint when it has one that subscribes to the event, and to the account endpoint otherwise: never both. A Connect endpoint never receives an event that belongs to no chatbot (chatbot_id: null, below). A business's own dashboard endpoints are independent and get what they subscribe to.

Every endpoint has its own signing secret (whsec_…), shown once when it is made (or, for Connect and account endpoints, on every PUT). Endpoint URLs must be public http or https addresses (use https); private and loopback addresses are refused.

The request#

POST /webhooks/chatsa HTTP/1.1
Host: app.example.com
Content-Type: application/json
User-Agent: ChatSA-Webhooks/1
X-ChatSA-Event: message.received
X-ChatSA-Delivery: evt_5b0e2c7a-3f41-4a8e-9a57-6f0d9e1b2c3d
X-ChatSA-Timestamp: 1764512640
X-ChatSA-Signature-V1: 3f9a…
X-ChatSA-Signature: 81c2…

{
  "id": "evt_5b0e2c7a-3f41-4a8e-9a57-6f0d9e1b2c3d",
  "event": "message.received",
  "chatbot_id": "6f1c2a4e-0000-4000-8000-000000000001",
  "timestamp": "2026-11-30T14:24:00.000Z",
  "data": { "…": "…" }
}
HeaderMeaning
X-ChatSA-EventThe event name, as in the body
X-ChatSA-DeliveryThe event id, the same on every retry: de-duplicate on it
X-ChatSA-TimestampUnix seconds when this attempt was signed
X-ChatSA-Signature-V1Hex HMAC-SHA256 of `${timestamp}.${rawBody}` with your signing secret
X-ChatSA-SignatureLegacy: hex HMAC-SHA256 of the raw body alone. Prefer V1.

chatbot_id is null for events that belong to the account rather than one chatbot: lead.received, account.safety, campaign.replied and payment.succeeded, and SMS and call events of a number with no chatbot. A partner receives those on its account endpoint, never on a Connect endpoint.

Verifying the signature#

Verify the V1 signature over the raw body, before parsing it, and refuse a timestamp more than 5 minutes off:

import crypto from 'node:crypto';

export function verifyChatSa(rawBody, headers, secret) {
  const timestamp = headers['x-chatsa-timestamp'];
  const signature = headers['x-chatsa-signature-v1'] || '';
  if (!timestamp || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const expected = crypto.createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex');
  const a = Buffer.from(expected, 'hex');
  const b = Buffer.from(signature, 'hex');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Answering, retries and order#

  • Answer with any 2xx within 10 seconds. Do the work after answering (a queue or a background job).
  • Anything else, or no answer in time, is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours: seven attempts in all, over about 21 hours. After the last attempt the delivery is marked failed. Redirects are not followed: a 3xx counts as a failed attempt.
  • The same event may arrive more than once (a lost answer is retried). Keep the X-ChatSA-Delivery ids you have handled and skip repeats.
  • Order is not guaranteed. Use the times inside data (received_at, sent_at, at…) to order events.

For dashboard endpoints, Deliveries lists the last 50 deliveries with their status, attempts and your endpoint's last answer, with Send again. Send a test event sends a ping.

Subscribing#

Pick events by name, or with a wildcard: message.*, contact.*, sms.*, call.*, lead.*, social.*, or * for everything. history.imported and handoff.requested are not part of message.*: subscribe to them by name (or *), like the events with no wildcard of their own (connection.status, template.status, conversation.closed, conversation.rated, campaign.replied, payment.succeeded, account.safety). An unknown name is refused with a 400. ping is never subscribed to: it is sent to one endpoint when you test it or set it up.

Events#

WhatsApp messages#

EventWhendata
message.receivedA customer wrote, on a Team only number or an AI numbermessage_id, wa_message_id, conversation_id, from, profile_name, type, text, transcript (a voice note's words, also in text), button: { id, title }, media, location, form, reply_to_wa_message_id, received_at
message.sentA message went out: your API sends (source: "api"), replies typed in ChatSa's inbox (inbox), AI drafts a person approved (ai_approved), the holding message sent while a person reviews (review_hold), AI replies (ai), flow messages (flow), and messages typed in the WhatsApp Business app (app)message_id, wa_message_id, conversation_id, to, type, text, template, media, source, sender_name, reference, sent_at; your button and link sends add interactive; app messages add sender: "business_app" and location
message.statusWhatsApp reported sent, delivered, read or failed for a message ChatSa sentmessage_id, wa_message_id, to, status, error: { code, title }, pricing: { billable, category, type }, reference, at
handoff.requestedA customer's message matched a topic the business set to be answered by people only, and ChatSa handed the chat to a personphone, conversation_id, reason (the topic's name)
history.importedChat history from a WhatsApp Business app number arrived (one per chunk, and when done or declined)declined, done, meta_code, phase, chunk_order, progress, messages, threads: [{ phone, messages }], at

error on a failed message.status is WhatsApp's own code and title. The most common is 131049: WhatsApp held a marketing template because the person reached WhatsApp's per-person marketing limit (shared across all businesses); retrying at once won't help. Others: 131047 (the 24-hour window closed: send a template), 131026 (the number can't receive WhatsApp), 131042 (a payment problem on the WhatsApp account), 131050 (the person stopped your marketing messages).

Contacts and the connection#

EventWhendata
contact.opted_outA customer sent a stop wordphone, word, at
contact.opted_inA customer sent a start wordphone, word, at
connection.statusThe number's token expired, it was disconnected, restricted or reconnected, or its quality or messaging limit changedstatus (connected, token_expired, disconnected, restricted), quality_rating (always null: read the rating with GET /whatsapp/status), messaging_limit, at; changes WhatsApp reported add meta_event
template.statusWhatsApp approved, rejected, re-categorised or re-rated a templatekind (status, category, quality), template_id, name, language, status, reason, category, at; a category change adds previous_category, a quality change quality and previous_quality
account.safetyThe business's sending limits changed: its state (ok, watch, paused) or its daily cap (an account event: chatbot_id: null)state, previous_state, reasons: [{ code, level, message, chatbot_id }], since, set_by, daily_cap, sent_today, resets_at, on_ramp, at

Conversations, campaigns and payments#

EventWhendata
conversation.closedA conversation was closed in ChatSa's inboxconversation_id, chatbot_id, close_reason: { id, label } | null, closed_by
conversation.ratedA customer answered the satisfaction surveyconversation_id, chatbot_id, score (3 great, 2 OK, 1 poor), label, agent_user_id, close_reason
campaign.repliedA customer replied to a campaign message (an account event: chatbot_id: null)campaign_id, phone
payment.succeededA payment link sent in a conversation was paid (an account event: the chatbot is in data)payment_id, chatbot_id, conversation_id, amount, currency

Leads#

EventWhendata
lead.receivedSomeone submitted a Facebook or Instagram lead ad form on a connected Pageleadgen_id, created_at, backfill, page, form, ad, platform, is_organic, name, email, phone, company, city, job_title, fields, consent: see Facebook Pages and lead ads

lead.received belongs to the account (chatbot_id: null).

Messenger and Instagram#

EventWhendata
social.message.receivedA person wrote to a connected Facebook Page or Instagram accountmessage_id, channel, conversation_id, account, from, type, text, media, reply_to_message_id, reply_window_until, received_at: see Messenger and Instagram
social.message.sentThe business sent a message there, from the API, ChatSa's inbox or Facebook / Instagram itselfmessage_id, channel, conversation_id, account, to, type, text, media, source (api, inbox, app), sender_name, sent_at

SMS and calls#

EventWhendata
sms.receivedA text arrived on a connected numberid, from, to, body, media: [{ content_type, url }], twilio_sid, received_at
sms.statusA text's status moved forward (queued, sent, delivered, undelivered, failed; failed at once when Twilio refuses the send)id, status, error_code, twilio_sid, from, to, at
sms.opted_outA customer opted out (STOP, STOPALL, carrier error 21610, or your API)phone, number, source, keyword, at
sms.opted_inA customer opted back inphone, number, source, keyword, at
call.completedA call ended and its recording, voicemail or AI transcript is in (sent once per call)the Call object: see Calls
call.voicemailA voicemail recording is readyid, from, to, duration_sec, recording_url, recording_expires_at, at

Test#

EventWhendata
pingSend a test event in the dashboard, or about 3 seconds after you set up a Connect or account endpoint (to that endpoint only){ "message", "at" } (dashboard) or { "connection": "ok" } (Connect and account endpoints)

Sample: message.received#

{
  "id": "evt_5b0e2c7a-3f41-4a8e-9a57-6f0d9e1b2c3d",
  "event": "message.received",
  "chatbot_id": "6f1c2a4e-0000-4000-8000-000000000001",
  "timestamp": "2026-11-30T14:24:00.000Z",
  "data": {
    "message_id": "c2d8…",
    "wa_message_id": "wamid.HBgL…",
    "conversation_id": "0a9c…",
    "from": "14155550199",
    "profile_name": "Jordan",
    "type": "interactive",
    "text": "Yes, 3 pm works",
    "transcript": null,
    "button": { "id": "job-8812:yes", "title": "Yes, 3 pm works" },
    "media": null,
    "location": null,
    "form": null,
    "reply_to_wa_message_id": "wamid.HBgK…",
    "received_at": "2026-11-30T14:23:58.000Z"
  }
}

Payloads carry phone numbers and message text by design, so treat your webhook logs as personal data.