# message.delivered

Coming soon, not sent yet. The channel reported an outgoing message was delivered.

> **Coming soon.** Endpoints can subscribe to this event, but nothing is sent for it yet. Its payload may change before it is.

**Channels:** WhatsApp and Messenger.

## Headers

| Header | Description | Example |
| --- | --- | --- |
| `webhook-id` | The event's id, the same on every retry and redelivery. Dedupe on it. | `evt_01JE2Z3QK4T8M6N2R5S7V9W1X3` |
| `webhook-timestamp` | When this attempt was signed, in Unix seconds. | `1794475538` |
| `webhook-signature` | One or more signatures, separated by spaces: `v1,` and the base64 HMAC-SHA256 of `<webhook-id>.<webhook-timestamp>.<body>`. | `v1,<base64>` |
| `X-Chatwise-Event` | The event's name. | `message.delivered` |
| `X-Chatwise-Delivery` | The delivery's id. | `wd_3f1c0a9b5d7e42688c1f0e2d4b6a8c90` |
| `User-Agent` | Always `Chatwise-Webhooks/1.0`. | `Chatwise-Webhooks/1.0` |

## Payload

This payload isn't final, so don't build on it yet.

```json
{
  "id": "evt_01JE2Z3QK4T8M6N2R5S7V9W1X3",
  "type": "message.delivered",
  "timestamp": "2026-11-12T09:25:36.000Z",
  "apiVersion": "2026-12-01",
  "workspaceId": "42",
  "data": {
    "message": {
      "id": "5680",
      "conversationId": "1234",
      "channel": "WHATSAPP",
      "direction": "outbound",
      "type": "text",
      "text": "Yes, in two shades of blue.",
      "sentAt": "2026-11-12T09:31:02.000Z",
      "ingestedAt": "2026-11-12T09:31:02.350Z",
      "replyToMessageId": null,
      "attachments": []
    },
    "conversation": {
      "id": "1234",
      "channel": "WHATSAPP",
      "status": "open",
      "participant": {
        "name": "Jordan Example",
        "channelId": "12025550147",
        "phoneNumber": "12025550147",
        "instagramUsername": null
      },
      "createdAt": "2026-11-01T09:12:00.000Z",
      "lastMessageAt": "2026-11-12T09:25:36.000Z"
    },
    "account": {
      "id": "11",
      "channel": "WHATSAPP"
    }
  }
}
```

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The event's id, the same on every retry and redelivery. Also the `webhook-id` header. |
| `type` | string | The event's name. Also the `X-Chatwise-Event` header. Always `message.delivered`. |
| `timestamp` | string | When the event happened. The same on every retry. ISO 8601, in UTC. |
| `apiVersion` | string | The payload format, as a date. |
| `workspaceId` | string | The workspace the event happened in. |
| `data` | object | What happened. |
| `data.message` | object | The message, as the API returns it. |
| `data.message.id` | string | The message's id. |
| `data.message.conversationId` | string | The conversation the message is in. |
| `data.message.channel` | string | The channel the message is on. One of `WHATSAPP`, `INSTAGRAM`, `MESSENGER`, `WEBSITE_CHAT`. |
| `data.message.direction` | string | `inbound` from the customer, `outbound` from the workspace. |
| `data.message.type` | string | The message's type, such as `text`, `image`, `audio`, `interactive` or `whatsapp_template`. |
| `data.message.text` | string or null | The text or caption. For other types, text that Chatwise makes of the message, such as JSON for a location or contacts. Null for WhatsApp authentication templates, so a one-time code is never returned. |
| `data.message.sentAt` | string | When the message was sent. ISO 8601, in UTC. |
| `data.message.ingestedAt` | string | When Chatwise stored the message. ISO 8601, in UTC. |
| `data.message.replyToMessageId` | string or null | The message this one replies to, if any and still visible. |
| `data.message.attachments` | array of objects | The message's attachments, at most 10. Always empty on Messenger and Website Chat, and for WhatsApp authentication templates. |
| `data.message.attachments[].type` | string | The attachment's type, such as `image`, `video`, `audio` or `document`. |
| `data.message.attachments[].mediaId` | string or null | The channel's id for the media, when Chatwise has it: usually on Instagram only. |
| `data.conversation` | object | Its conversation, as the API returns it. |
| `data.conversation.id` | string | The conversation's id. |
| `data.conversation.channel` | string | The channel the conversation is on. One of `WHATSAPP`, `INSTAGRAM`, `MESSENGER`, `WEBSITE_CHAT`. |
| `data.conversation.status` | string | Whether the conversation is open or resolved in the inbox. One of `open`, `resolved`. |
| `data.conversation.participant` | object | The customer. |
| `data.conversation.participant.name` | string or null | The customer's name. A placeholder, or on Website Chat their email, when Chatwise doesn't know it. |
| `data.conversation.participant.channelId` | string or null | The customer's id on the channel: the WhatsApp number, or an Instagram or Messenger id. Null on Website Chat. |
| `data.conversation.participant.phoneNumber` | string or null | The customer's phone number, digits only, on WhatsApp. Null on other channels, and when WhatsApp doesn't show it. |
| `data.conversation.participant.instagramUsername` | string or null | The customer's Instagram username, when known. Null on WhatsApp. |
| `data.conversation.createdAt` | string | When the conversation was created in Chatwise. ISO 8601, in UTC. |
| `data.conversation.lastMessageAt` | string or null | When the latest message was sent. Null before the first one. ISO 8601, in UTC. |
| `data.account` | object or null | The account the conversation is on, such as a WhatsApp number or an Instagram account. |
| `data.account.id` | string | The account's id. The same as in `accountIds`. |
| `data.account.channel` | string | The account's channel. One of `WHATSAPP`, `INSTAGRAM`, `MESSENGER`, `WEBSITE_CHAT`. |

