# API keys

Create, read and revoke the keys that authenticate the CLI and the API, and see what each permission allows.

Source: https://slashinfra.com/docs/platform/api-keys
Last modified: 2026-11-30T16:36:19.000Z

An API key authenticates the CLI or a request to the control API and belongs to one organization. A key reaches the projects and actions it is given, and its secret is shown once.

## Create an API key

A new key starts with the member set and the whole organization unless you narrow it. The dashboard shows the secret once, in the Your new API key dialog.

### Dashboard

- Open the [API keys](https://app.slashinfra.com/keys) page. 
- Select Create API key. 
- Enter a name in Name, for example `build-agent`. The name helps you recognise the key later. 
- Choose Expires: 30 days, 90 days or 365 days. The default is 90 days. 
- Leave All projects of the organization checked under Projects, or clear it and select the projects the key may name. 
- Clear the actions the key does not need under Permissions. The form starts with the member set. 
- Select Create API key. 
- Select Copy key in Your new API key and store the secret.

> Caution
> 
> 
> 
> The secret is shown once. Copy it before you close Your new API key. The API stores only its hash, so a lost secret cannot be read again; create another key and replace it.

Neither the CLI nor an API key can create an organization key; [`POST /keys`](https://slashinfra.com/docs/api-reference/svm#runProgram) needs a browser session.

## List API keys

The list shows each key’s name, project scope, permission count, key prefix, creation time and expiry. An expired key stays in the list until its row is swept.

### Dashboard

- Open the [API keys](https://app.slashinfra.com/keys) page. 
- Read the Name, Scope, Permissions, Key, Created and Expires columns. Expires shows Expired after the time.

A member holds `apikey:write` but not `apikey:read`, so a member cannot list the organization’s keys.

## Read the key of a request

`si login` saves a device key for the CLI, and `si auth whoami` prints the organization, key name and user email of the saved key. [`GET /whoami`](https://slashinfra.com/docs/api-reference/control/keys#getWhoami) returns the same fields for any key.

### CLI

```bash
si auth whoami
```

Output

```text
org:   Acme Inc.
key:   cli laptop
email: jenny@example.com
```

### curl

```bash
curl -sS "https://api.slashinfra.com/whoami" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
{"org":"org_2fH7kLmN9pQrSt","org_name":"Acme Inc.","key_name":"cli laptop","email":"jenny@example.com","expires_at":"2026-12-28T01:39:32.569Z"}
```

### Python

```python
import os, requests

res = requests.get(
"https://api.slashinfra.com/whoami",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
data = res.json()
print(data["org_name"], data["key_name"], data["expires_at"])
```

Output

```text
Acme Inc. cli laptop 2026-12-28T01:39:32.569Z
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/whoami', {
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
const data = (await res.json()) as { org_name: string; key_name: string | null; expires_at: string }
console.log(data.org_name, data.key_name, data.expires_at)
```

Output

```text
Acme Inc. cli laptop 2026-12-28T01:39:32.569Z
```

A device key belongs to the user who approved `si login`. It lasts 30 days, shows that user’s email, and carries their role and the key’s own actions. An organization key belongs to the organization, has no email, and keeps the name the dashboard gave it. `si login --key-stdin` saves an existing key instead of starting the device flow.

| Field | Type | What it is |
| --- | --- | --- |   
| `org` | string | The id of the organization of the key. | 
| `org_name` | string | The display name of the organization. | 
| `key_name` | string or null | `cli <host>` for a device key, the dashboard name for an organization key, or `null` when the key has no name. | 
| `email` | string or null | The email address of the device key owner, or `null` for an organization key. | 
| `expires_at` | string | When the key expires, as an ISO 8601 UTC timestamp. |

## Revoke a key

Revoking a key stops it within 30 seconds and leaves every resource it created. The CLI revokes the saved device key, the API revokes the key in the request, and the dashboard deletes an organization key.

### Dashboard

- Open the [API keys](https://app.slashinfra.com/keys) page. 
- Select More actions in the key’s row. 
- Select Delete. The dashboard waits 5 seconds and offers Undo; select Undo to keep the key. After that, the key is deleted.

To revoke the key in a request, send [`DELETE /keys/current`](https://slashinfra.com/docs/api-reference/control/keys#deleteKeysCurrent) with that key. The API answers `204`, and the gateway rejects the key within 30 seconds. `si auth logout` does the same for the saved device key and removes it from your laptop.

A member can delete only a key it created. Another key answers `404 key_not_found`.

## Key expiry

A key stops verifying at its `expires_at`. A request after that answers `401 key_expired`; an unknown or revoked key answers `401 unauthorized`. The dashboard shows Expired in the list.

An organization key lives 1 to 365 days; the dashboard offers 30, 90 or 365, and 90 is the default. A device key from `si login` lives 30 days. Create the replacement before the old key expires, because a key’s permissions and project scope are fixed when it is created.

## Key actions

An owner and an admin hold every action. A member holds the actions marked All roles. A key without `permissions.actions` gets the member set.

| Action | What it allows | Roles |
| --- | --- | --- |   
| `svm:read` | Read VMs, their ports, SSH keys, inbox, agent sessions and push subscriptions. | All roles | 
| `svm:write` | Create, change, start, stop, pause or wake a VM; open, close or rotate a port; mint or end a grant; change its inbox; add or remove an SSH key. | All roles | 
| `svm:delete` | Delete a VM and its disk. | All roles | 
| `svm:exec` | Run a command in a VM and fire a schedule now. | All roles | 
| `snapshot:read` | List and read snapshots. | All roles | 
| `snapshot:write` | Take or rename a snapshot. | All roles | 
| `snapshot:delete` | Delete a snapshot that no VM uses. | All roles | 
| `secret:read` | List and read secrets and provider connections. | All roles | 
| `secret:write` | Create or replace a secret, change its description, or connect a provider account. | All roles | 
| `secret:delete` | Delete a secret or a provider connection. | All roles | 
| `secret:use` | Use a secret in a VM or profile. No control route checks this action; a VM or profile that names a secret needs `svm:write` or `profile:write`. | All roles | 
| `profile:read` | List and read profiles. | All roles | 
| `profile:write` | Create or change a profile. | All roles | 
| `profile:delete` | Delete a profile. | All roles | 
| `schedule:read` | List and read schedules and their runs. | All roles | 
| `schedule:write` | Create or change a schedule. | All roles | 
| `schedule:delete` | Delete a schedule and its run history. | All roles | 
| `database:read` | List and read databases, branches and backups. | All roles | 
| `database:write` | Create a database, a branch or a backup, and set a branch password. | All roles | 
| `database:delete` | Delete a database or a branch. | All roles | 
| `project:read` | List and read projects. | All roles | 
| `project:write` | Create or rename a project. | Owner and admin | 
| `project:delete` | Delete an empty project. | Owner and admin | 
| `pool:read` | List and read pools and their join tokens. | All roles | 
| `pool:write` | Create or change a pool, set the default pool, or delete a join token. | Owner and admin | 
| `pool:delete` | Delete a pool. | Owner and admin | 
| `node:read` | List nodes and their status. | All roles | 
| `node:write` | Set a node to draining. | Owner and admin | 
| `node:delete` | Revoke a node. | Owner and admin | 
| `node:enroll` | Mint a node join token. | Owner and admin | 
| `storage:read` | List and read storage connections. | All roles | 
| `storage:write` | Connect storage or rotate its key. | Owner and admin | 
| `storage:delete` | Delete a storage connection. | Owner and admin | 
| `apikey:read` | List the organization’s API keys from a browser session. | Owner and admin | 
| `apikey:write` | Create or delete an API key from a browser session. | All roles | 
| `member:read` | Read the members of the organization. | Owner and admin | 
| `member:write` | Change a member’s role. | Owner and admin | 
| `member:delete` | Remove a member. | Owner and admin | 
| `audit:read` | Read the audit log. | Owner and admin | 
| `usage:read` | Read usage and the plan. | All roles |

`member` actions guard the organization endpoints of Better Auth, not a control route. No control route checks `secret:use`; the routes check `svm:write` or `profile:write` when a VM or profile names a secret.

## Options

| Field | Type | Default | Allowed values | What it changes |
| --- | --- | --- | --- | --- |   
| `name` (`Name`) | string | `org key` in the API; the dashboard requires one | Any text | A label in the list. It does not authenticate anything. | 
| `expires_in_days` (`Expires`) | integer | 90 | 1 to 365; the dashboard offers 30, 90 and 365 | When the key stops verifying. A request after it answers `401 key_expired`. | 
| `permissions.projects` (`Projects`) | string or array | `*` | `*`, or project names or `proj_` ids that the creator can name | The projects the key may name. Another project answers `404 project_not_found`. | 
| `permissions.actions` (`Permissions`) | array | The member set | Any action in Key actions; the creator must hold it | What the key may do. An action the creator does not hold answers `403 permission_not_grantable`. | 
| `id` (path) | string | Required | A key id | The organization key that delete acts on. |

## Errors

| Code | When | Fix |
| --- | --- | --- |   
| [`invalid_expires_in_days`](https://slashinfra.com/docs/reference/errors#invalid_expires_in_days) | Create sends an expiry that is not an integer, or outside 1 to 365 days. | Send an integer from 1 to 365. | 
| [`invalid_permission`](https://slashinfra.com/docs/reference/errors#invalid_permission) | Create names an action that is not in Key actions. | Use an action from the table. | 
| [`permission_not_grantable`](https://slashinfra.com/docs/reference/errors#permission_not_grantable) | Create grants an action that the creator does not hold. | Remove it, or create the key from a session that holds it. | 
| [`project_not_found`](https://slashinfra.com/docs/reference/errors#project_not_found) | Create names an unknown project, or one outside the creator’s scope. | Use a project in the creator’s scope. | 
| [`key_not_found`](https://slashinfra.com/docs/reference/errors#key_not_found) | Delete names no key in the organization, or a member names another member’s key. | Use an existing key id, or one the member created. |

Errors that any request can return are in the [error catalog](https://slashinfra.com/docs/reference/errors).

## Permissions

| Operation | Who can | Key action |
| --- | --- | --- |   
| Create an API key | Any member | `apikey:write` | 
| List API keys | Owner or admin | `apikey:read` | 
| Get the key of a request | Any key holder | None | 
| Revoke the key of a request | Any key holder | None | 
| Delete an organization key | Owner or admin; a member for a key it created | `apikey:write` |

## Limits

- An organization key lives 1 to 365 days; the dashboard offers 30, 90 and 365, and 90 is the default. 
- A device key from `si login` lives 30 days. 
- A key without `permissions.actions` gets the member set; a key without `permissions.projects` gets the whole organization. 
- A revoked key stops working within 30 seconds. 
- A key’s permissions and project scope are fixed when it is created; delete it and create another to change them. 
- A key limited to projects cannot name another; the other answers `404 project_not_found`. 
- A member can create a key and delete one it created; another key answers `404 key_not_found`.

The full list is in [Limits](https://slashinfra.com/docs/reference/limits).

## Next

- [Who can reach your VM](https://slashinfra.com/docs/how/access): roles, grants and the project scope of a key. 
- [Control API keys](https://slashinfra.com/docs/api-reference/control/keys#getWhoami): the whoami operation and its fields. 
- [Secrets](https://slashinfra.com/docs/platform/secrets): keep a key out of the files a VM reads.
