Receive webhooks
Send Platica events to your system: new messages, open cases or approved templates. Register your receiver URL and choose the events it needs.
A webhook sends a JSON POST to your server when something happens in Platica. Every delivery is signed with HMAC-SHA256 so you can check it.
Before you start
You need your Platica API key in PLATIC_API_KEY and a webhook receiver with a public HTTPS URL. For local development, you can use a tunnel.
To configure it from the platform, see Send events by webhook.
Choose the events
List the events you can subscribe to. There are 29, in 9 categories: conversations, messages, comments, contacts (
clientsin the API), ads, WhatsApp Flows, cases, WhatsApp templates and AI providers. (List events)curl https://api.platic.ai/v1/webhooks/events \ -H "Authorization: Bearer $PLATIC_API_KEY"import { Platic } from "platic-sdk"; const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! }); const { events } = await platic.webhooks.events(); console.log(events);Which events can I receive on a webhook?
Tool:
list_webhook_events.All events include
id,event,workspaceId,timestamp,source,resourceType,resourceId,changesanddata. See Payloads for the content ofdatafor each event.Create the webhook
Give it a name, your URL, the events and a signing secret. In the same call Platica stores the credentials as secrets, checks that your URL answers and, if it does, turns the webhook on. (Create a webhook)
curl https://api.platic.ai/v1/webhooks \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "CRM", "url": "https://acme.com/webhooks/platica", "events": ["message.created", "case.created"], "secret": "'$PLATIC_WEBHOOK_SECRET'" }'const webhook = await platic.webhooks.create({ name: "CRM", url: "https://acme.com/webhooks/platica", events: ["message.created", "case.created"], secret: process.env.PLATIC_WEBHOOK_SECRET, }); console.log(webhook.status, webhook.nextStep);Create a webhook called CRM that sends message.created and case.created to https://acme.com/webhooks/platica, signed with the secret I stored for webhooks.
Tool:
create_webhook. To keep the signing secret out of the chat, store it yourself in Integrations → Functions → Secrets and ask it to bind it withbind_webhook_secret.Save the response's
idinWEBHOOK_IDand keep thesecreton your server. It accepts up to 255 characters and is stored as a workspace secret; reads don't return its value. Theurlmust be public HTTPS.You can include up to 10
headersin every delivery. Headers with credentials are also stored as secrets. If you change the URL to another domain, authorize those credentials again.If the URL doesn't pass the check, the webhook is saved anyway, inactive (
status: "draft"), and the response is still201: see the next step.Test it and reactivate it
If your server wasn't ready, fix it and verify again. Platica sends a
HEADrequest to your URL (it waits up to 15 seconds) and, if it passes, leaves the webhook active. It doesn't send any event. Don't create the webhook again. (Test a webhook)curl -X POST https://api.platic.ai/v1/webhooks/$WEBHOOK_ID/test \ -H "Authorization: Bearer $PLATIC_API_KEY"const checked = await platic.webhooks.test(webhook.id); console.log(checked.status, checked.nextStep);Test the CRM webhook and turn it on if it passes.
Tool:
test_webhook.A status below
500passes, also404or405, because many servers only acceptPOST. A5xxor no answer doesn't.
Handle deliveries
- Verify
X-Webhook-Signatureusing the secret and original body bytes before processing the event. See Delivery and signatures. - Store each event's
idand skip events already processed. You may receive the same event more than once. - Respond with
2xxpromptly, then do the slow work.
The SDK example includes a complete server.
Check it worked
Use Get the webhook to check that status is enabled and active is true. Trigger an event you subscribed to: for example, send a message with Talk to your agent. Find the event on your server and check lastDeliveryStatus in Platica.
A delivery fails if your server responds with 5xx, takes more than 15 seconds or cannot be reached. A 4xx response counts as delivered.
By default, the webhook pauses after 5 consecutive failures. Configure autoPause by count, { "mode": "failures", "failures": 5 } (5 to 1000), or time, { "mode": "time", "hours": 24 } (1 to 168). Owners and admins receive a notice. Fix the server and call Test a webhook to reactivate it.
Next steps
- Payloads: what
datacarries for every event. - Delivery and signatures: headers, retries and automatic pause.
- WhatsApp Flows: the only events where your server must answer with JSON.
- Webhooks: list, update and delete.