# Personal access tokens

Source: https://cubibase.com/docs/platform/access-tokens

Also available: [Markdown version](https://cubibase.com/docs/platform/access-tokens.md) · [llms.txt](https://cubibase.com/llms.txt) · [full site content](https://cubibase.com/llms-full.txt)

Personal access tokens (cb_pat_…) authenticate the Control API without an interactive login — for scripts, CI, and AI agents. Create them in Console → Account → Access tokens.

## What a token is

A personal access token (PAT) is a developer credential for the Control API at api.cubibase.com. It carries the permissions of the account that created it, narrowed by a scope and an optional project restriction. Tokens are shown once at creation and stored only as SHA-256 hashes.

| Scope | Allows |
| --- | --- |
| read | GET routes: list projects, schema, rows, logs, usage |
| write | Everything in read, plus creating and modifying projects, tables, policies, keys |
| admin | Everything in write, plus destructive operations such as project deletion |

Scopes are cumulative: write includes read, admin includes write. A token can also be restricted to a single project, and can carry an expiration date.

## Creating and using a token

1. **Open the Console** — Account → Access tokens → Create token. Pick a name, scope, optional project restriction and expiry.
2. **Copy the token** — The cb_pat_… value is shown exactly once. Store it in a secret manager or environment variable.
3. **Call the Control API** — Send Authorization: Bearer cb_pat_… on any api.cubibase.com route within the token’s scope.

**List projects with a PAT**

```bash
curl https://api.cubibase.com/v1/projects \
  -H "Authorization: Bearer cb_pat_…"
```

> **note**: Tokens cannot manage other tokens: the /v1/auth/tokens routes require an interactive session. This prevents a leaked token from minting new credentials.

## Rate limits and revocation

- Token requests are rate-limited per token. A throttled request returns 429 with a Retry-After header — wait that many seconds and retry.
- Revoke a token from the same Console page; requests using it fail immediately with 401.
- Every token records a last-used timestamp so you can find and revoke stale credentials.
- Errors always carry a stable machine code and a requestId, e.g. {"error":{"code":"insufficient_scope","message":"…","requestId":"…"}}.

## Additional resources

- [Using CubiBase with AI agents](https://cubibase.com/docs/agents) MCP server, CLI, and the agent workflow built on these tokens.
- [API keys](https://cubibase.com/docs/platform/api-keys) The project-level keys for the Data API.
