> ## 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.

# Authentication

> Organization-scoped API keys and the Bearer scheme.

The Naive Managed Agents API authenticates with **organization-scoped API keys**. Every key belongs to a single [organization](https://vetta.sh/docs/api/organizations.md) and can act only on that org's resources and credit balance.

## The Bearer scheme

Send your key in the `Authorization` header on every request:

```bash theme={"system"}
Authorization: Bearer sk_live_...
```

A missing or invalid key returns `401 unauthorized`. A valid key acting outside its scopes returns `403 forbidden`.

> [!WARNING]
>
> Live keys are prefixed `sk_live_` and are shown **once** at creation. Store them in a secret manager — they cannot be retrieved again, only rotated.

## Scopes

Keys carry scopes that limit what they can do. Scopes follow a `resource:action` grammar (e.g. `agents:write`, `sessions:read`). Every key names at least one; grant `admin` for full access to the organization.

The last three rows are newer **grants**. A key's `scopes` field lists only the original scopes, so older clients keep parsing it; the full list, including grants, is in `grants`. Keys can also be made from a preset (`tools`, `tools_resources`, `read`, `full`) with an expiry and a budget — see [Keys](https://vetta.sh/docs/developers/keys.md).

| Scope | Grants |
| - | - |
| `agents:read` / `agents:write` | Read or manage [agents](https://vetta.sh/docs/api/agents.md). |
| `sessions:read` / `sessions:write` | Read or run [sessions](https://vetta.sh/docs/api/sessions.md). |
| `computers:write` | Manage [computers](https://vetta.sh/docs/api/computers.md), and read what commands run on them printed ([command history](https://vetta.sh/docs/api/computers.md#command-history)). |
| `proxy:write` | Call the [model proxy](https://vetta.sh/docs/api/proxy.md) and [choose a model](https://vetta.sh/docs/api/models.md#choose-a-model-for-a-conversation) for it — nothing else. |
| `files:read` / `files:write` | Read or upload [files](https://vetta.sh/docs/api/files.md). |
| `billing:read` / `billing:write` | Read the [credits](https://vetta.sh/docs/api/credits.md) balance and ledger / charge a payment method to top up. |
| `webhooks:*` | Manage [webhook endpoints](https://vetta.sh/docs/api/webhooks.md), rotate secrets, and read delivery logs. |
| `tools:read` / `tools:run` | Search the [tool catalog](https://vetta.sh/docs/developers/tools.md), read runs and logs / run tools. |
| `resources:read` / `resources:write` | The unified [resource](https://vetta.sh/docs/developers/resources.md) reads / each resource type's existing write routes (not money or verification routes). |
| `approvals:read` | List, read and wait on [approvals](https://vetta.sh/docs/developers/approvals.md). Deciding is for people only. |
| `audit:read` | Read the [audit log](https://vetta.sh/docs/api/audit-logs.md). |
| `admin` | Manage members, keys, and organization settings. |

> [!NOTE]
>
> `proxy:write` is deliberately narrow. The proxy routes accept it **or** `sessions:write`, so a key that reaches them today keeps working — but a credential that holds only `proxy:write` can make model calls and cannot start, cancel or read sessions. That is what makes it safe to hand to a sandbox: a harness that runs as a process inside a micro-VM needs a credential to reach the door, and one that leaked should not be able to run sessions for your organization.
>
> `webhooks:*` is one scope, spelled with the star: it is the only webhook scope, and it covers both reading and managing endpoints. `billing:write` gates the card-charging top-up endpoint and is deliberately separate from read-only `billing:read`.

## Who is this credential?

`GET /v1/me` answers from the credential alone — no scope, no organization id in the request. It is
the first call any client should make, and it is how the CLI and the dashboard learn which
organization a key belongs to instead of asking you to paste an `org_` id you have no way to look
up.

```json Response theme={"system"}
{
  "object": "identity",
  "principal": { "type": "key", "id": "key_01H8AA..." },
  "organization": { "id": "org_01H8AA...", "name": "Acme", "mode": "live" },
  "scopes": ["admin"],
  "user": null
}
```

`organization` is `null` only for a signed-in person who does not belong to one yet; `user` is
`null` whenever the caller is an API key rather than a person.

`GET /v1/organizations` is the list form. An API key reaches exactly the one organization it is
bound to — a one-row page, never another tenant's row. A signed-in person reaches every
organization they are a member of. Cursor-paginated, see [Pagination](https://vetta.sh/docs/api/pagination.md).

## Signing a person in

A **person** authenticates with an email address and the 6-digit code mailed to it (or, for an
account that set one, a password) and receives a short-lived bearer session token prefixed `vt_`. It is accepted anywhere an `sk_` key is, on the same
`Authorization: Bearer` header, and its scopes are derived from the member's role.

```bash theme={"system"}
POST /v1/auth/session
```

**email** `string`

The account's email address. Required with `code` or `password` when signing in fresh; omitted when re-scoping an existing `vt_` token.

**code** `string`

The 6-digit code mailed to `email` at sign-up, or by [Resend](#codes-and-passwords). Single use. Typing it proves the address.

**password** `string`

The account's password, if it set one through Naive. Paired with `email`. A password set anywhere else signs nobody in.

**provider\_token** `string`

The access token an external provider sign-in came back with. Verified against the provider on every call, and then refused unless it came from an external sign-in (Google), not a password. Used instead of `email`/`code`.

**organization\_id** `string`

The organization to scope the session to. With an existing `vt_` token this re-scopes the session — the org switcher. Must be an organization the person belongs to.

```json Request theme={"system"}
{ "email": "ada@acme.test", "code": "123456" }
```

```json Response theme={"system"}
{
  "object": "auth_session",
  "token": "vt_...",
  "expires_at": "2026-08-22T09:00:00Z",
  "organization": { "id": "org_01H8AA...", "name": "Acme", "mode": "live" }
}
```

Presenting an existing `vt_` token to the same route with an `organization_id` re-scopes the session
to another organization you belong to — that is what an organization switcher is. Passing an
`organization_id` you are not a member of returns `404 not_found`. The new token keeps the presented
token's `expires_at`: re-scoping never extends a session. Sign in again to start a new 30 days.

### Signing in with Google

The dashboard offers "Continue with Google" wherever the deployment has the provider turned on. It
is the same route and the same session at the end of it: the provider hands back an access token,
and that token is exchanged for a `vt_`.

```json Request theme={"system"}
{ "provider_token": "..." }
```

The token is **verified against the provider on every call** — it is never decoded or taken at face
value, so a forged, expired or revoked one is `401 unauthorized`, phrased exactly as a wrong
code is.

Two things are worth knowing before you build against it:

* **The address must be one your provider has verified.** You are matched to your organizations by
  email address, so an unverified address is refused rather than signed in. Google verifies the
  addresses it asserts, so this is invisible in practice.
* **It signs you in; it does not enrol you.** Signing in with Google as somebody who belongs to no
  organization gives you the same session a code sign-in would: `organization_id: null`, no
  scopes, and the choice of joining one or creating one. Your role and scopes always come from your
  membership — never from how you signed in, and never from anything the caller asks for.

`POST /v1/auth/users` registers a person. It takes an email and nothing else: no password exists
until the address is proved, so nobody can set one on an address they do not own.

**email** `string` *required*

The address to register. A new dashboard account is mailed nothing yet; a taken address, or an app's new account, is mailed a 6-digit code.

**return\_to** `string`

Which app the account was made in: `creator` or `doomscroll`. Omitted, it is the dashboard.

```json Request theme={"system"}
{ "email": "ada@acme.test" }
```

```json Response theme={"system"}
{
  "object": "auth_user",
  "email": "ada@acme.test",
  "confirmation_required": true,
  "session": { "object": "auth_session", "token": "vt_...", "organization_id": null }
}
```

A new dashboard account is in at once: `session` is a `vt_` that can set up a company but cannot pay
or act outward until the code is typed. Those routes answer `403 email_unconfirmed` until then. Sign
in with `{ "email", "code" }` on `POST /v1/auth/session`, presenting that `vt_` as the bearer, and the
company it started is proved with it. A code typed on another device signs that device in and leaves
this session alone: it keeps only its own company, still cannot spend, and is proved when a code is
typed beside it.

A taken address gets no `session`, only a code to sign in with. An app that names `return_to` gets
no `session` either: its person signs in with the code.

More than five registrations of one address in a minute, or 20 an hour from one caller, answer
`429 rate_limited`. A new dashboard account gets its code at the first spend, from
`POST /v1/auth/confirmations`, so it is fresh when typed. A registration that mails a code counts against
the code limits below.

> [!NOTE]
>
> Session tokens are for interactive clients. Machine-to-machine callers should hold a scoped API key:
> a token expires and a key does not.

## Codes and passwords

`POST /v1/auth/confirmations` mails a new 6-digit sign-in code (Resend, and "Email me a code"). It
works for every account, with or without a password.

**email** `string` *required*

The address to mail the code to.

It answers `202` with the same body, at the same speed, **whether or not that address has an
account**, and refuses alike at the limits. An endpoint that answered differently would be a way to
discover who your users are. Do not branch on it; there is nothing to branch on.

```json Response theme={"system"}
{ "object": "auth_confirmation", "delivery": "sent" }
```

Limits on codes:

* At most 5 codes an hour for one address from one caller, 20 an hour for one address from everyone,
  and 10 an hour from one caller.
* One budget of codes an hour for the whole deployment, set below the mail provider's own limit. Only a
  mail that went counts. Past it, every send answers `429` with "Too many sign-ins right now. Try again
  in a few minutes."
* A code is checked at most 5 times. After that it is dead, even the right one; mail a new code.
* Checks are also capped at 5 a minute, 20 an hour and 50 a day per address and caller, at 100 an hour
  and 200 a day per address from everyone, and at 60 an hour per caller.
* Password sign-ins are capped at 5 a minute and 20 an hour per address and caller.

There is no password reset by mailed link. A person who forgot a password signs in with a code,
then sets a new one.

`POST /v1/auth/password` sets a password for the signed-in person (the bearer). A session whose
address is not proved yet is refused with `403 email_unconfirmed`.

**password** `string` *required*

The new password. At least 8 characters.

```json Request theme={"system"}
{ "password": "..." }
```

It answers `200` with `{ "object": "auth_password", "updated": true }`. Any other field is `400`.

## Create an API key

`POST /v1/api_keys` → `201 Created`. Creates a new key for the caller's organization. The plaintext `secret` is returned only in this response.

**name** `string` *required*

Human-readable label for the key.

**scopes** `string[]`

Scopes to grant. At least one; `admin` for full org access. Required unless you send a `preset` instead (see [Keys](https://vetta.sh/docs/developers/keys.md)); a request with only `name` and `scopes` behaves exactly as before.

```bash cURL theme={"system"}
curl -fsSL https://api.vetta.sh/v1/api_keys \
  -H "authorization: Bearer sk_live_..." \
  -H "content-type: application/json" \
  -H "idempotency-key: $(uuidgen)" \
  -d '{ "name": "ci", "scopes": ["agents:write", "sessions:write"] }'
```

**id** `string`

The key id (e.g. `key_01H...`).

**name** `string`

The label you supplied.

**secret** `string`

The plaintext key. Returned only once.

**scopes** `string[]`

Granted scopes.

**prefix** `string`

The non-secret prefix, shown in listings for identification.

**created\_by** `object`

The principal that created this key — `{ "type": "user" | "key" | "system", "id": "..." }`, the same shape the [audit log](https://vetta.sh/docs/api/audit-logs.md) records.

**last\_used\_at** `string | null`

When the key was last used to authenticate a request, to within about a minute; `null` until first use.

**created\_at** `string`

Creation timestamp.

**org\_id** `string`

The organization this key opens. Returned only at create and rotate.

**mode** `string`

`live` or `test` — the tier the key spends on. Returned only at create and rotate.

```json Response theme={"system"}
{
  "id": "key_01H8XK2M...",
  "object": "api_key",
  "name": "ci",
  "secret": "sk_live_9f2c...redacted",
  "prefix": "sk_live_9f2c",
  "scopes": ["agents:write", "sessions:write"],
  "created_by": { "type": "user", "id": "usr_01H8AA..." },
  "last_used_at": null,
  "created_at": "2026-08-20T17:00:00Z",
  "org_id": "org_01H8A0...",
  "mode": "live"
}
```

## List API keys

`GET /v1/api_keys` returns key metadata (never the secret). Cursor-paginated — see [Pagination](https://vetta.sh/docs/api/pagination.md).

```json Response theme={"system"}
{
  "data": [
    { "id": "key_01H...", "name": "ci", "prefix": "sk_live_9f2c", "scopes": ["agents:write"], "created_by": { "type": "user", "id": "usr_01H8AA..." }, "last_used_at": "2026-08-20T17:22:10Z", "created_at": "2026-08-20T17:00:00Z" }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## Rotate & revoke

Rotation issues a new secret and invalidates the old one. Revocation deletes the key immediately.

```bash theme={"system"}
POST   /v1/api_keys/{id}/rotate   # returns a new secret
DELETE /v1/api_keys/{id}          # revoke
```

> [!NOTE]
>
> Rotate on a schedule and on any suspected exposure. Because keys are org-scoped, revoking one never affects another org's access.

> [!NOTE]
>
> Key creation, rotation, and revocation are recorded in the [audit log](https://vetta.sh/docs/api/audit-logs.md) as `api_key.created`, `api_key.rotated`, and `api_key.revoked`, attributed to the acting principal.


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