# Inbox bridges

Bring your own inbox. An inbox bridge connects another system's inbox (your CRM, a helpdesk, your team's own tools) to Pagebee's support inbox in both directions. Every conversation, message, status change and assignment is sent to your system as it happens, and your system replies, adds notes, closes and assigns through Pagebee. Replies reach the person through the messenger and by email, exactly as a reply written in Pagebee would, and show in Pagebee as sent by your teammate "via" the bridge.

Nobody has to sign in to two places, and Pagebee stays the source of truth.

This page is the bridge contract, version `2026-11-24`. Every delivery and `GET /v1/bridge` carry the version, and a change that could break a receiver gets a new one.

## Connect one

In the dashboard: **Settings, Inbox bridges, Connect an inbox**. Give it a name (shown on replies, like "Sam via NBS platform"), the URL Pagebee should post to, and optionally the one site or app it covers. You get two things:

- **The bridge token** (`pbb_...`). Your system sends it to the bridge API. It's shown once; make a new one from the bridge's row if it's lost.
- **The signing secret** (`whsec_...`). Your system checks every delivery with it. You can see it again from the bridge's row.

Keep both in your system's secret store, never in a repo.

Or let your agent do it: with a support or dev key, MCP has `add_inbox_bridge`, `list_inbox_bridges`, `test_inbox_bridge` and `remove_inbox_bridge`. The REST API has the same under `/v1/bridges`:

```bash
curl -X POST https://api.pagebee.ai/v1/bridges \
  -H "Authorization: Bearer pb_ak_your_support_key" \
  -H "Content-Type: application/json" \
  -d '{"name":"NBS platform","url":"https://example.com/hooks/pagebee"}'
```

```json
{
  "bridge": { "id": "6f1c...", "name": "NBS platform", "url": "https://example.com/hooks/pagebee", "site_ids": null, "paused": false, "token_hint": "pbb_...x9Qa", "contract": "2026-11-24" },
  "token": "pbb_...",
  "secret": "whsec_..."
}
```

Add `"site_ids": ["<site id>"]` to cover only some sites and apps. Leave it out to cover all of them, including ones you add later.

Press **Test** on the bridge (or call `test_inbox_bridge`) to send a signed `bridge.test` event and see what came back.

## Events Pagebee sends

Each event is a `POST` to your URL with a JSON body:

```json
{
  "id": "0b6e2f9c-6d0a-4a51-9a3e-2d4f6c1b8e21",
  "type": "message.created",
  "contract": "2026-11-24",
  "created_at": "2026-11-24T10:15:00.000Z",
  "workspace_id": "1a2b...",
  "bridge": { "id": "6f1c...", "name": "NBS platform" },
  "data": { "conversation": { }, "message": { } }
}
```

| `type` | When | `data` |
| --- | --- | --- |
| `conversation.created` | Someone writes in for the first time, or your team starts a conversation | `conversation`, `message` (the first one) |
| `message.created` | A new message: from the person, a reply, an internal note, or a note from Pagebee | `conversation`, `message` |
| `conversation.status_changed` | Opened, snoozed or closed. A person writing again reopens it | `conversation`, `from`, `to`, `actor` |
| `conversation.assigned` | Assigned, reassigned or unassigned | `conversation`, `from`, `to` (`{ id, name }` or null), `actor` |
| `conversation.updated` | Priority, tags or subject changed, or the person left their email | `conversation`, `changes` (the fields), `actor` |
| `conversation.deleted` | Deleted for good (an erasure request, or spam) | `conversation` (`{ id, property_id, deleted: true }`) |
| `bridge.test` | The test button | `message` |

`actor` is `{ id, name }` for who made the change, or null when it was the person or Pagebee.

Changes your system makes through the bridge API are not sent back to it. Other bridges still hear about them.

### The conversation

Every event (except `conversation.deleted`) carries the whole conversation as it is now:

