Webhooks
Handle inbound webchat message
Inbound webhook called by the webchat socket server (on behalf of the embedded widget) when a visitor sends a message. Validates the configured webchatConfigId, upserts the visitor as a contact, and persists the message + any attachments. For a customer message the response is sent only once the message is stored or definitively refused: 2xx means the Message row exists, 4xx means it never will be stored. Two responses fall outside that guarantee: a page-context system emit (isSystemContext) is answered 2xx as "handled" and implies no row, and a replay that arrives while the first attempt for the same clientMessageId is still being stored is answered 503 ingest_in_progress before that attempt resolves. 5xx responses carry a retryable flag that callers must check before retrying (not_persisted is a 500 that is NOT retryable; ingest_in_progress is a 503 that is). Sends carrying a clientMessageId are idempotent per webchat session: a replay that finds the row already stored answers with it and duplicate: true.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/webhook/webchat" \ -H "Content-Type: application/json" \ -d '{ "webchatId": "wc_8f3d1b9c-2e7a-4f0b-9a4d-2c1e6e2f8c01", "webchatConfigId": "5f7b1c2e8a1d4e0012c3b4a5", "message": "Hi, do you ship to Canada?", "deviceId": "dev_4f9a-8c1b-2e3d-7a01", "visitorName": "Alex Morgan", "visitorEmail": "alex@example.com", "visitorPhone": "+14165550100", "metadata": { "page": "/pricing", "referrer": "https://google.com" } }'{ "ok": true, "messageId": "6ab29740f7ebee5395fbb598", "conversationId": "6ab297364fe62a69debc5ae7", "duplicate": false}