# API keys and scopes

> Where to make a key, what each scope allows, and when a key stops working.

Every call to the REST API and the MCP server needs a workspace API key. Send it in the `Authorization` header:

```bash
curl https://appliflo.com/api/v1/envelopes \
  -H "Authorization: Bearer $APPLIFLO_API_KEY"
```

## Make a key

1. Open [Settings, API keys](https://appliflo.com/settings/api-keys) on appliflo.com. Only an owner or admin can make keys.
2. Choose **Create key**, give it a name, tick what it can do and pick when it expires.
3. Copy the key. It is shown once. AppliFlo keeps only a hash of it, so nobody can show it to you again.

API keys come with the [Business plan](https://dev.appliflo.com/guides/plans). On another plan, making a key is refused with `402` and the code `plan_feature`.

Keep keys on your server or in your secret store. Never put one in a web page, a mobile app or a public repository. If a key leaks, revoke it on the same page and make a new one.

## Scopes

A key can do only what its scopes allow. New keys start with **Read** and **Create drafts** ticked, so no email can go out until someone ticks **Send and void**.

| Scope | In Settings | Allows |
| --- | --- | --- |
| `read` | Read | Every list and get: documents, fields, envelopes, templates, batches, downloads. |
| `draft` | Create drafts | Upload, detect, fill and correct fields, make documents from templates, save templates. Nothing is sent. |
| `send` | Send and void | Send for signature, send templates and send to many, remind, void, and a batch's retry, cancel and row fix. |

A call outside the key's scopes gets `403`:

```json
{
  "success": false,
  "error": "insufficient_scope",
  "required_scope": "send",
  "message": "this API key needs the 'send' scope"
}
```

The MCP server checks the same scope for each tool. Each tool's page under [MCP tools](https://dev.appliflo.com/mcp/tools) says what it needs. Keys made before scopes existed have full access.

## Expiry

A key can expire in 30, 90 or 365 days, or never. After its expiry date, calls get `401` with `api_key_expired`, so your code can tell an old key from a wrong one:

```json
{ "success": false, "error": "api_key_expired" }
```

Make a new key in Settings and swap it in. A missing or wrong key gets `401` with `invalid or missing API key`.

## Who the key acts as

A key acts for its workspace. Usage is counted against the workspace, and [AI pages](https://dev.appliflo.com/guides/plans) used through the API are charged to the person who made the key. A key can delete only documents it created through the API, never a person's upload.