Fields are only ever added within an `apiVersion`, so ignore the ones you don't know. `data.message` and `data.conversation` are the objects [get a message](https://chatwise.so/docs/api/get-message.md) and [get a conversation](https://chatwise.so/docs/api/get-conversation.md) return.

## Verify it

Check the signature against the raw body before you trust the event. [Verify signatures](https://chatwise.so/docs/webhooks/verify-signatures.md) explains each step and has a complete server.

**Node.js** `verify.mjs`:

```js
import { createHmac, timingSafeEqual } from "node:crypto";

const FIVE_MINUTES = 5 * 60;

// rawBody is the request body exactly as received (a Buffer or a string).
// headers has lowercase names, as Node's request.headers does.
export function verifyChatwiseWebhook(rawBody, headers, secret, now = Date.now() / 1000) {
  const id = headers["webhook-id"];
  const timestamp = headers["webhook-timestamp"];
  const signatures = headers["webhook-signature"];
  if (!id || !timestamp || !signatures) return false;

  // Refuse old requests, so a captured one can't be sent again later.
  if (!(Math.abs(now - Number(timestamp)) <= FIVE_MINUTES)) return false;

  const key = Buffer.from(secret.slice("whsec_".length), "base64");
  const expected = createHmac("sha256", key).update(`${id}.${timestamp}.`).update(rawBody).digest();

  // While a secret is being rotated there are two signatures. One match is enough.
  return signatures.split(" ").some((signature) => {
    const [version, value = ""] = signature.split(",");
    const received = Buffer.from(value, "base64");
    return version === "v1" && received.length === expected.length && timingSafeEqual(received, expected);
  });
}
```

**Python** `verify.py`:

```python
import base64
import hashlib
import hmac
import time

FIVE_MINUTES = 5 * 60


def verify_chatwise_webhook(raw_body, headers, secret, now=None):
    """raw_body is the request body exactly as received, as bytes.

    headers is a mapping with case-insensitive or lowercase names.
    """
    message_id = headers.get("webhook-id")
    timestamp = headers.get("webhook-timestamp")
    signatures = headers.get("webhook-signature")
    if not message_id or not timestamp or not signatures:
        return False

    # Refuse old requests, so a captured one can't be sent again later.
    try:
        age = abs((time.time() if now is None else now) - int(timestamp))
    except ValueError:
        return False
    if age > FIVE_MINUTES:
        return False

    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{message_id}.{timestamp}.".encode() + raw_body
    expected = "v1," + base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()

    # While a secret is being rotated there are two signatures. One match is enough.
    return any(
        hmac.compare_digest(signature.encode(), expected.encode())
        for signature in signatures.split(" ")
    )
```

## Answer it

Answer with any 2xx status within 10 seconds, and do the work afterwards. The same event can arrive more than once, so skip a `webhook-id` you already handled. What other answers do is in [delivery and retries](https://chatwise.so/docs/webhooks/delivery.md).
