# Inbox and conversations API

Every messenger conversation lands in one inbox per workspace, across all your sites and apps. Work it in the dashboard (Inbox), in the iPhone app, through MCP, or show it in your own tools with the conversations API and webhooks.

A conversation is also the ticket: it has a status (`open`, `snoozed`, `closed`), a priority, an assignee and tags.

## Keys

Conversations hold personal data, so intelligence (`read`) keys can't see them. Create a **Support** key under Agents and keys for a tool or agent that works the inbox: it reads numbers, reads and replies to conversations, and registers webhooks, but can't change settings. Dev keys can do all of that too.

```bash
curl https://api.pagebee.ai/v1/conversations?status=open \
  -H "Authorization: Bearer pb_ak_your_support_key"
```

## Endpoints

| Method and path | Does |
| --- | --- |
| `GET /v1/conversations` | The inbox, newest activity first. `status` (`open`, `snoozed`, `closed`, `all`), `property`, `tag`, `before`, `limit` (up to 100) |
| `GET /v1/conversations/:id` | The conversation, its contact and context, and every message, notes included |
| `POST /v1/conversations/:id/messages` | Reply: `{ "body": "...", "author": { "id": "u_1", "name": "Sam Lee" } }`. Add `"note": true` for an internal note |
| `PATCH /v1/conversations/:id` | `status` (with `snoozed_until` for snoozes), `priority` (0 or 1), `assignee` (`{ id, name }` or null), `tags`, `subject` |
| `POST /v1/conversations/:id/read` | Marks it read for the team |
| `POST /v1/conversations` | Start one with a signed-in person of yours: `property_id`, `external_id`, `body`, `author`, optional `email`, `name`, `subject` |
| `DELETE /v1/conversations/:id` | Deletes it and its messages for good, and the contact if they have no other conversations |
| `GET /v1/conversations/stream` | Server-sent events: a `conversation` event with `type` and `conversation_id` for every change |
| `GET /v1/conversations/:id/context` | What the site or app is doing now (see below) |
| `POST /v1/contacts` | Tell the inbox about a signed-in person (see below) |
| `GET /v1/saved-replies` | The team's saved replies |
| `POST /v1/saved-replies` | `shortcut`, `title`, `body`. Creates one, or updates the one with the same shortcut |
| `PATCH /v1/saved-replies/:id`, `DELETE /v1/saved-replies/:id` | Change or delete one |

Replies from a key name their author, so the person sees your teammate's first name and your system keeps track of who replied. In the dashboard and the app, people reply as themselves.

A reply reaches the person in their messenger at once. If they left an email and don't have the chat open, it's emailed to them too. Internal notes are never shown to the person or emailed.

## Who wrote in

Send what your team should know about a signed-in person from your server, whenever they sign in or their plan changes. It shows beside every conversation they start, and your agent sees it too.

```bash
curl -X POST https://api.pagebee.ai/v1/contacts \
  -H "Authorization: Bearer pb_ak_your_support_key" \
  -H "Content-Type: application/json" \
  -d '{"site_id":"<site id>","user_id":"user_42","email":"ada@example.com","name":"Ada","traits":{"plan":"pro","mrr":49,"app_version":"2.3.1"}}'
```

Traits merge with the ones already held, and `null` removes one. The same person signed in to the messenger with an identity token is the same contact.

## What the site is doing now

Beside each conversation, the inbox shows what the site or app is doing: visitors in the last 30 minutes, today and yesterday, the busiest custom events and live feed items of the last day, and how many earlier conversations this person had. MCP's `get_conversation` returns it as `product_context`, so a coding agent picking up a bug report has it.

None of it is about the person. It is the same for everyone who writes in, and conversations are never joined to analytics.

## Saved replies

Answers your team sends often, shared across the workspace. Write `{first_name}` where the person's first name goes. Keep them in your repo and have your agent push them with `save_reply`, or save them from the reply box in the inbox.

## Email limits

Replies by email go from a sending reputation every Pagebee customer shares, so they are limited: 20 a day in a workspace's first week, then 100 on Free and 1,000 on paid plans, and at most 10 a day to one address. Addresses that bounce or report a support email as spam get no more email, and three spam reports in 30 days pause a workspace's support email until we look. A reply that isn't emailed still reaches the chat, and the thread gets an internal note saying why.

## Webhooks

Register a URL and Pagebee posts each change to it.

```bash
curl -X POST https://api.pagebee.ai/v1/webhooks \
  -H "Authorization: Bearer pb_ak_your_support_key" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/hooks/pagebee","events":["conversation.created","message.created","conversation.updated"]}'
```

The answer includes the signing secret (`whsec_...`), which you can read again at `GET /v1/webhooks/:id/secret`. Each delivery is `{ id, type, created_at, data }` with the conversation, and for `message.created` the message. Check the `Pagebee-Signature` header, `t=<unix seconds>,v1=<hex>`, where the hex is HMAC-SHA256 of `<t>.<raw body>` with the secret:

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

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

A delivery that fails is tried again after 10 seconds, a minute and four minutes. The API is the source of truth: if you need every change, read the conversation when a webhook arrives.

To work the inbox from another system (replies, notes, status and assignment going back, every event retried for hours with a delivery log), use an [inbox bridge](/docs/inbox-bridges) instead.

## MCP

With a support or dev key, your agent gets `list_conversations`, `get_conversation`, `reply_to_conversation`, `update_conversation`, `list_saved_replies`, `save_reply` and `update_contact`, and `add_inbox_bridge`, `list_inbox_bridges`, `test_inbox_bridge` and `remove_inbox_bridge`. Dev keys also get `get_messenger_config`, `apply_messenger_config` and `get_messenger_identity_secret`. See [MCP](/docs/mcp).
