# Add an SSH key

URL: https://heaven.dev/docs/reference/ssh-keys/add
Updated: 2026-11-21

Register an SSH public key or create a token for a Computer's private website. Limit a public key to one Computer or tag if needed. To get a website-only token, name a Computer with `computer` and omit the public key. Heaven returns that token once and revokes it when you remove its key.

`POST /v1/account/ssh-key/create`

## Parameters

- `public_key` (string): SSH public key text, such as the contents of `~/.ssh/id_ed25519.pub`. To create a private website token, omit the public key and give `computer`.
- `label` (string): Label to identify the key in `ssh-key view`. A website token's key defaults to `site token`.
- `tag` (string): Limit an SSH key to Computers with this tag. Use one tag of lowercase letters, digits and hyphens. Use this field or `computer`.
- `computer` (string): Name or ID of the only Computer this key can reach. Without a public key, creates a token for that Computer's private website. Use this field or `tag`.

## Returns

- `data` (object, always present): A registered SSH key or a private-site token.
  - `alternative-1` (object): A registered SSH public key and its access restrictions.
    - `computer` (object): Single Computer this key can reach, when it is limited to one. May be omitted.
      - `id` (string, always present): Selected Computer's ID.
      - `name` (string, always present): Current name; empty during deletion or after you lose access.
    - `created_at` (string (date-time)): Time the key was added. May be omitted.
    - `fingerprint` (string, always present): Public key fingerprint.
    - `id` (string, always present): Registered key's ID.
    - `label` (string, always present): User-assigned label.
    - `last_used_at` (string (date-time) | null, always present): Last recorded SSH sign-in; null if none is recorded. Updates can take five minutes.
    - `public_key` (string, always present): SSH public key.
    - `tag` (string): Tag limiting the key to matching Computers, when set. May be omitted.
  - `alternative-2` (object): A token for a Computer's private website and the key that signed it.
    - `key` (object, always present): Registered key that signed the token.
      - `computer` (object): Single Computer this key can reach, when it is limited to one. May be omitted.
        - `id` (string, always present): Selected Computer's ID.
        - `name` (string, always present): Current name; empty during deletion or after you lose access.
      - `created_at` (string (date-time)): Time the key was added. May be omitted.
      - `fingerprint` (string, always present): Public key fingerprint.
      - `id` (string, always present): Registered key's ID.
      - `label` (string, always present): User-assigned label.
      - `last_used_at` (string (date-time) | null, always present): Last recorded SSH sign-in; null if none is recorded. Updates can take five minutes.
      - `public_key` (string, always present): SSH public key.
      - `tag` (string): Tag limiting the key to matching Computers, when set. May be omitted.
    - `site` (string, always present): Private website this token reaches.
    - `token` (string, always present): Private-site token, returned only on creation.

## Errors

Each code is explained in full at https://heaven.dev/docs/reference/errors.

| Code | Status | What happened |
|---|---:|---|
| `invalid` | 400 | An input is missing or invalid. |
| `unauthenticated` | 401 | The credential is missing, invalid, expired or revoked. |
| `denied` | 403 | The caller lacks permission for this action. |
| `not_found` | 404 | The resource is absent or inaccessible to this caller. |
| `conflict` | 409 | The request conflicts with the current resource state or an earlier request. |
| `over_capacity` | 409 | The request exceeds a resource or credential allowance. |
| `access_list_full` | 409 | The change would exceed the access-list allowance. |
| `payment_required` | 402 | Payment or credit is required. |
| `rate_limited` | 429 | The caller's request rate exceeds its limit. |
| `busy` | 429 | Too much work is in progress to accept this request. |
| `unknown` | 503 | The outcome is unconfirmed; a change may have happened. |
| `unavailable` | 503 | The service or requested feature is unavailable. |

## Notes

- Requires the dashboard or management SSH with a registered key.
- A key limited to a command list cannot run this command.

## Examples

```sh
ssh cli@heaven.dev ssh-key add [PUBLIC-KEY]
  [--label LABEL]
  [--tag TAG]
  [--computer COMPUTER]
```

Response:

```json title="Response excerpt"
{
  "version": 1,
  "data": {
    "created_at": "2026-11-16T12:00:00Z",
    "fingerprint": "SHA256:I4GjSM66YVvGIhz6Aiu9D3WxtXAwFPScB79NYkQI2Uw",
    "id": "f7b888e3-5211-4fab-a0bc-6f75ca06312a",
    "label": "laptop",
    "last_used_at": null,
    "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG3yNzhZuzE1qsy47PhC/f+Kls+8J8j4OxebqeotQL8G"
  }
}
```
