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

# Keys

> Scope presets, expiry, rotation with a grace window, and a spend cap on every key.

A key is how your agent calls Naive. In a developer workspace every key has a **preset** (what it may do), an
**expiry** and a **budget** (how much it may spend). Keys carry no approval rules; those live on the
[identity](https://vetta.sh/docs/developers/identities.md#approval-rules).

Create, rotate and revoke keys in the console under **Connect**, or with the API below. Managing keys needs the
`admin` scope (an admin key, or a signed-in owner or admin).

## Presets

| Preset | Grants | Use it for |
| - | - | - |
| `tools` | `tools:*` | An agent that only runs tools. |
| `tools_resources` | `tools:*`, `resources:*`, `approvals:read` | An agent that also uses inboxes, domains, brokerage and other resources. The quickstart default. |
| `read` | `tools:read`, `resources:read`, `approvals:read` | Dashboards and read-only scripts. |
| `full` | every member scope, as today, plus `approvals:read`; in a developer workspace also `webhooks:*` and `billing:write` | Studio keys and anything that needs the whole API. In a developer workspace this is the only preset that can buy numbers, connect a brokerage, issue cards or form companies (within the key budget and each identity's approval rules). |

The new grants:

| Grant | Allows |
| - | - |
| `tools:read` | Search the catalog, read tools and past runs, read logs and usage. |
| `tools:run` | Run tools. |
| `resources:read` | The unified resource list and reads. |
| `resources:write` | The existing write routes of each resource type, except money and business-verification routes. |
| `approvals:read` | List, read and wait on approvals. Nobody holds an "approve" grant: deciding is for people only. |
| `x:*` | Every verb under `x`, e.g. `tools:*`. |

You can still pass explicit `scopes` instead of a preset. A key's response keeps the legacy `scopes` field (the
original 15 values only, so older SDKs parse it) and adds `grants`, the full list including the new values.

A key whose grants are only the new ones is refused on routes outside them, except `GET /v1/me`, the model list and
organization reads.

## Create a key

`POST /v1/api_keys` — scope `admin`.

**name** `string` *required*

A label, e.g. `research-agent`.

**preset** `string`

`full`, `tools`, `tools_resources` or `read`.

**scopes** `string[]`

Explicit grants instead of a preset.

**expires\_at** `string | null`

When the key stops working. Developer workspaces default to 90 days from now; `null` means never.

**budget** `object | null`

`{ cap_micro_usd, period }` with `period` one of `day`, `month`, `total`. Developer workspaces require one and default to \$20 a day.

**description** `string`

What the key is for.

```bash curl theme={"system"}
curl https://api.vetta.sh/v1/api_keys \
  -H "Authorization: Bearer $NAIVE_ADMIN_KEY" -H "Content-Type: application/json" \
  -d '{ "name": "research-agent", "preset": "tools", "expires_at": "2027-03-01T00:00:00Z",
        "budget": { "cap_micro_usd": 20000000, "period": "day" } }'
```

```ts TypeScript theme={"system"}
const key = await client.keys.create({
  name: "research-agent",
  preset: "tools",
  expiresAt: "2027-03-01T00:00:00Z", // sent as expires_at
  budget: { usd: 20, period: "day" },
});
console.log(key.secret); // shown once
```

The reply carries the `secret` once. Store it then; no read ever returns it.

## Read a key

`GET /v1/api_keys` lists keys. `GET /v1/api_keys/{id}` reads one, with `spent_micro_usd` for the current budget period,
`calls_24h` and `pending_approvals`. Each key shows `grants`, `preset`, `description`, `expires_at`, `budget`
(`{ cap_micro_usd, period, spent_micro_usd }`) and `created_via` (`developers`, `cli`, `api` or `studio`).

## Update a key

`PATCH /v1/api_keys/{id}` — scope `admin`. Change `name`, `description`, `scopes`, `preset`, `expires_at` or `budget`.
A key or MCP connection may only **narrow** a key (fewer grants, an earlier expiry, a lower budget); widening needs a
signed-in person.

## Rotate a key

`POST /v1/api_keys/{id}/rotate` — scope `admin`. Mints a new secret under the same id.

**grace\_seconds** `integer`

Keep the old secret working for this long, up to 604800 (7 days). Default `0`: the old secret stops at once, as before.

## Revoke a key

`DELETE /v1/api_keys/{id}`. The key stops working immediately.

## Budgets

A key's budget is checked before every paid call: tool runs, data and social-data runs, media, and the funded resource
actions. When the key's spend in the current period has reached its cap, the call is refused with
`402 budget_exceeded` and nothing is charged. The `day` period resets at midnight UTC; `month` on the first of the
month; `total` never.

The workspace also has a **daily cap** (default \$50 a day across all keys), changed by an owner in **Settings**. It is
checked the same way.

## From the CLI

```bash theme={"system"}
naive keys create --preset tools --expires 90d --budget-usd 20 --budget-period day
naive keys show key_01JD7P9H1K3M5P7R9T1V3X5Z7B
naive keys rotate key_01JD7P9H1K3M5P7R9T1V3X5Z7B --grace 1d
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.