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

> Scoped API keys — client.keys, and where the secret appears.

Six methods. All of them need the `admin` scope: a key granted `admin`, or the session of an owner or admin. Anything else is `403 forbidden`. API detail: [Authentication](https://vetta.sh/docs/api/authentication.md).

> [!WARNING]
>
> Only `create` and `rotate` ever answer a `secret`. Store it then; `list` never returns one.

## create

```ts theme={"system"}
client.keys.create(body: { name: string; scopes?: Scope[]; preset?: "full" | "tools" | "tools_resources" | "read"; description?: string; expiresAt?: string | Date | null; budget?: { usd?: number; capMicroUsd?: number; period: "day" | "month" | "total" } | null }): Promise<MintedKey>
```

`POST /v1/api_keys`. The reply is the key **plus** `secret`, `org_id`, and `mode` (`test | live`) — the only response shape that carries them. A key can only mint another key in its own mode. `scopes` alone works exactly as before; `preset`, `expiresAt` and `budget` are optional (developer workspaces default to a 90-day expiry and a \$20-a-day budget). See [Keys](https://vetta.sh/docs/developers/keys.md).

## list

```ts theme={"system"}
client.keys.list(query?: ListQuery): Promise<Page<ApiKey>>
```

`GET /v1/api_keys` — name, `prefix`, scopes, `created_by`; never a secret. Newer fields (`grants`, `preset`, `description`, `expires_at`, `budget`, `created_via`) are present when the API sends them.

## get

```ts theme={"system"}
client.keys.get(id: string): Promise<ApiKey>
```

`GET /v1/api_keys/{id}`. One key, with `spent_micro_usd`, `calls_24h` and `pending_approvals`.

## update

```ts theme={"system"}
client.keys.update(id: string, patch: { name?: string; description?: string; scopes?: Scope[]; preset?: string; expiresAt?: string | Date | null; budget?: object | null }): Promise<ApiKey>
```

`PATCH /v1/api_keys/{id}`. A key may only narrow another key; widening needs a person's session.

## rotate

```ts theme={"system"}
client.keys.rotate(id: string, options?: { graceSeconds?: number }): Promise<MintedKey>
```

`POST /v1/api_keys/{id}/rotate`. Mints a replacement secret under the same id; the reply carries it once. `graceSeconds` (up to 604800) keeps the old secret working that long; the default `0` ends it at once, as before.

## revoke

```ts theme={"system"}
client.keys.revoke(id: string): Promise<Deleted>
```

`DELETE /v1/api_keys/{id}`. Immediate — the next request on the old secret is a `401`.


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