```json
{
  "id": "c0ffee00-...",
  "workspace_id": "1a2b...",
  "property": { "id": "9d8c...", "name": "Kiln", "domain": "kiln.example" },
  "environment": "production",
  "channel": "web",
  "status": "open",
  "priority": 0,
  "subject": null,
  "assignee": { "id": "nbs-user-1", "name": "Sam Lee" },
  "tags": ["billing"],
  "snoozed_until": null,
  "context": { "path": "/pricing", "pages": ["/", "/pricing"] },
  "contact": { "id": "...", "name": "Ada Lovelace", "email": "ada@example.com", "external_id": "user_42", "verified": true, "traits": { "plan": "pro" }, "last_seen_at": "..." },
  "last_message": { "author": "contact", "body": "My export is empty", "note": false, "created_at": "..." },
  "unread": true,
  "last_message_at": "...",
  "created_at": "...",
  "updated_at": "...",
  "pagebee_url": "https://pagebee.ai/w/your-team/inbox?c=c0ffee00-..."
}
```

`property` is the site or app it came in on. `contact.email` is there once the person has left one or your server identified them.

### The message

```json
{
  "id": "m1...",
  "conversation_id": "c0ffee00-...",
  "author": "contact",
  "author_ref": null,
  "body": "My export is empty",
  "note": false,
  "via": null,
  "created_at": "..."
}
```

`author` is `contact` (the person), `teammate`, `bot` or `system`. For a teammate, `author_ref` is `{ id, name }`. `note: true` is an internal note the person never sees. `via` is `{ bridge_id, bridge_name }` when it was posted through a bridge.

### Headers

| Header | Value |
| --- | --- |
| `Pagebee-Signature` | `t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with the signing secret>` |
| `Pagebee-Event-Id` | The event id, the same as `id` in the body |
| `Pagebee-Event-Type` | The event type |
| `Pagebee-Bridge-Id` | Which bridge it's for, if one receiver serves several |
| `Pagebee-Contract` | `2026-11-24` |
| `Pagebee-Delivery-Attempt` | 1 for the first try, then 2, 3 and so on |

### Checking the signature

Check the signature on the raw body before parsing it, and refuse anything older than five minutes:

```ts
import crypto from "node:crypto";

export function verifyPagebee(header: string, rawBody: string, secret: string): boolean {
  const [, t, v1] = /^t=(\d+),v1=([0-9a-f]+)$/.exec(header) ?? [];
  if (!t || !v1 || Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const mac = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  return mac.length === v1.length && crypto.timingSafeEqual(Buffer.from(mac), Buffer.from(v1));
}
```

### Answering, retries and duplicates

Answer with any `2xx` within 10 seconds. Do the work after answering if it is slow.

Anything else (an error status, a timeout, a redirect) is tried again after 1, 5, 15 and 30 minutes, then 1, 2, 4 and 8 hours: nine tries over about 16 hours. After the last one the delivery is marked failed and kept, and you can send it again from the bridge's delivery log (one, or all failed ones at once).

Every try of an event sends the same event id. **Keep the ids you have handled and ignore one you have seen**, so a retry never adds a message twice. Message and conversation ids are stable too.

Events can arrive out of order when one is retried. Each one carries the conversation as it was when the event happened, with `updated_at`; keep the newest. If you need to be certain, read the conversation from the bridge API.

A paused bridge keeps its events and sends them when it's resumed. Delivered events are kept in the log for 30 days and failed ones for 90.

## The bridge API

Your system calls these with the bridge token. It sees only the sites and apps the bridge covers.

```bash
curl https://api.pagebee.ai/v1/bridge -H "Authorization: Bearer pbb_your_bridge_token"
```

| Method and path | Does |
| --- | --- |
| `GET /v1/bridge` | Who the bridge is: `bridge`, `workspace`, `contract`, `events`, `signing_secret`, and `sites` (each `id`, `name`, `domain`, `kind`) |
| `GET /v1/bridge/conversations` | Conversations, newest activity first. `status` (`open`, `snoozed`, `closed`, `all`, default `all`), `since` (an ISO time, to catch up), `limit` (up to 100) |
| `GET /v1/bridge/conversations/:id` | The conversation and every message, notes included |
| `POST /v1/bridge/conversations/:id/messages` | A reply to the person, or an internal note (below) |
| `PATCH /v1/bridge/conversations/:id` | Status, assignment, priority and tags (below) |

