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

# API authentication

> Create, name, scope, expire and revoke PostChamp API keys, and send them in the x-api-key header.

Every API call carries an API key in the `x-api-key` header. A key acts as the person who created it.

```bash
curl https://api.postchampai.com/api/v1/credits \
  -H "x-api-key: pc_live_xxx"
```

Only `x-api-key` is accepted on the public API. Browser cookies, `Authorization` headers and OAuth tokens are ignored there, and a key is not read anywhere else. The [MCP server](/mcp/authentication.md) uses a browser sign-in instead of a key.

> [!NOTE]
>
> Keys are on the Studio plan. Only owners can create, rename and revoke them. Admins and other roles see a read-only notice on the page.

## Create a key

![Settings, API keys, with one key in the list](/images/api/keys-list.png)

1. Create API key. 2. The key list: name, masked key, workspace, creator, dates. 3. Row actions: Rename and Revoke.

1) Open [Settings → API keys](https://app.postchampai.com/settings/api-keys).
2) Select **Create API key**.
3) Fill in the dialog, then select **Create key**.

![The Create API key dialog with the name Zapier typed in](/images/api/keys-create.png)

1. Name. 2. Workspace. 3. Expires. 4. Create key.

| Field | What it does |
| - | - |
| **Name** | Required, up to 60 characters. Name it after the tool that uses it, such as "Zapier" or "Weekly report script". You can rename it later. |
| **Workspace** | **All workspaces** (every workspace you can open) or one workspace. A key scoped to one workspace gets `404 not_found` for every other workspace. |
| **Expires (optional)** | A date at least a day ahead. After it the key answers `401 api_key_invalid`. |

After you select **Create key**, the full key appears once. Select **Copy** and store it in your secrets manager. It starts with `pc_live_`.

> [!WARNING]
>
> You cannot see the key again. PostChamp keeps only a SHA-256 hash, the first characters and the last four, so it cannot show the key a second time. If you lose it, revoke it and create a new one.

### Creating a key over the API

Key management is not part of the public API. Keys cannot create or list keys. The key endpoints work only with a signed-in owner session, so use the app.

## What a key can do

* **It acts as its creator.** Calls run with the creator's current role in the workspace. Viewers can read, editors and above can write. If the creator's role changes, the key follows it.
* **It uses the organization's credits.** Generation spends credits exactly as in the app. See [Rate limits](/api/rate-limits.md) for the separate request limits.
* **Client reviewers are refused.** If the creator is later made a client reviewer, calls answer `404 not_found`.
* **It stops when the creator leaves.** If the creator is removed from the organization, the key answers `401 api_key_invalid`.
* **Actions are logged.** Audit entries for scheduling record that an API key did it, with the key's prefix.

## Limits

An organization can hold up to 50 live (not revoked) keys. Creating more answers `422 too_many_api_keys`. Revoke a key you no longer use.

The **Last used** column updates at most once every 60 seconds per key.

## Rename and revoke

* **Rename:** open the row menu, select **Rename**, edit the name and save.
* **Revoke:** open the row menu, select **Revoke**, then **Revoke key**. Apps using the key stop working right away. Open job streams that used the key close within about 15 seconds. Revoking cannot be undone.

## Keep keys safe

* Keep keys on your server or in a secrets manager. Never put one in a browser app, a mobile app or a public repository.
* Use one key per tool, so you can revoke one without breaking the others.
* Scope a key to one workspace when a tool needs only that workspace, and set an expiry for temporary work.
* Rotate by creating the new key first, switching your tool, then revoking the old key.

## Key errors

| Status | Code | Reason |
| - | - | - |
| 401 | `api_key_required` | No `x-api-key` header. |
| 401 | `api_key_invalid` | Unknown, revoked or expired key, or its creator left. One answer for all cases, so keys cannot be probed. |
| 402 | `subscription_required` | The organization has no live subscription. |
| 403 | `plan_limit` | The plan has no API access. |
| 403 | `forbidden` | The creator's current role cannot do this. |
| 404 | `not_found` | The workspace is outside the key's scope, or the creator is a client reviewer. |

## Troubleshooting

> [accordion] The page says only owners can manage keys
>
> Ask an owner of the organization to create the key. Admins can open the page but not change it.

> [accordion] The page asks me to upgrade
>
> Your plan does not include API access. It is on the Studio plan.

> [accordion] There is no API keys page on a client domain
>
> On a white-label domain, keys are not available. Open the app on the main address.

> [card] [Quickstart](/api/quickstart.md)
>
> Make your first call.

> [card] [Errors](/api/errors.md)
>
> All error codes.
