---
docId: doc_de75e59ae7d14e7ca8ec2272ca4bb3e3
title: Payloads
description: "Read webhook event structures and fields."
---

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

# Payloads

Receive these events at your endpoint and read their contents in `data`:

- `conversation.*`
- `message.*`
- `comment.*`
- `client.*`
- `referral.received` (Meta ads)
- `case.*`
- `template.status.updated` (WhatsApp templates)
- `model_provider.status.updated` (AI providers)

For `whatsapp.flows.*`, use [WhatsApp Flows](/api-reference/webhooks/whatsapp-flows): these events need your response to continue the flow. They share this envelope with `resourceType: "flow_response"`.

## Common envelope

All these events reach your endpoint via a JSON `POST` with this structure:

```json
{
  "id": "9f8c...",
  "event": "conversation.created",
  "workspaceId": "ws_456",
  "timestamp": "2026-05-06T19:00:00.000Z",
  "source": "system.conversation.created",
  "resourceType": "conversation",
  "resourceId": "conv_123",
  "changes": null,
  "data": {}
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string` | Unique event identifier |
| `event` | `string` | Name of the event that triggered the webhook |
| `workspaceId` | `string` | Workspace where the event happened |
| `timestamp` | `string` | ISO-8601 date of the event |
| `source` | `string` | Origin of the event — see [the `source` field](#the-source-field) |
| `resourceType` | `conversation \| message \| comment \| client \| case \| template \| flow_response` | Type of resource affected |
| `resourceId` | `string \| null` | Identifier of the affected resource |
| `changes` | `object \| null` | Detected changes. `null` for creation/deletion events |
| `data` | `object` | Normalized snapshot of the resource |

<Note type="tip">

If you only want to verify that the webhook is authentic, go to [Delivery and signatures](/api-reference/webhooks/signatures).

</Note>

## The `source` field

<Collapsible summary="Show the event origin">

Identifies the origin of the event. For conversation, message, comment, and customer events, its value follows the format:

```text
<origin>.<resource>.<action>[.<qualifier>]
```

- **origin**: one of `api`, `dashboard`, `inbound`, `agent`, `system`, `scheduler`, `campaign`.
- **resource**: `client`, `conversation`, `message`, `comment`, `audience`, `scheduled_event`, `webhook`, `moderation`, `supervisor`.
- **action**: verb / state (`created`, `updated`, `deleted`, `processed`, `dispatched`, etc.).
- **qualifier** (optional): `bulk`, `auto`, `campaign`.

For WhatsApp Flows, `source` is always `whatsapp.flows`. Cases use `<actor>.case.<action>`: see [Cases](#cases). For `template.status.updated` it is `inbound.template.status_updated`, `inbound.template.category_updated`, or `inbound.template.quality_updated`, depending on Meta's notice.

Use `source` for auditing or debugging. Identify what changed through `event`, `resourceType`, `resourceId`, and `changes`.

Read the channel platform from `data.conversation.platform` for conversation and message events, or `data.comment.platform` for comments. Do not infer it from `source`.

<Note type="note">

Except for `whatsapp.flows`, `source` does not depend on the provider or implementation details. It remains stable across implementation changes.

</Note>

Common examples by event:

| `event` | Possible `source` values |
|---------|------------------------------|
| `client.created` | `api.client.created`, `inbound.client.created`, `campaign.client.created` |
| `client.updated` | `api.client.updated`, `api.client.blocked`, `api.client.unblocked`, `api.client.strikes_reset`, `api.conversation.status_changed`, `dashboard.client.updated`, `dashboard.client.blocked`, `dashboard.client.unblocked`, `dashboard.client.strikes_reset`, `inbound.client.profile_updated`, `inbound.client.refreshed`, `inbound.client.identifiers_updated`, `agent.supervisor.applied`, `system.moderation.applied` |
| `client.tags.updated` | `api.client.tagged.bulk`, `api.audience.added`, `api.audience.removed`, `api.audience.cleared`, `dashboard.client.updated` |
| `client.customFields.updated` | `api.client.custom_fields_updated`, `inbound.client.custom_fields_updated`, `agent.client.confirmation_saved`, `dashboard.client.updated` |
| `conversation.created` | `system.conversation.created`, `dashboard.conversation.created`, `campaign.conversation.created`, `dashboard.comment.private_reply`, `api.comment.private_reply`, `agent.comment.private_reply` |
| `conversation.status.updated` | `api.conversation.updated`, `api.conversation.finished`, `api.conversation.marked_spam`, `api.conversation.archived`, `api.conversation.reactivated`, `dashboard.conversation.stopped`, `api.conversation.stopped`, `campaign.conversation.updated` |
| `conversation.expired` | `system.conversation.expired_by_inactivity`, `agent.conversation.expired`, `api.conversation.archived.auto`, `api.conversation.updated` |
| `conversation.operation.updated` | `api.case.opened`, `api.case.accepted`, `api.case.closed`, `dashboard.case.opened`, `dashboard.case.accepted`, `dashboard.case.closed`, `dashboard.conversation.assistance_accepted`, `dashboard.conversation.assistance_declined`, `system.conversation.assistance_auto_accepted`, `agent.case.closed`, `system.case.expired` |
| `conversation.owners.updated` | `api.conversation.operator_assigned`, `api.conversation.operators_set`, `dashboard.conversation.assistance_accepted`, `api.case.opened`, `api.case.accepted`, `api.case.assigned`, `api.case.note_created`, `dashboard.case.assigned`, `dashboard.case.note_created`, `agent.case.note_created` |
| `conversation.tags.updated` | `api.conversation.tagged`, `dashboard.conversation.assistance_requested` |
| `message.created` | `inbound.message.received`, `dashboard.comment.private_reply`, `api.comment.private_reply`, `agent.comment.private_reply`, `agent.message.generated`, `agent.message.processed`, `agent.message.dispatched`, `agent.message.service_sent`, `agent.message.summary_generated`, `campaign.message.received`, `dashboard.message.system_inserted`, `scheduler.scheduled_event.created` |
| `message.updated` | `inbound.message.delivery_updated`, `inbound.message.delivery_failed`, `inbound.message.delivery_updated.campaign`, `agent.message.processed`, `agent.message.status_updated`, `agent.message.dispatched`, `dashboard.message.resent`, `scheduler.scheduled_event.processing`, `scheduler.scheduled_event.sent`, `scheduler.scheduled_event.failed`, `api.scheduled_event.cancelled` |
| `comment.created` | `inbound.comment.received` |
| `comment.updated` | `inbound.comment.updated`, `dashboard.comment.updated`, `api.comment.updated` |
| `comment.deleted` | `inbound.comment.deleted`, `dashboard.comment.deleted`, `api.comment.deleted` |
| `whatsapp.flows.*` | `whatsapp.flows` |
| `case.*` | `agent.case.opened`, `user.case.accepted`, `api.case.closed`, `system.case.expired`… See [Cases](#cases) |
| `template.status.updated` | `inbound.template.status_updated`, `inbound.template.category_updated`, `inbound.template.quality_updated` |
| `model_provider.status.updated` | `system.model_provider.call`, `user.model_provider.verified` |

</Collapsible>

## Conversations

Events:

| Event | `changes` |
|--------|-----------|
| `conversation.created` | `null` |
| `conversation.status.updated` | `{ "status": { "before", "after" } }` |
| `conversation.operation.updated` | `{ "operation": { "before", "after" } }` |
| `conversation.owners.updated` | `{ "owners": { "added": [], "removed": [] } }` |
| `conversation.tags.updated` | `{ "tags": { "added": [], "removed": [] } }` |
| `conversation.expired` | `{ "isFinished": { "before", "after": true } }` |

For `conversation.*` events, `data` always has:

```json
{
  "client": {
    "id": "521234567890",
    "phoneNumber": "521234567890",
    "creationDate": "2026-05-06T19:00:00.000Z",
    "lastUpdate": "2026-05-06T19:00:00.000Z",
    "name": "John Smith",
    "firstname": "John",
    "email": null
  },
  "conversation": {
    "id": "conv_123",
    "conversationId": "521234567890",
    "canSendDirectMessage": true,
    "workspaceId": "ws_456",
    "channelId": "521555000111",
    "contactName": "John Smith",
    "phoneNumber": "521234567890",
    "topic": "",
    "platform": "whatsapp",
    "email": null,
    "owners": [],
    "tags": [],
    "creationDate": "2026-05-06T19:00:00.000Z",
    "lastUpdate": "2026-05-06T19:00:00.000Z",
    "status": "open",
    "operation": "automatic",
    "messageCount": 1,
    "messages": []
  }
}
```

<Collapsible summary="conversation fields">

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string \| null` | Unique, canonical conversation ID |
| `conversationId` | `string \| null` | Chat thread ID; it does not identify the client |
| `canSendDirectMessage` | `boolean` | Can only be `false` on WhatsApp, Instagram, and Messenger/Facebook; calculated from the latest user message. Always `true` for internal chats |
| `workspaceId` | `string \| null` | Owning workspace |
| `channelId` | `string \| null` | Channel where it happened |
| `contactName` | `string \| null` | Contact name |
| `phoneNumber` | `string \| null` | Contact phone number |
| `topic` | `string` | Conversation topic |
| `platform` | `string \| null` | Contact channel: `whatsapp`, `instagram`, `messenger`, `email`, `sms`, etc. |
| `email` | `object \| null` | On an email thread, `{ subject, mailbox, provider, contactEmail }`; `null` on other channels. See [the `email` block](/api-reference/conversations/v1/get#the-email-block) |
| `owners` | `string[]` | Assigned owners, identified by **email** |
| `tags` | `string[]` | Assigned tags |
| `creationDate` | `string \| null` | ISO-8601 date |
| `lastUpdate` | `string \| null` | ISO-8601 date |
| `status` | `string \| null` | Current state: `open`, `pending`, `finished`, `blocked`, `spam`, `expired` |
| `operation` | `string \| null` | Conversation mode: `automatic` (bot-handled) or `manual` (operator-handled) |
| `messageCount` | `number` | Number of messages |
| `messages` | `unknown[]` | Serialized messages. Only present in `conversation.*` events |

</Collapsible>

## Messages

Events:

| Event | `changes` |
|--------|-----------|
| `message.created` | `null` |
| `message.updated` | Per-field changes: `content`, `contentBlocks`, `contentType`, `direction`, `lastUpdate`, `role`, `status`, `files`, `images`, `owner` |
| `message.deleted` | `null` — declared in the catalog, but **not emitted yet**. Subscribing produces no events today. |

For `message.*` events, `data` contains `client`, `conversation`, and `message`. The conversation **does not include** `messages[]`; the affected message is in `data.message`.

```json
{
  "client": { "...": "WebhookClientSummary" },
  "conversation": { "...": "WebhookConversation without messages[]" },
  "message": {
    "id": "msg_789",
    "content": "Hi, I need help with my order",
    "contentBlocks": [
      { "type": "text", "text": "Hi, I need help with my order" }
    ],
    "contentType": "text",
    "creationDate": "2026-05-06T19:00:00.000Z",
    "direction": "incoming",
    "files": [],
    "images": [],
    "owner": null,
    "lastUpdate": "2026-05-06T19:00:00.000Z",
    "role": "user",
    "status": "delivered",
    "email": null
  }
}
```

<Collapsible summary="message fields">

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string \| null` | Message identifier |
| `content` | `string` | Plain-text version of the message |
| `contentBlocks` | `unknown[]` | Structured blocks |
| `contentType` | `string` | `text` by default |
| `creationDate` | `string \| null` | ISO-8601 date |
| `direction` | `incoming \| outgoing \| string \| null` | Always normalized to `incoming` or `outgoing`. Values like `received` or `sent` are translated before being emitted |
| `files` | `unknown[]` | Attached files |
| `images` | `unknown[]` | Attached images |
| `owner` | `{ "id": string } \| null` | Message author. `id` is the operator's **email** when applicable |
| `lastUpdate` | `string \| null` | ISO-8601 date |
| `role` | `string \| null` | `user`, `assistant`, `tool`, etc. |
| `status` | `string \| null` | Message status. Common values: `received`, `sent`, `delivered`, `read`, `failed` |
| `email` | `object \| null` | On email, the block with subject, sender, recipients, text, HTML and attachments; `null` on other channels. See [the `email` block](/api-reference/conversations/v1/get#the-email-block) |


</Collapsible>

Example of `message.created` for an incoming email. On email, `content` is the plain text:

```json
{
  "client": { "...": "WebhookClientSummary" },
  "conversation": {
    "id": "Hk3pQ9wLx2QmZ7bN1cVd",
    "channelId": "em-sales@example.com",
    "platform": "email",
    "email": {
      "subject": "Your quote",
      "mailbox": "sales@example.com",
      "provider": "gmail",
      "contactEmail": "ana@example.com"
    }
  },
  "message": {
    "id": "msg_790",
    "content": "Thanks, can you send it as a PDF?",
    "direction": "incoming",
    "role": "user",
    "email": {
      "subject": "Re: Your quote",
      "from": { "address": "ana@example.com", "name": "Ana Lopez" },
      "to": ["sales@example.com"],
      "cc": [],
      "messageId": "<CAF1x2@mail.gmail.com>",
      "inReplyTo": "<a9b8c7@example.com>",
      "threadId": "18c4f2a9e1b",
      "text": "Thanks, can you send it as a PDF?",
      "html": "<p>Thanks, can you send it as a PDF?</p>",
      "attachments": []
    }
  }
}
```

Example of `message.updated`:

```json
{
  "event": "message.updated",
  "resourceType": "message",
  "resourceId": "msg_789",
  "changes": {
    "status": {
      "before": "sent",
      "after": "read"
    }
  },
  "data": {
    "client": {},
    "conversation": {},
    "message": {}
  }
}
```

## Comments

Events:

| Event | `changes` |
|--------|-----------|
| `comment.created` | `null` |
| `comment.updated` | Per-field changes with `{ "before", "after" }`: `content`, `contentType`, `attachments`, `isSpam`, `moderation` |
| `comment.deleted` | `null` |

For `comment.*`, `resourceType` is `comment`. `data` contains `client`, `post`, `thread`, and `comment`. `client` summarizes the contact linked to the author; it is `null` if there is none. Read the platform in `data.comment.platform`.

`data.post.id`, `data.thread.id`, and `data.comment.id` are the `postId`, `threadId`, and `commentId` of the [Posts API](/api-reference/posts), so you can reply to a comment straight from the webhook.

A private reply to a comment creates or reuses a direct-message conversation. That conversation notifies like any other: `conversation.created` when it is new and `message.created` for the message, with `source` `dashboard.comment.private_reply` (from the inbox), `api.comment.private_reply` (from the API), or `agent.comment.private_reply` (sent by the agent).

Example of `comment.created`:

```json
{
  "id": "evt_comment_demo_01",
  "event": "comment.created",
  "workspaceId": "ws_demo_456",
  "timestamp": "2026-08-31T15:42:18.000Z",
  "source": "inbound.comment.received",
  "resourceType": "comment",
  "resourceId": "comment_demo_01",
  "changes": null,
  "data": {
    "client": {
      "id": "client_demo_01",
      "phoneNumber": null,
      "creationDate": "2026-04-12T17:05:00.000Z",
      "lastUpdate": "2026-08-31T15:42:18.000Z",
      "name": "Ana Lopez",
      "firstname": "Ana",
      "email": null
    },
    "post": {
      "id": "post_demo_01",
      "externalId": "18000000000123456",
      "platform": "instagram",
      "channelId": "channel_demo_01",
      "title": "Which color do you prefer this summer?",
      "permalink": "https://www.instagram.com/p/DemoPost123/",
      "contactName": "Platica Demo"
    },
    "thread": {
      "id": "comment_demo_01",
      "status": "open",
      "needsReply": true,
      "commentCount": 1,
      "topic": "Instagram comments",
      "tags": []
    },
    "comment": {
      "id": "comment_demo_01",
      "postId": "18000000000123456",
      "parentCommentId": null,
      "rootCommentId": "comment_demo_01",
      "permalink": "https://www.instagram.com/p/DemoPost123/c/DemoComment456/",
      "platform": "instagram",
      "channelId": "channel_demo_01",
      "content": "I love the blue one 💙",
      "contentType": "text",
      "attachments": [],
      "creationDate": "2026-08-31T15:42:18.000Z",
      "lastUpdate": "2026-08-31T15:42:18.000Z",
      "direction": "incoming",
      "role": "user",
      "clientId": "client_demo_01",
      "authorName": "Ana Lopez",
      "authorPhotoUrl": "https://cdn.example.com/profiles/ana-demo.jpg",
      "authorType": null,
      "isSpam": false,
      "moderation": {
        "action": "none",
        "synced": false,
        "moderatedAt": null
      }
    }
  }
}
```

<Collapsible summary="comment fields">

`post` summarizes the related post:

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string \| null` | Post identifier |
| `externalId` | `string \| null` | Content identifier on the platform |
| `platform` | `string \| null` | `instagram`, `facebook`, or another supported platform |
| `channelId` | `string \| null` | Connected channel |
| `title` | `string \| null` | Post text or title |
| `permalink` | `string \| null` | Public URL of the post |
| `contactName` | `string \| null` | Display name for the channel account |

`thread` summarizes the comment thread:

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string \| null` | Thread identifier; matches `comment.rootCommentId` |
| `status` | `string \| null` | Current thread status |
| `needsReply` | `boolean` | Whether the thread needs a reply |
| `commentCount` | `number` | Number of comments in the thread |
| `topic` | `string \| null` | Thread topic |
| `tags` | `string[]` | Thread tags |

`comment` contains the affected comment:

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string \| null` | Comment identifier |
| `postId` | `string \| null` | External post identifier; matches `post.externalId` |
| `parentCommentId` | `string \| null` | Parent comment when this is a reply |
| `rootCommentId` | `string \| null` | Root comment in the thread |
| `permalink` | `string \| null` | Public URL of the comment |
| `platform` | `string \| null` | Comment platform |
| `channelId` | `string \| null` | Connected channel |
| `content` | `string` | Comment text |
| `contentType` | `string` | Content type, usually `text` |
| `attachments` | `object[]` | Public comment attachments |
| `creationDate` | `string \| null` | ISO-8601 creation date |
| `lastUpdate` | `string \| null` | ISO-8601 last update date |
| `direction` | `incoming \| outgoing \| null` | `incoming` for customers and `outgoing` for the brand |
| `role` | `string \| null` | Normalized author role |
| `clientId` | `string \| null` | Associated customer, when available |
| `authorName` | `string \| null` | Author display name |
| `authorPhotoUrl` | `string \| null` | URL of the author's public photo |
| `authorType` | `string \| null` | Author type |
| `isSpam` | `boolean` | Whether the comment is marked as spam |
| `moderation` | `{ "action": "none" \| "hidden" \| "deleted", "synced": boolean, "moderatedAt": string \| null }` | Moderation state |

Each `attachments` item can include:

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string \| null` | Attachment identifier |
| `type` | `string` | `image`, `video`, `link`, or `unsupported` |
| `status` | `string` | Attachment availability status |
| `url` | `string \| null` | URL available to the integration |
| `mime` | `string \| null` | MIME type, when available |
| `title` | `string \| null` | Attachment title |
| `bytes` | `number \| null` | Size in bytes, when available |

</Collapsible>

In `comment.updated`, each changed field includes its previous and new values. `data` keeps the same shape and contains the snapshot after the change. For example, the `changes` fragment for a moderation update can be:

```json
{
  "moderation": {
    "before": {
      "action": "none",
      "synced": false,
      "moderatedAt": null
    },
    "after": {
      "action": "hidden",
      "synced": true,
      "moderatedAt": "2026-08-31T15:48:02.000Z"
    }
  }
}
```

## Customers

Events:

| Event | `changes` |
|--------|-----------|
| `client.created` | `null` |
| `client.updated` | Per basic-field changes: `phoneNumber`, `name`, `firstname`, `lastname`, `email`, `birthdate`, `gender`, `company`, `country`, `state`, `city`, `address`, `postalCode`, `status`, `moderation`, `creationDate`, `lastUpdate`, `deleted` |
| `client.owners.updated` | `{ "owners": { "added": [], "removed": [] } }` |
| `client.tags.updated` | `{ "tags": { "added": [], "removed": [] } }` |
| `client.customFields.updated` | `{ "customFields": { "<field>": { "before", "after" } } }` or `{ "customFields": { "<field>": { "added": [], "removed": [] } } }` |

For `client.*` events, `data` is the normalized customer directly:

```json
{
  "id": "521234567890",
  "workspaceId": "ws_456",
  "phoneNumber": "521234567890",
  "name": "John Smith",
  "firstname": "John",
  "lastname": "Smith",
  "email": "john@acme.com",
  "birthdate": null,
  "gender": null,
  "company": "Acme Inc.",
  "country": "MX",
  "state": null,
  "city": null,
  "address": null,
  "postalCode": null,
  "status": "active",
  "moderation": {
    "totalStrikes": 0,
    "lastAction": null,
    "lastSource": null,
    "lastSeverity": null,
    "lastFlaggedAt": null,
    "lastCategories": [],
    "lastMatchedTerms": [],
    "blockedAt": null,
    "blockedBy": null,
    "blockedReason": null
  },
  "tags": ["vip"],
  "owners": ["agent1@acme.com"],
  "customFields": {
    "placas": "ABC123"
  },
  "creationDate": "2026-05-06T19:00:00.000Z",
  "lastUpdate": "2026-05-06T19:00:00.000Z",
  "deleted": false
}
```

<Note type="note">

In `customFields`, list-type fields are truncated to the **last 5 items** inside `data`. In `client.customFields.updated`, the `changes` object is computed from the full values, with no truncation.

</Note>

### Blocking and moderation

`status` and `moderation` always travel inside `data`, and `moderation` is returned in full even when the customer has no incidents. Its fields are documented in [Get a Customer](/api-reference/contacts/get#the-moderation-object).

When you block or unblock a customer you get a `client.updated` carrying `changes.status`, **plus** one `conversation.status.updated` per open conversation that was synced. If you only care about the block itself, filter by the event's `source` rather than by how many events arrived.

| Action | `source` on the `client.updated` |
|--------|----------------------------------|
| Block via the API | `api.client.blocked` |
| Unblock via the API | `api.client.unblocked` |
| Strike reset via the API | `api.client.strikes_reset` |
| Block / unblock from the dashboard | `dashboard.client.blocked`, `dashboard.client.unblocked` |
| Strike reset from the dashboard | `dashboard.client.strikes_reset` |
| Automatic block by moderation | `system.moderation.applied` |
| Conversation marked as spam | `api.conversation.status_changed` |

Example of `client.customFields.updated`:

```json
{
  "event": "client.customFields.updated",
  "resourceType": "client",
  "resourceId": "521234567890",
  "changes": {
    "customFields": {
      "placas": {
        "before": "ABC123",
        "after": "XYZ789"
      },
      "visitas": {
        "added": [
          {
            "id": "visit_5",
            "creationDate": "2026-05-06T19:00:00.000Z",
            "lastUpdate": "2026-05-06T19:00:00.000Z",
            "content": "Visita de seguimiento"
          }
        ],
        "removed": []
      }
    }
  },
  "data": {
    "id": "521234567890",
    "customFields": {
      "placas": "XYZ789",
      "visitas": []
    }
  }
}
```

## Meta Ads

Event:

| Event | `changes` | `resourceType` |
|--------|-----------|----------------|
| `referral.received` | `null` | `client` |

Sent when an inbound message comes from a Meta ad: Click-to-WhatsApp, Click-to-Messenger, or Instagram ads. `data` contains `client`, `conversation`, and `referral` with the ad attribution.

```json
{
  "event": "referral.received",
  "resourceType": "client",
  "resourceId": "client_sample_abc123",
  "changes": null,
  "data": {
    "client": {
      "id": "521234567890",
      "phoneNumber": "521234567890",
      "creationDate": "2026-05-06T19:00:00.000Z",
      "lastUpdate": "2026-05-06T19:00:00.000Z",
      "name": "John Smith",
      "firstname": "John",
      "email": null
    },
    "conversation": {
      "id": "conv_123",
      "conversationId": "521234567890",
      "platform": "whatsapp",
      "channelId": "wb-123456789012345"
    },
    "referral": {
      "platform": "whatsapp",
      "source": "ad",
      "ad_id": "120211234567890123",
      "ctwa_clid": "ARAkLkA8rmlFeiCktEJQ-QTwRiyYHAFDLMNDBH0CD3qpjd0HR4irJ6LEkR7JwLzMDopn7vghDWqTXUYWmTzID29SrqLOgUSDRAsNH0_sample",
      "ref": null,
      "headline": "Anuncio de prueba",
      "body": "Texto principal del anuncio de prueba.",
      "media_type": "image",
      "image_url": "https://example.com/ad-image.jpg",
      "video_url": null,
      "thumbnail_url": null,
      "welcome_message": "Hi, I want more information",
      "user_text": "Hi, I want more information",
      "channelId": "wb-123456789012345",
      "messageId": "wamid.sample",
      "conversationId": "521234567890",
      "receivedAt": "2026-05-06T19:00:00.000Z"
    }
  }
}
```

<Collapsible summary="referral fields">

| Field | Type | Description |
|-------|------|-------------|
| `platform` | `string` | Channel platform: `whatsapp`, `messenger`, `instagram` |
| `source` | `string \| null` | Source type reported by Meta, usually `ad` |
| `ad_id` | `string \| null` | Meta ad identifier |
| `ctwa_clid` | `string \| null` | Click-to-WhatsApp click ID, useful for the Conversions API |
| `ref` | `string \| null` | Ad `ref` parameter (Click-to-Messenger / `m.me`) when present |
| `headline` | `string \| null` | Ad headline |
| `body` | `string \| null` | Ad primary text |
| `media_type` | `string \| null` | Ad media type: `image`, `video`, etc. |
| `image_url` | `string \| null` | Ad image URL |
| `video_url` | `string \| null` | Ad video URL |
| `thumbnail_url` | `string \| null` | Ad thumbnail URL |
| `welcome_message` | `string \| null` | Welcome message prefilled in the ad |
| `user_text` | `string \| null` | Text the customer sent when starting the conversation |
| `channelId` | `string \| null` | Channel where the message arrived |
| `messageId` | `string \| null` | Identifier of the inbound message that triggered the event |
| `conversationId` | `string \| null` | Conversation identifier |
| `receivedAt` | `string \| null` | ISO-8601 date when the attributed message was received |

</Collapsible>

<Note type="note">

`referral.received` is only emitted on channels connected directly with Meta (Click-to-WhatsApp, Click-to-Messenger, and Instagram ads). Ad fields that Meta does not send arrive as `null`.

</Note>

## Cases

They arrive when a [case](/api-reference/cases) changes, whether the agent, a person, the API, or Platica (when it expires) changed it. `resourceType` is `case` and `resourceId` is the case id.

| Event | When | `changes` |
|-------|------|-----------|
| `case.created` | A case was opened | `null` |
| `case.updated` | The priority, fields, or summary changed | `{ "priority"?, "fields"?, "summary"? }`, each `{ "before", "after" }`. In `fields`, only the fields that changed; `null` means it had no value or was removed |
| `case.assigned` | The assignees changed, or someone took it | `{ "assigneeIds": { "added": [], "removed": [] }, "acceptedBy"?: { "before", "after" } }`. `acceptedBy` only comes when someone took it |
| `case.note.created` | A note was added | `null` |
| `case.closed` | It was closed, by hand or when it expired | `{ "status": { "before": "open", "after": "closed" }, "closeReason": { "before": null, "after": "<reason>" } }` |

`source` follows the format `<actor>.case.<action>`. The actor is `agent`, `user`, `api`, or `system`, and the action is `opened`, `updated`, `assigned`, `accepted`, `note_created`, `closed`, or `expired`. For example: `agent.case.opened`, `user.case.accepted`, `system.case.expired`.

Read the updated case in `data.case` and the event that caused the change in `data.event`, with the fields from the [log](/api-reference/cases/get#the-event-log). The case includes `revision` and `idempotencyKey`, the internal id of its opening. For `case.closed`, `data.conversation` contains [the conversation state](/api-reference/cases#the-conversation-object). Example of `case.assigned` when someone takes it:

```json
{
  "id": "3b9f0c2a7e4d1f6a8c5b2e9d0a7f4c1b6e3d8a5f2c9b6e3d0a7f4c1b8e5d2a9f",
  "event": "case.assigned",
  "workspaceId": "Wk5rT8yUi2OpAs4d",
  "timestamp": "2026-11-12T15:12:00.000Z",
  "source": "user.case.accepted",
  "resourceType": "case",
  "resourceId": "Es4kP9wLx2QmZ7bN1cVd",
  "changes": {
    "assigneeIds": { "added": ["Us2qW4eR6tY8uI0o"], "removed": [] },
    "acceptedBy": { "before": null, "after": "Us2qW4eR6tY8uI0o" }
  },
  "data": {
    "case": {
      "id": "Es4kP9wLx2QmZ7bN1cVd",
      "workspaceId": "Wk5rT8yUi2OpAs4d",
      "number": 143,
      "folio": "FAC-0143",
      "escalationId": "Et7hQ2mVx9LpRk3s",
      "escalationSnapshot": {
        "name": "Invoice with an error",
        "prefix": "FAC",
        "color": "#2563EB",
        "keepReplying": false,
        "canClose": false,
        "waitMessage": null,
        "inactivityCloseHours": null,
        "allowManual": true
      },
      "status": "open",
      "priority": "normal",
      "summary": "Asks to correct the tax ID on the invoice for order 48213.",
      "fields": { "numero_pedido": "48213", "rfc": "EJE010101AB1" },
      "contactId": "Ct3fG5hJ7kL9mN1p",
      "conversationId": "Cv8hN2lP4qR6sT0u",
      "channelId": "Ch2wE4rT6yU8iO0p",
      "platform": "whatsapp",
      "relatedConversationIds": [],
      "postId": null,
      "threadId": null,
      "agentId": "Ag6bV8nM1qW3eR5t",
      "openedBy": { "kind": "agent", "id": "Ag6bV8nM1qW3eR5t" },
      "assigneeIds": ["Us9fG3hJ6kL2mN8b", "Us2qW4eR6tY8uI0o"],
      "acceptedBy": "Us2qW4eR6tY8uI0o",
      "acceptedAt": "2026-11-12T15:12:00.000Z",
      "lastActivityAt": "2026-11-12T15:12:00.000Z",
      "maxOpenAt": "2026-11-26T15:04:00.000Z",
      "autoCloseAt": null,
      "closedAt": null,
      "closedBy": null,
      "closeReason": null,
      "closeNote": null,
      "idempotencyKey": "9f1c7a52-3d0e-4b8a-a6f4-2c5e8d1b7a90",
      "revision": 2,
      "createdAt": "2026-11-12T15:04:00.000Z",
      "updatedAt": "2026-11-12T15:12:00.000Z"
    },
    "event": {
      "id": "000002-0",
      "caseId": "Es4kP9wLx2QmZ7bN1cVd",
      "revision": 2,
      "actor": { "kind": "user", "id": "Us2qW4eR6tY8uI0o" },
      "at": "2026-11-12T15:12:00.000Z",
      "kind": "accepted",
      "data": { "userId": "Us2qW4eR6tY8uI0o", "previousUserId": null, "notifyCustomer": false }
    }
  }
}
```

Differences from the API's case:

- People come by id only: no `assigneeEmails` or `acceptedByEmail`.
- The case and the event carry `revision`, which goes up with every change. Use it to discard an event older than the last one you processed.
- The envelope `id` comes from the case, its `revision`, and the event: a retry arrives with the same `id`.

<Note type="note">

Opening a case of an escalation that has `keepReplying: true` does not change `operation`, so `conversation.operation.updated` does not arrive. To learn about every case, listen to `case.created`.

</Note>

When a case changes the conversation (pauses it, hands it back to the agent or adds people to it), `conversation.operation.updated` and `conversation.owners.updated` arrive too, whoever moved it. A note with `viaConversationId` also adds the case's assignees to that other conversation, so its `conversation.owners.updated` arrives. `source` says who it was:

| Who | `source` |
|-----|----------|
| The API | `api.case.opened`, `api.case.accepted`, `api.case.closed`, `api.case.assigned`, `api.case.note_created` |
| A person in Platica | `dashboard.case.opened`, `dashboard.case.accepted`, `dashboard.case.closed`, `dashboard.case.assigned`, `dashboard.case.note_created` |
| The agent | `system.conversation.assistance_auto_accepted` when it opens it, `agent.case.closed` when it closes it, `agent.case.note_created` when it adds a note from another conversation |
| Platica, when it expires | `system.case.expired` |

<Note type="note">

On comments the change belongs to the post, not the thread: `resourceId` is the post's id.

</Note>

## WhatsApp templates

| Event | `changes` | `resourceType` |
|-------|-----------|----------------|
| `template.status.updated` | `{ "status"?, "category"?, "quality"? }`, each `{ "before", "after" }` | `template` |

Receive status, category, or quality changes for a [WhatsApp template](/api-reference/whatsapp-templates/list). Meta may approve, reject, pause, or disable it. `resourceId` is its id in Meta. Use the event to follow the review without polling the template.

```json
{
  "id": "6f1d0b3c9a8e7f2d4c5b1a0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c",
  "event": "template.status.updated",
  "workspaceId": "ws1",
  "timestamp": "2026-11-13T16:00:00.000Z",
  "source": "inbound.template.status_updated",
  "resourceType": "template",
  "resourceId": "1234567890123456",
  "changes": {
    "status": { "before": "PENDING", "after": "APPROVED" }
  },
  "data": {
    "template": {
      "id": "1234567890123456",
      "name": "confirmacion_pedido",
      "language": "es_MX",
      "category": "UTILITY",
      "status": "APPROVED",
      "previousStatus": "PENDING",
      "quality": null,
      "rejectedReason": null,
      "rejectionInfo": null,
      "wabaId": "102938475610293"
    }
  }
}
```

| Field of `data.template` | Type | Description |
|--------------------------|------|-------------|
| `id` | `string` | Template id in Meta |
| `name`, `language` | `string \| null` | The name and the language version that changed |
| `category` | `string \| null` | `MARKETING`, `UTILITY`, or `AUTHENTICATION` |
| `status` | `string \| null` | The new status: `APPROVED`, `REJECTED`, `PAUSED`, `DISABLED`… |
| `previousStatus` | `string \| null` | The status Platica had stored |
| `quality` | `string \| null` | The quality Meta reports (`GREEN`, `YELLOW`, `RED`), if it reports one |
| `rejectedReason` | `string \| null` | Only with `REJECTED`: the reason code Meta gives |
| `rejectionInfo` | `object \| null` | Only with `REJECTED`, if Meta sends it: `{ "reason", "recommendation" }` |
| `wabaId` | `string \| null` | The template's WhatsApp account |

How it behaves:

- It only arrives if the status, category, or quality changed. `changes` carries only what changed.
- `before: null` means Platica did not have the template stored.
- If several workspaces share the WhatsApp account, each one gets its own delivery.
- If Meta repeats the same notice, the envelope `id` is the same: use it to avoid processing it twice.

<Note type="tip">

If you created the template with [create template](/api-reference/whatsapp-templates/create), subscribe to `template.status.updated` and send it when `data.template.status` is `APPROVED`.

</Note>

## AI providers

| Event | `changes` | `resourceType` |
|-------|-----------|----------------|
| `model_provider.status.updated` | `{ "health": { "before", "after" } }` | `model_provider` |

Sent when the workspace's [own key](/api-reference/ai-providers) for an AI provider stops working or works again. `resourceId` is the provider: `openai`, `google`, `anthropic`, or `xai`. It never carries the key.

```json
{
  "id": "3b9e1f0c7d2a4e6b8c0d1f3a5b7c9e1d2f4a6b8c0e2d4f6a8b0c2e4f6a8b0c2e",
  "event": "model_provider.status.updated",
  "workspaceId": "ws1",
  "timestamp": "2026-11-18T18:00:00.000Z",
  "source": "system.model_provider.call",
  "resourceType": "model_provider",
  "resourceId": "openai",
  "changes": {
    "health": { "before": "ok", "after": "no_credit" }
  },
  "data": {
    "modelProvider": {
      "provider": "openai",
      "name": "OpenAI",
      "status": "connected",
      "health": "no_credit",
      "previousHealth": "ok",
      "errorCode": "NO_CREDIT",
      "fallback": "platform",
      "impact": "platform_fallback",
      "models": [
        { "id": "gpt-6.1-sol", "status": "available", "ownKeyOnly": false },
        { "id": "gpt-6-luna", "status": "unverified", "ownKeyOnly": false }
      ]
    }
  }
}
```

| `data.modelProvider` field | Type | Description |
|----------------------------|------|-------------|
| `provider`, `name` | `string` | The provider and its name |
| `health` | `string` | How the key is doing now (table below) |
| `previousHealth` | `string` | How it was before the change |
| `status` | `string` | The provider status, as in [list providers](/api-reference/ai-providers/list): `connected` or `invalid` |
| `errorCode` | `string \| null` | What the provider answered, as a code (`AUTH_INVALID`, `NO_CREDIT`, `AUTH_OR_PERMISSION`…). `null` when it works again |
| `fallback` | `string` | `platform` or `none` |
| `impact` | `string` | What your agents do now with that provider's models: `none` (they use your key), `platform_fallback` (they answer with Platica's account, which charges AI), or `not_responding` (they don't answer) |
| `models` | `array` | Each model of the provider with `status` (`available`, `unavailable`, or `unverified`) and `ownKeyOnly`. With `platform_fallback`, models with `ownKeyOnly: true` don't answer either |

| `health` | What happened | What to do |
|----------|---------------|------------|
| `ok` | The key works | Nothing |
| `key_rejected` | The provider rejected the key twice in a row: it is invalid or was revoked | Connect a new key |
| `no_credit` | The provider account has no balance | Top up with the provider. The key stays `connected`: Platica tries it again every 10 minutes and, when it answers, another event arrives with `health: "ok"` |
| `no_model_access` | The key can no longer use any of the provider's models | Check its permissions and [verify it](/api-reference/ai-providers/test-key) again |

`source` is `system.model_provider.call` when the change showed up while an agent was answering, and `user.model_provider.verified` when someone verified the key, in Platica or through the API.

How it behaves:

- It only arrives when `health` changes. A key that remains out of credit does not send another event.
- When the key stops working, the workspace owners and admins also get an email. When it works again, a notice stays in Platica.
- A temporary rate limit (`QUOTA_OR_RATE_LIMIT`) does not change `health`.
- The first verification of a newly connected key only sends the event if it fails.

<Note type="tip">

If your agents have no fallback (`fallback: "none"`), subscribe to this event: with `impact: "not_responding"`, your agents don't answer with those models until you fix the key.

</Note>
