---
title: API conventions
description: "What every endpoint has in common: request ids, the answers' shape, authentication and the workspace a request acts in."
sidebar:
  icon: book-open
---

Every endpoint of the [API](/developers) follows the same rules, so a client written for one handles them all. The [API reference](/reference) has what each endpoint takes and answers. The pages below cover what they share.

**[Errors](/developers/conventions/errors)**

The error format, what to do with each kind, and every code.

**[Ids and instants](/developers/conventions/ids)**

How ids, instants and time zones are written.

**[Paging](/developers/conventions/paging)**

Read a list one page at a time.

**[Idempotency](/developers/conventions/idempotency)**

Send a request again without posting twice.

**[Rate limits](/developers/conventions/rate-limits)**

How many requests a key may send.

**[Versions and changes](/developers/conventions/versioning)**

How the API changes, deprecations and the changelog.

**[Discovery](/developers/conventions/discovery)**

The documents that tell a program where the API is.

## Requests and answers [#requests]

Requests go to the address you open Peal at, under `/api`, and a workspace's endpoints under `/api/v1` ([The workspace of a request](#workspace)). Bodies are JSON, sent with `Content-Type: application/json`. So are answers, except those with no body (204). A body of another type answers 415 [`unsupported_content_type`](/developers/conventions/errors#error-codes).

Every answer carries an `X-Request-Id` header, whatever answered it and whether or not it succeeded. Here's how the id works:

- Send your own `X-Request-Id` and Peal keeps it, as long as it's 8 to 128 characters of letters, digits, `.`, `_`, `:` and `-`. Otherwise the server issues one, a UUIDv7.
- The id is on every line the server logs for the request (`peal.request_id`), in the body of every error (`requestId`) and in the workspace's [activity log](/guides/workspace#activity).
- Log it on your side, and quote it when you ask for help.

This request sends its own id:

```bash
curl -i https://api.example.com/api/v1/channels \
  -H "Authorization: Bearer $PEAL_API_KEY" \
  -H "X-Request-Id: nightly-sync:2026-11-16:0042"
```

The answer keeps it:

```http
HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: nightly-sync:2026-11-16:0042
RateLimit-Policy: "default";q=600;w=60
RateLimit: "default";r=599;t=42
Peal-Version: 2026-11-09
```

The API only adds to what it answers ([Versioning](/developers/conventions/versioning#versioning)), so ignore the fields, values and errors your client doesn't know.

## Authentication [#authentication]

Every endpoint of the API needs a credential, sent as `Authorization: Bearer …`. The exceptions are the health checks, the changelog and the [discovery documents](/developers/conventions/discovery#discovery). A few other endpoints answer someone who isn't a member, by other means:

- the pages of a [connect link](/developers/embedding) or a [review link](/guides/posts/review), which answer the link's token;
- the platforms' data deletion callbacks, which the platform signs;
- what the web app's own pages send before anyone signs in: its error reports, the captcha's site key, the sign-in routes under `/api/auth`.

Two credentials call the API:

| Credential            | Acts as                                            | Allowed                                                                                                                     |
| --------------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| An API key, `peal_…`  | The key itself, in the one workspace it belongs to | The permissions chosen when it was created, such as `post:read` or `post:schedule` ([API keys](/guides/workspace#api-keys)) |
| An OAuth access token | The member who signed the application in           | What the member's role allows, within the scopes they granted ([What each permission allows](/developers/agents#scopes))    |

The web app's session cookie is for the web app only. A request whose credential in `Authorization: Bearer …` is refused gets a 401, whatever else it carries. Peal never falls back to a session cookie sent with it. [Authentication](/developers#authentication), in the overview, describes each credential.

Each endpoint's reference names the permission it needs. An OAuth token also needs the scope that carries it:

| Scope               | Needed for                                                                                                                                           |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `workspace:read`    | Reading                                                                                                                                              |
| `workspace:write`   | Changing something                                                                                                                                   |
| `workspace:publish` | Whatever needs `post:schedule`                                                                                                                       |
| `workspace:ads`     | What reaches an ad network: beside `workspace:write` for `ads:manage`, beside `workspace:publish` for `ads:spend` ([Ads](/guides/engage/ads#access)) |

Every authorization names the resource it is for, the API or the MCP endpoint. A grant without one gets no token (`invalid_target`): Peal isn't an identity provider for other applications.

When the credential doesn't get through, you'll see one of these:

| Status | Code                 | When                                                                                                                        |
| ------ | -------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| 400    | `workspace_required` | The request names no workspace, and the credential belongs to none ([The workspace of a request](#workspace)).              |
| 401    | `unauthenticated`    | No credential, or one that no longer works: a key revoked or expired, or a token past its time.                             |
| 403    | `forbidden`          | The credential works but doesn't allow the request. `reason` says why ([Errors](/developers/conventions/errors#forbidden)). |
| 404    | `not_found`          | No such resource, or a workspace the caller doesn't belong to.                                                              |

## The workspace of a request [#workspace]

A workspace's endpoints are under `/api/v1`, and their paths don't name the workspace. Each request acts in one workspace, decided in this order:

1. The workspace whose id the `Peal-Workspace` header gives, when the request sends one.
2. Otherwise, the workspace the credential belongs to: an API key's, or the one an application's OAuth token is bound to, as an MCP client's is.
3. Otherwise none, and the API answers 400 `workspace_required` without doing anything.

| Credential                          | Without `Peal-Workspace` | With `Peal-Workspace`                                                     |
| ----------------------------------- | ------------------------ | ------------------------------------------------------------------------- |
| An API key                          | Its own workspace        | Its own workspace. Another one answers 403 `forbidden` (`wrongWorkspace`) |
| An application bound to a workspace | That workspace           | That workspace. Another one answers 403 `forbidden` (`wrongWorkspace`)    |
| The command line's sign-in          | 400 `workspace_required` | Any workspace its user belongs to                                         |
| A partner key                       | 400 `workspace_required` | Any workspace its partner account owns                                    |
| The web app's session               | 400 `workspace_required` | Any workspace its user belongs to                                         |

The header is optional for an API key, so its first call is `POST /api/v1/posts` with the key and nothing else. A workspace the caller doesn't belong to answers 404 `workspace_not_found`, and so does a value that isn't a workspace's id. A blank header names no workspace, as if it weren't sent.

A partner key names the customer's workspace on every request inside it:

```bash
curl https://api.example.com/api/v1/channels \
  -H "Authorization: Bearer $PEAL_PARTNER_KEY" \
  -H "Peal-Workspace: 7b1f6c1e-2d4a-4f0b-9c3e-5a8d2e6f1b90"
```

The partner API keeps a workspace's id in the path where the workspace is the thing it acts on, as in `DELETE /api/v1/partner/workspaces/{workspaceId}` ([Embedding Peal](/developers/embedding#workspaces)).
