---
docId: doc_a505fcb6939b421a8418a203e30123c5
title: Receive webhooks
description: "Receive Platica events on your server and verify each delivery's signature."
---

<script>
  import { Note, Steps, Ways, Collapsible } from '$lib/components';
</script>

# Receive webhooks

<span id="what-youll-build"></span>

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](/help/integrations/functions/webhooks).

<Steps>
<Steps.Step>

**Choose the events**

List the events you can subscribe to. There are 29, in 9 categories: conversations, messages, comments, contacts (`clients` in the API), ads, WhatsApp Flows, cases, WhatsApp templates and AI providers. ([List events](/api-reference/webhooks/events))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/webhooks/events \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
import { Platic } from "platic-sdk";

const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });

const { events } = await platic.webhooks.events();
console.log(events);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Which events can I receive on a webhook?

</Ways.Say>

Tool: [`list_webhook_events`](/mcp/tools#list_webhook_events).

</Ways.Way>
</Ways>

All events include `id`, `event`, `workspaceId`, `timestamp`, `source`, `resourceType`, `resourceId`, `changes` and `data`. See [Payloads](/api-reference/webhooks/payloads) for the content of `data` for each event.

</Steps.Step>

<Steps.Step>

**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](/api-reference/webhooks/create))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
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'"
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
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);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

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.

</Ways.Say>

Tool: [`create_webhook`](/mcp/tools#create_webhook). To keep the signing secret out of the chat, store it yourself in **Integrations → Functions → Secrets** and ask it to bind it with [`bind_webhook_secret`](/mcp/tools#bind_webhook_secret).

</Ways.Way>
</Ways>

Save the response's `id` in `WEBHOOK_ID` and keep the `secret` on your server. It accepts up to 255 characters and is stored as a workspace secret; reads don't return its value. The `url` must be public HTTPS.

You can include up to 10 `headers` in 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 still `201`: see the next step.

</Steps.Step>
<Steps.Step>

**Test it and reactivate it**

If your server wasn't ready, fix it and verify again. Platica sends a `HEAD` request 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](/api-reference/webhooks/test))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl -X POST https://api.platic.ai/v1/webhooks/$WEBHOOK_ID/test \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const checked = await platic.webhooks.test(webhook.id);
console.log(checked.status, checked.nextStep);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Test the CRM webhook and turn it on if it passes.

</Ways.Say>

Tool: [`test_webhook`](/mcp/tools#test_webhook).

</Ways.Way>
</Ways>

A status below `500` passes, also `404` or `405`, because many servers only accept `POST`. A `5xx` or no answer doesn't.

</Steps.Step>
</Steps>

## Handle deliveries

- Verify `X-Webhook-Signature` using the secret and original body bytes before processing the event. See [Delivery and signatures](/api-reference/webhooks/signatures).
- Store each event's `id` and skip events already processed. You may receive the same event more than once.
- Respond with `2xx` promptly, then do the slow work.

The [SDK example](/sdk/examples/webhook-server) includes a complete server.

## Check it worked

Use [Get the webhook](/api-reference/webhooks/get) 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](/guides/chat-api). 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.

<Collapsible summary="Automatic pause and reactivation">

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](/api-reference/webhooks/test) to reactivate it.

</Collapsible>

## Next steps

- [Payloads](/api-reference/webhooks/payloads): what `data` carries for every event.
- [Delivery and signatures](/api-reference/webhooks/signatures): headers, retries and automatic pause.
- [WhatsApp Flows](/api-reference/webhooks/whatsapp-flows): the only events where your server must answer with JSON.
- [Webhooks](/api-reference/webhooks): list, update and delete.
