# API reference: ssh-keys

The org's SSH public keys. Any of them signs in to any of the org's machines through the gateway.

[API conventions](../api.md) explains auth, IDs, lists, errors and idempotency. The examples read the API key from `ARVM_API_KEY`.

## Operations

| Operation | Request |
|---|---|
| [Add an SSH public key](#add-an-ssh-public-key) | `POST /v1/ssh-keys` |
| [List SSH keys](#list-ssh-keys) | `GET /v1/ssh-keys` |
| [Remove an SSH key](#remove-an-ssh-key) | `DELETE /v1/ssh-keys/{ssh_key}` |

## Add an SSH public key

`POST /v1/ssh-keys`

The key signs in to every machine of the org through the gateway from now on. Adding a key the org already has is `ssh_key_exists` (409).

- Operation ID: `createSshKey`
- Auth: an API key, or the web app's session cookie
- API key scope: a full key. A read-only key is answered 403 `read_only_key`.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | no | A value the client chooses, such as a UUID. For 24 hours after a request succeeded, a request with the same key and the same body returns the first request's response instead of creating again. A request that failed leaves the key free, with one exception: a `createMachine` refused with `no_capacity` returns the same 503 until its `Retry-After` has passed, and is tried again after. The same key with a different body is `idempotency_key_reused` (409). Minimum length: `1`. Maximum length: `255`. |

**Request body**

`application/json`: [SSHKeyCreate](schemas.md#sshkeycreate)

**Responses**

| Status | Description | Body |
|---|---|---|
| 201 | The key was added. | `application/json`: [SSHKey](schemas.md#sshkey) |

Errors: `400`, `401`, `403`, `409`, `429`. [Error responses](index.md#error-responses) says what each status means.

**Example**

```console
$ curl -s -X POST "https://api.arvm.dev/v1/ssh-keys" \
    -H "Authorization: Bearer $ARVM_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{"name": "ada-laptop", "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE2xJ8Qq3mVwT0c9y7uXo4dHk1bN6fRzLs5pGaWjYvKt ada@laptop"}'
```

Response body, `application/json`:

```json
{
  "id": "sshkey_01jcz3k8x0e5v9w2r4t6y8a0bq",
  "name": "ada-laptop",
  "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE2xJ8Qq3mVwT0c9y7uXo4dHk1bN6fRzLs5pGaWjYvKt ada@laptop",
  "fingerprint": "SHA256:pL2mX8vQ4nR7sT1wY6zB3kH5jF0aGdE9cU2iO7yN4bM",
  "created_at": "2026-11-10T20:20:00Z"
}
```

## List SSH keys

`GET /v1/ssh-keys`

Newest first.

- Operation ID: `listSshKeys`
- Auth: an API key, or the web app's session cookie
- API key scope: any. A read-only key may call this.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `limit` | query | integer (int32) | no | The most items to return. Default: `50`. Minimum: `1`. Maximum: `200`. |
| `cursor` | query | string | no | The `next_cursor` of the previous page. Opaque. Maximum length: `512`. |

**Responses**

| Status | Description | Body |
|---|---|---|
| 200 | A page of SSH keys. | `application/json`: [SSHKeyList](schemas.md#sshkeylist) |

Errors: `400`, `401`, `429`. [Error responses](index.md#error-responses) says what each status means.

**Example**

```console
$ curl -s "https://api.arvm.dev/v1/ssh-keys" \
    -H "Authorization: Bearer $ARVM_API_KEY"
```

Response body, `application/json`:

```json
{
  "data": [
    {
      "id": "sshkey_01jcz3k8x0e5v9w2r4t6y8a0bq",
      "name": "ada-laptop",
      "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE2xJ8Qq3mVwT0c9y7uXo4dHk1bN6fRzLs5pGaWjYvKt ada@laptop",
      "fingerprint": "SHA256:pL2mX8vQ4nR7sT1wY6zB3kH5jF0aGdE9cU2iO7yN4bM",
      "created_at": "2026-11-10T20:20:00Z"
    }
  ],
  "next_cursor": null
}
```

## Remove an SSH key

`DELETE /v1/ssh-keys/{ssh_key}`

The key stops signing in through the gateway at once, and is removed from the machines it was installed in.

- Operation ID: `deleteSshKey`
- Auth: an API key, or the web app's session cookie
- API key scope: a full key. A read-only key is answered 403 `read_only_key`.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `ssh_key` | path | [SSHKeyID](schemas.md#sshkeyid) | yes | The SSH key's ID. |

**Responses**

| Status | Description | Body |
|---|---|---|
| 204 | Removed. |  |

Errors: `400`, `401`, `403`, `404`, `429`. [Error responses](index.md#error-responses) says what each status means.

**Example**

```console
$ curl -s -X DELETE "https://api.arvm.dev/v1/ssh-keys/sshkey_01jcz3k8x0e5v9w2r4t6y8a0bq" \
    -H "Authorization: Bearer $ARVM_API_KEY"
```