### Reply or add a note

```bash
curl -X POST https://api.pagebee.ai/v1/bridge/conversations/<id>/messages \
  -H "Authorization: Bearer pbb_your_bridge_token" \
  -H "Content-Type: application/json" \
  -d '{"body":"Fixed now, sorry about that","author":{"id":"u_17","name":"Sam Lee","email":"sam@yourteam.com"},"external_id":"your-message-id"}'
```

| Field | |
| --- | --- |
| `body` | Required. Up to 5,000 characters |
| `author` | Required. `{ id, name }`, with optional `email` and `avatar_url`. The person sees the first name |
| `note` | `true` for an internal note, which is never shown to the person or emailed |
| `external_id` | Your own id for the message. Posting the same one again returns the first and sends nothing twice |

A reply reaches the person in their messenger at once, and by email if they left one and don't have the chat open (within [the email limits](/docs/conversations-api#email-limits)). The answer is `201` with the `message`.

### Status and assignment

```bash
curl -X PATCH https://api.pagebee.ai/v1/bridge/conversations/<id> \
  -H "Authorization: Bearer pbb_your_bridge_token" \
  -H "Content-Type: application/json" \
  -d '{"status":"closed","assignee":{"id":"u_17","name":"Sam Lee"},"actor":{"id":"u_17","name":"Sam Lee"}}'
```

| Field | |
| --- | --- |
| `status` | `open`, `snoozed` (with `snoozed_until`, an ISO time in the future) or `closed` |
| `assignee` | `{ id, name }` from your system, or `null` to unassign |
| `priority` | `0` normal, `1` high |
| `tags` | The whole list of tags |
| `actor` | Who made the change, for other bridges and the record |

### Errors

Errors are `{ "error": "<code>", "message": "..." }` with the status: `400` for a body that doesn't fit (`details` says which field), `401` for a token that isn't valid (replaced, or the bridge removed), `403` for a paused bridge, and `404` for a conversation the bridge can't see.

## Managing bridges

With a support or dev key that covers every site (a key limited to some sites can't), or as a workspace admin in the dashboard:

| Method and path | Does |
| --- | --- |
| `GET /v1/bridges` | Every bridge, with how deliveries are going (`pending`, `failed`, `delivered_24h`) |
| `POST /v1/bridges` | Add one: `name`, `url`, optional `site_ids` |
| `GET /v1/bridges/:id` | One bridge |
| `PATCH /v1/bridges/:id` | `name`, `url`, `site_ids`, `paused` |
| `DELETE /v1/bridges/:id` | Remove it. The token stops working at once and its log is deleted. Conversations stay |
| `GET /v1/bridges/:id/secret` | The signing secret |
| `POST /v1/bridges/:id/token` | A new token. The old one stops working at once |
| `POST /v1/bridges/:id/test` | Send a `bridge.test` event now: `ok`, `status`, `duration_ms`, `error` |
| `GET /v1/bridges/:id/deliveries` | The delivery log, newest first. `status` (`pending`, `delivered`, `failed`), `limit` |
| `GET /v1/bridges/:id/deliveries/:delivery` | One delivery, with the body that was sent |
| `POST /v1/bridges/:id/deliveries/:delivery/retry` | Send it again now, with a fresh set of retries |
| `POST /v1/bridges/:id/retry-failed` | Send every failed delivery again |

## Bridges or webhooks

[Webhooks](/docs/conversations-api#webhooks) are one-way and lighter: three event types, three retries, no log. Use a bridge when your system works the inbox, so replies, notes, status and assignment come back, and when you need every event to arrive.

## MCP

| Tool | What it does |
| --- | --- |
| `add_inbox_bridge` | Connect another inbox: name, URL, optional sites. Returns the token and secret |
| `list_inbox_bridges` | Every bridge and how deliveries are going; with `bridge_id`, its recent deliveries |
| `test_inbox_bridge` | Send a signed test event and say what came back |
| `remove_inbox_bridge` | Disconnect one |

See [MCP](/docs/mcp).
