> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.flowella.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook events, payloads and signature verification

> Reference for Flowella outbound webhooks: event types, payloads, headers, HMAC-SHA256 signature checks, retries, deduplication and management endpoints.

Outbound webhooks let your systems react to events in Flowella without polling the API. Each webhook has a URL, a signing secret and a list of event types. When one of those events happens, Flowella sends a signed JSON `POST` to the URL.

You can manage webhooks in the app under **Settings** → **Webhooks** (see [Add and manage outbound webhooks](https://knowledge.flowella.io/settings/webhooks.md)) or with the [webhooks API](#manage-webhooks-with-the-api). This page is the reference for what Flowella sends.

## Event types

Tick these events when you add a webhook, or pass them in `events` when you create one with the API.

| Event | When it fires | `data` fields |
| - | - | - |
| `message.received` | A contact sends a message to one of your WhatsApp numbers. | `messageId`, `conversationId`, `contactId`, `direction` (`INBOUND`), `type`, `metaMessageId` |
| `message.sent` | Flowella sends a message from the inbox or with `POST /v1/messages`. It fires again when Meta reports any outbound message as sent, including bulk and HubSpot workflow sends. | From the inbox or API: `messageId`, `conversationId`, `contactId`, `direction`, `type`, `metaMessageId`. From Meta: `messageId`, `conversationId`, `metaMessageId`, `status`, `direction` |
| `message.delivered` | Meta reports that the message reached the recipient's device. | `messageId`, `conversationId`, `metaMessageId`, `status`, `direction` |
| `message.read` | Meta reports that the recipient read the message. | Same as `message.delivered` |
| `message.failed` | Meta reports that the message could not be delivered. | Same as `message.delivered` |
| `conversation.opened` | An inbound message creates a new conversation. Flowella keeps one conversation per contact and WhatsApp number, so this fires only when the contact has no conversation on that number yet. It does not fire when a closed conversation reopens. | `conversationId`, `contactId`, `whatsappChannelId` |
| `conversation.closed` | A conversation is closed in the inbox (one at a time or in bulk), with `POST /v1/conversations/{id}/close`, or because its WhatsApp number was removed. | `conversationId` |
| `optout.created` | A contact opts out by sending an opt-out keyword, or you record an opt-out with `POST /v1/opt-outs`. It fires only when the contact was not already opted out. Opt-outs you add or import in the app do not fire it. | `contactId`, `phone`, `reason`, and `conversationId` for keyword opt-outs. `reason` is `USER_KEYWORD` for keywords, otherwise the reason you sent or `API_SET`. |
| `template.status_updated` | Meta changes the status of one of your templates. | `metaTemplateId`, `templateName`, `status` (`APPROVED`, `REJECTED`, `PENDING`, `PAUSED` or `DISABLED`), plus `reason`, `language` and `category` when Meta sends them |
| `flow.status_updated` | The status of a Flow in Meta changes: when you deprecate it with `POST /v1/flows/{id}/deprecate`, or when `GET /v1/flows/{id}` refreshes the status from Meta and finds it has changed. | `flowId`, `metaFlowId`, `previousStatus`, `status` (`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED`, `THROTTLED` or `UNKNOWN`), `source` (`api_deprecate` or `status_refresh`), `occurredAt`. It never includes contact data or answers. |
| `contact.created` | You create a contact with `POST /v1/contacts`. | `contactId`, `externalId` |
| `contact.updated` | You update a contact with `PATCH /v1/contacts/{id}`, or with `POST /v1/contacts` for a phone number that already exists. | `contactId`, `externalId` |
| `contact.deleted` | You delete a contact with `DELETE /v1/contacts/{id}`. | `contactId`, `externalId` |

Contact events fire only for these single-contact API calls. They do not fire for `POST /v1/contacts/bulk-upsert`, for contacts created by inbound messages, or for changes made in the app or synced from HubSpot.

> [!WARNING]
>
> Known issue: `optout.created` doesn't fire for a contact's first opt-out on a WhatsApp number, whether the contact sends a keyword or you call `POST /v1/opt-outs`. At the moment it fires only when a contact who opted back in opts out again. Don't rely on it to catch every opt-out: list opt-outs with `GET /v1/opt-outs` (scope `contacts:read`).

Flowella also sends `webhook.test` when you select **Send test event** in the app or call `POST /v1/webhooks/{id}/test`. You cannot subscribe to it. Its `data` is `{ "test": true, "sentAt": "<ISO 8601 time>" }`.

> [!NOTE]
>
> One outbound message can produce two `message.sent` events: one when Flowella hands it to Meta, and one when Meta reports it as sent. The two have different top-level `id` values. Use `data.messageId` to link them to the same message.

## Request format

Flowella sends each event as an HTTP `POST` with these headers:

| Header | Value |
| - | - |
| `Content-Type` | `application/json` |
| `X-Flowella-Signature` | The lowercase hex HMAC-SHA256 of the raw body, made with the webhook's current signing secret. |
| `X-Flowella-Signature-Previous` | The same signature made with the previous secret. Sent only for 24 hours after you [rotate the secret](#rotate-a-signing-secret) with the API. |

Flowella sends no other custom headers. The event type and ID are in the body.

### Body

Every webhook has a payload version, returned as `payloadVersion` by the webhooks API. Version `1` is the default for every webhook, and there is no setting in the app or the API to change it. The two versions use these envelopes:

```json Version 1 (default) theme={null}
{
  "id": "evt_3f2b8c1d9a7e4f60b5c2d8e1a4f7b9c3",
  "type": "message.received",
  "created_at": "2026-10-21T09:30:00.000Z",
  "payload_version": "1",
  "data": {
    "messageId": "clxxxxxxxxxxxxxxxxxxxxxxxx",
    "conversationId": "clxxxxxxxxxxxxxxxxxxxxxxxx",
    "contactId": "clxxxxxxxxxxxxxxxxxxxxxxxx",
    "direction": "INBOUND",
    "type": "TEXT",
    "metaMessageId": "wamid.HBgLMTU1NTEyMzQ1NjcVAgASGBQzQUY"
  }
}
```

```json Version 2 theme={null}
{
  "id": "evt_3f2b8c1d9a7e4f60b5c2d8e1a4f7b9c3",
  "type": "message.received",
  "occurred_at": "2026-10-21T09:30:00.000Z",
  "version": "2026-08-11",
  "correlation_id": null,
  "data": {
    "messageId": "clxxxxxxxxxxxxxxxxxxxxxxxx",
    "conversationId": "clxxxxxxxxxxxxxxxxxxxxxxxx",
    "contactId": "clxxxxxxxxxxxxxxxxxxxxxxxx",
    "direction": "INBOUND",
    "type": "TEXT",
    "metaMessageId": "wamid.HBgLMTU1NTEyMzQ1NjcVAgASGBQzQUY"
  }
}
```

| Field | Meaning |
| - | - |
| `id` | The unique ID of the event, usually `evt_` followed by 32 hexadecimal characters. Test events use a UUID. The same event keeps the same `id` across retries and replays, and every webhook that receives it gets the same `id`. |
| `type` | The event type from the [table above](#event-types). |
| `created_at` (version 1) or `occurred_at` (version 2) | When Flowella created the delivery, as an ISO 8601 time in UTC. Replays keep the original time. |
| `payload_version` (version 1) | Always `"1"`. |
| `version` (version 2) | The API version date, `2026-08-11`. |
| `correlation_id` (version 2) | The request ID of the API call that caused the event when Flowella knows it, otherwise `null`. |
| `data` | The event fields listed in [Event types](#event-types). |

Flowella does not send an event whose `data` is larger than 256 KB.

## Verify signatures

Check the signature on every request before you trust it. Flowella computes `X-Flowella-Signature` like this:

* **Algorithm**: HMAC with SHA-256.
* **Key**: the signing secret as UTF-8 text, exactly as saved. A secret generated by the API includes its `whsec_` prefix.
* **Message**: the raw request body, byte for byte, as Flowella sent it. Nothing else is signed: there is no timestamp or URL in the signature.
* **Output**: lowercase hexadecimal, 64 characters, with no `sha256=` prefix.

To verify, compute the same HMAC over the raw body and compare it with the header in constant time. During the 24 hours after an API rotation, the request carries both headers: accept it if either header matches a secret you hold.

```javascript Node.js theme={null}
import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody: the request body as a Buffer, before any JSON parsing.
// secrets: the secrets you accept, for example [current] or [current, previous].
export function isValidFlowellaSignature(rawBody, headers, secrets) {
  const received = [
    headers["x-flowella-signature"],
    headers["x-flowella-signature-previous"],
  ].filter(Boolean);

  return secrets.some((secret) => {
    const expected = createHmac("sha256", secret).update(rawBody).digest();
    return received.some((value) => {
      const given = Buffer.from(value, "hex");
      return given.length === expected.length && timingSafeEqual(given, expected);
    });
  });
}

// Express: keep the raw body for this route.
// app.post("/flowella", express.raw({ type: "application/json" }), (req, res) => {
//   if (!isValidFlowellaSignature(req.body, req.headers, [process.env.FLOWELLA_WEBHOOK_SECRET])) {
//     return res.sendStatus(401);
//   }
//   const event = JSON.parse(req.body.toString("utf8"));
//   res.sendStatus(200); // reply first, then process the event in the background
// });
```

```python Python theme={null}
import hashlib
import hmac


def is_valid_flowella_signature(raw_body: bytes, headers, secrets: list[str]) -> bool:
    """raw_body is the request body exactly as received, before JSON parsing."""
    received = [
        value.lower()
        for value in (
            headers.get("X-Flowella-Signature"),
            headers.get("X-Flowella-Signature-Previous"),
        )
        if value
    ]
    for secret in secrets:
        expected = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
        if any(hmac.compare_digest(expected, value) for value in received):
            return True
    return False
```

> [!WARNING]
>
> Compute the signature over the raw body before any middleware parses or reformats it. If your framework parses the JSON and you serialise it again, the bytes change and the signature does not match.

## Responses, retries and timeouts

| Rule | Value |
| - | - |
| Success | Any `2xx` status within 10 seconds. |
| Attempts per event | 3 in total: the second about 1 second after the first fails, the third about 2 seconds after the second. |
| After the third failure | The event is dropped. Flowella does not retry it later. |
| Turning the webhook off | After 10 events in a row fail all their attempts, Flowella turns the webhook off and sends every Owner an in-app "Outbound webhook disabled" notification. A successful delivery resets the count. |
| Inactive webhooks | Receive no events. Events that happen while a webhook is inactive are not sent later. |

Flowella delivers several events at once, so they can arrive out of order. Use `created_at` or `occurred_at` if order matters. Reply with a `2xx` status as soon as the signature checks out, then process the event in the background. For how retries look in the app, see [Retries and back-off](https://knowledge.flowella.io/settings/webhooks.md#retries-and-back-off).

## Deduplicate events

Your endpoint can receive the same event more than once: a retry after your endpoint timed out but still processed the request, or a replay through the API. Deduplicate on the top-level `id`:

1. Store the `id` of every event you process.
2. If an incoming `id` is already stored, reply `200` and do nothing else.
3. Keep stored IDs at least as long as you might replay deliveries.

Do not deduplicate on `data.messageId`. Different events about the same message, such as `message.sent` and `message.delivered`, share it.

## Event feed

The event feed is a pull alternative to webhooks. `GET /v1/events` returns events from the last 7 days, including events that no webhook subscribes to. It needs the `events:read` scope. Filter with `type` (one type or a comma-separated list), `occurredAfter` and `occurredBefore`, and page with `limit` and `cursor`.

Each item has `id`, `type`, `occurredAt`, `version`, `correlationId` and `data`. The `id` matches the `id` in the webhook body, so you can use the feed to fill gaps after your endpoint was down.

## Manage webhooks with the API

All webhook endpoints need an API key or OAuth access token with the `webhooks:manage` scope. Keys created in the app have it. See the [API introduction](https://knowledge.flowella.io/api-reference/introduction.md) for authentication.

| Method | Path | What it does |
| - | - | - |
| `GET` | `/v1/webhooks` | Lists your webhooks in `items`. |
| `POST` | `/v1/webhooks` | Creates a webhook from `url`, `events` and an optional `name`. Returns `201` with `webhook` and `signingSecret`. |
| `GET` | `/v1/webhooks/{id}` | Returns one webhook. |
| `PATCH` | `/v1/webhooks/{id}` | Changes `url`, `name`, `events` or `isActive`. |
| `DELETE` | `/v1/webhooks/{id}` | Deletes the webhook and its delivery history. Returns `204`. |
| `POST` | `/v1/webhooks/{id}/test` | Queues a `webhook.test` delivery. |
| `POST` | `/v1/webhooks/{id}/rotate-secret` | Generates a new signing secret. See [Rotate a signing secret](#rotate-a-signing-secret). |
| `POST` | `/v1/webhooks/{id}/reactivate` | Turns the webhook on and resets its failure count to zero. |
| `GET` | `/v1/webhooks/{id}/deliveries` | Lists delivery attempts. Filter with `status` (`success` or `failed`), `event`, `occurredAfter` and `occurredBefore`; page with `limit` and `cursor`. |
| `GET` | `/v1/webhooks/{id}/deliveries/{deliveryId}` | Returns one attempt, including the stored `payload` and the first 1,024 characters of your endpoint's response body. |
| `POST` | `/v1/webhooks/{id}/deliveries/{deliveryId}/replay` | Sends the stored event again with its original `id` and time. Returns `202`. |
| `POST` | `/v1/webhooks/{id}/deliveries/bulk-replay` | Replays up to 100 deliveries, given as `deliveryIds`, in the background. Returns `202` with a `jobId`. |

Webhook objects contain `id`, `name`, `url`, `events`, `isActive`, `consecutiveFailures`, `signingSecretPrefix` (the first 8 characters of the current secret), `payloadVersion`, `lastTriggeredAt`, `disabledAt`, `createdAt` and `updatedAt`.

A few rules apply to webhooks managed through the API:

* You cannot choose the signing secret through the API. `POST /v1/webhooks` generates one that starts with `whsec_` and returns it once, as `signingSecret`.
* Replays do not count towards or reset the failure count. Flowella delivers a replay only while the webhook is active and still subscribed to that event type.
* The URL must follow the same [URL rules](https://knowledge.flowella.io/settings/webhooks.md#url-rules) as in the app.

### Rotate a signing secret

Rotate a secret when you think it has leaked, or on a regular schedule. Rotation works for any webhook that has a secret, including webhooks whose secret you typed in the app.

**1. Request a new secret**

Call the rotate endpoint and store the `signingSecret` from the response. Flowella returns it only once.

```bash theme={null}
curl -X POST "https://api.flowella.io/v1/webhooks/WEBHOOK_ID/rotate-secret" \
  -H "Authorization: Bearer $FLOWELLA_API_KEY"
```

**2. Accept both secrets for 24 hours**

New deliveries are signed with the new secret in `X-Flowella-Signature`, and with the old secret in `X-Flowella-Signature-Previous`. A handler that still uses the old secret keeps working if it checks both headers, as in the example in [Verify signatures](#verify-signatures).

**3. Switch to the new secret**

Update your handler to the new secret within 24 hours. After that, Flowella stops sending `X-Flowella-Signature-Previous`.

Changing the secret in the app with **New signing secret** has no overlap: the old secret stops working at once.

## Test locally

To receive webhooks on your own computer, expose your local server through a public tunnel, such as ngrok or Cloudflare Tunnel. Use the tunnel's public URL as the endpoint. Then use **Send test event** to send requests whenever you need them. Flowella refuses local and private addresses, so a `localhost` URL does not work.

## Related

> [card] [Manage webhooks in the app](https://knowledge.flowella.io/settings/webhooks.md)
>
> Add endpoints, send test events and read the delivery log.

> [card] [API introduction](https://knowledge.flowella.io/api-reference/introduction.md)
>
> Authentication, scopes, rate limits and errors.

> [card] [API keys](https://knowledge.flowella.io/settings/api-keys.md)
>
> Create the key you need for the webhooks API.

> [card] [Developer hub](https://knowledge.flowella.io/settings/developer-hub.md)
>
> Recent API requests, quickstarts and the API sandbox.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.