# API keys and scopes

Source: https://docs.autessa.com/docs/start/api-keys

> How Autessa API keys work: company-scoped product APIs that any key can call, resource-scoped table, Drive, and agent APIs, extra permissions, and deploy keys.

# API keys and scopes

What a call needs from the key depends on the kind of API. Using one of the libraries? [Keys](/docs/start/keys.md) lists which key each package needs.

## Get a key

- **Fastest:** [Get a free API key](https://builder.autessa.com/get-api-key). One click. Includes $100 of free credits for your first month, no card needed.
- **In the Builder:** **Developer → API keys → Create API Key**. Use this when you want to pick scopes, limits, and allowed origins. See [API Keys](/docs/guide/api-management/api-keys.md).

Send the key in the `Authorization` header, with no `Bearer` prefix:

```bash
curl https://api.autessa.com/clients/aaf/dashboard -H "Authorization: $AUTESSA_API_KEY"
```

Keep keys on your server. Never put a key in browser or mobile code.

## Two kinds of API

| Kind | APIs | What the key needs |
| --- | --- | --- |
| **Company-scoped** | SecurePass, AI Application Firewall, Evaluations, Synthetic data, Agent tools, Phone | Any enabled key from your company. No `resourceId`. Results belong to your company. |
| **Resource-scoped** | AutessaDB tables, Drive, Agents, Tools | A key that can reach that table, drive, agent, or tool. Send its ID as `?resourceId=`. |

**Company-scoped APIs** are products you call directly. A key's resource scope (the tools, agents, and tables you pick when you create it) does not limit them. Every enabled key from your company can call them. Their usage is billed to your company.

**Resource-scoped APIs** run things you keep in Autessa. The key must include the resource, and the call names it. A developer key from Get a free API key includes every resource you can open:

```bash
curl -X POST "https://api.autessa.com/clients/autessadb-drive/search?resourceId=V1StGXR8Z5" \
  -H "Authorization: $AUTESSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"tableId": "V1StGXR8Z5", "query": "refund policy"}'
```

The `resourceId` must match the table or agent ID in the body.

## Extra permissions

A few calls need a permission turned on for the key:

| Permission | Needed for |
| --- | --- |
| **Word of the day** | `GET /clients/aaf/word-of-day`. Only give it to keys that show the word to your own staff. |
| **Phone numbers** (`PHONE_MANAGE`) (Preview) | Buying numbers with `POST /clients/phone/numbers/purchase`. Company admins only. |
| **Run agents locally** (`AGENT_MODEL_TURN`) (Preview) | Running a project's agents on your machine with Autessa's models (`chat` in the [Autessa CDK](/docs/cdk/agents.md)). Only a company admin can give a key this permission. |

A key without a needed permission gets `403`.

## Deploy keys (Preview)

The [Autessa CDK](/docs/cdk.md) uses a separate **deploy key**, created in **Settings → Deploy keys**. A deploy key belongs to one company (tenant) and carries deploy scopes: `DEPLOY_DIFF`, `DEPLOY_APPLY`, `DEPLOY_PULL`, `DEPLOY_ROLLBACK`, `MODEL_TURN` for local agent chats, and `HARNESS_CHAT` for chatting with a project's agents in the tenant. Company admins create, rotate and revoke them, in the web app or with [`autessa deploy-keys`](/docs/cli/api-access.md#deploy-keys). Store one per stage, for example `AUTESSA_DEPLOY_KEY_DEV` and `AUTESSA_DEPLOY_KEY_PROD`.

## When a call is refused

| Status | Usually means |
| --- | --- |
| `401` | The key is wrong or disabled, or (on table, Drive, and agent paths) the key can't reach that `resourceId`. |
| `403` | The key is valid but lacks a permission. |
| `400` with `errors` | On a table: the key lacks READ or WRITE on it. |
| `429` | Rate limit. Wait for `Retry-After`, then retry. |

Each key has its own rate limits (60 requests per minute and 5,000 per day by default). Change them in **Developer → API keys**.

## Related

- [Keys: which key for each package](/docs/start/keys.md)
- [Start here](/docs/start.md)
- [API Keys guide](/docs/guide/api-management/api-keys.md)
- [Authentication](/docs/guide/authentication.md)
- [API reference](/docs/reference.md)

