---
title: "SSH Keys — Depfloy docs"
description: "Add, list, install and remove SSH keys through the Depfloy API."
url: "https://depfloy.com/docs/api-reference/ssh-keys"
---

# SSH Keys

SSH keys let you sign in to your servers as the `depfloy` user. A key is either yours (account-level, managed under System → SSH keys) or belongs to one server. On this page, we will dive into the endpoints you can use to manage both.

AUTH `Authorization: Bearer {API_KEY}` [Create a token →](https://depfloy.com/docs/api-keys)

## The SSH key model

A key placed on a server goes into the `depfloy` user’s `authorized_keys`, and that user has root on the server. Adding a key is therefore the same tier as opening a terminal: the two `POST` endpoints need `terminal:write` (Owner, Admin and Developer). An API token limited to specific abilities needs the `terminal:write` ability for them. The `DELETE` endpoints need `server:update` (Owner, Admin, Manager and Developer). See [SSH Keys](https://depfloy.com/docs/ssh-keys) for the same rules in the panel.

The public key you send is stored but never returned: `public_key` is not part of any response.

### Properties

id integer

Unique identifier for the key.

key\_name string

The name you gave the key.

user\_id integer

Set on an account-level key: the user it belongs to. `null` on a server key.

server\_id integer

Set on a server key: the server it belongs to. `null` on an account-level key.

fingerprint string

The key’s MD5 fingerprint.

status integer

0 = Installing, 1 = Installed, 2 = Error, 3 = Deleting, 4 = Deleted.

created\_at timestamp

When the key was added.

---

GET`/api/v1/ssh-keys`

## List your SSH keys

Returns your own account-level keys; no permission beyond a valid token is needed. Keys that belong to a single server are listed with `GET /api/v1/servers/:id/ssh-keys`, below.

GET /api/v1/ssh-keys Request

cURL

```bash
curl https://app.depfloy.com/api/v1/ssh-keys \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json"
```

Response

```json
{
  "status": "success",
  "data": [
    {
      "id": 5120,
      "key_name": "laptop",
      "user_id": 84,
      "server_id": null,
      "fingerprint": "3f:9a:1c:42:7d:e0:5b:88:21:c4:90:6e:af:13:57:d2",
      "status": 1,
      "created_at": "2026-10-23T09:12:44.000000Z"
    }
  ]
}
```

---

POST`/api/v1/ssh-keys`

## Add an SSH key

Adds an account-level key. With `add_to_all_servers`, Depfloy also queues its installation on all servers and the key starts in status 0 (Installing). Needs `terminal:write`.

### Required attributes

key\_name string

A name for the key, up to 255 characters.

public\_key string

The public key, for example the contents of `~/.ssh/id_ed25519.pub`.

### Optional attributes

add\_to\_all\_servers boolean

Install the key on all servers. Defaults to `false`.

POST /api/v1/ssh-keys Request

cURL

```bash
curl https://app.depfloy.com/api/v1/ssh-keys \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "key_name": "laptop",
    "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... you@laptop",
    "add_to_all_servers": false
  }'
```

Response (201)

```json
{
  "status": "success",
  "message": "SSH key created.",
  "data": {
    "id": 5120,
    "key_name": "laptop",
    "user_id": 84,
    "fingerprint": "3f:9a:1c:42:7d:e0:5b:88:21:c4:90:6e:af:13:57:d2",
    "status": 1,
    "created_at": "2026-10-23T09:12:44.000000Z"
  }
}
```

---

DELETE`/api/v1/ssh-keys/:id`

## Delete an SSH key

Deletes an account-level key. Needs `server:update`.

### Optional attributes

scope string

`depfloy` (default) removes the key from Depfloy; copies already installed on servers stay there. `all-servers` also removes it from all servers; the key reads status 3 (Deleting) while that runs.

DELETE /api/v1/ssh-keys/5120 Request

cURL

```bash
curl -X DELETE https://app.depfloy.com/api/v1/ssh-keys/5120 \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{ "scope": "all-servers" }'
```

Response

```json
{
  "status": "success",
  "message": "SSH key deletion processed."
}
```

---

GET`/api/v1/servers/:id/ssh-keys`

## List a server’s SSH keys

Returns the keys that belong to one server. Needs `server:read`.

GET /api/v1/servers/183009/ssh-keys Request

cURL

```bash
curl https://app.depfloy.com/api/v1/servers/183009/ssh-keys \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json"
```

Response

```json
{
  "status": "success",
  "data": [
    {
      "id": 5121,
      "key_name": "ci-runner",
      "user_id": null,
      "server_id": 183009,
      "fingerprint": "a1:07:5e:c9:32:4b:f8:6d:90:2e:17:bb:c0:48:6a:13",
      "status": 1,
      "created_at": "2026-10-23T09:20:05.000000Z"
    }
  ]
}
```

---

POST`/api/v1/servers/:id/ssh-keys`

## Add an SSH key to a server

Adds a key to one server and queues its installation. The key starts in status 0 (Installing). Needs `terminal:write`.

### Required attributes

key\_name string

A name for the key, up to 255 characters.

public\_key string

The public key.

POST /api/v1/servers/183009/ssh-keys Request

cURL

```bash
curl https://app.depfloy.com/api/v1/servers/183009/ssh-keys \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "key_name": "ci-runner",
    "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... ci@runner"
  }'
```

Response (201)

```json
{
  "status": "success",
  "message": "SSH key queued for installation.",
  "data": {
    "id": 5121,
    "key_name": "ci-runner",
    "server_id": 183009,
    "fingerprint": "a1:07:5e:c9:32:4b:f8:6d:90:2e:17:bb:c0:48:6a:13",
    "status": 0,
    "created_at": "2026-10-23T09:20:05.000000Z"
  }
}
```

---

DELETE`/api/v1/servers/:id/ssh-keys/:key`

## Remove an SSH key from a server

Deletes a server’s key from Depfloy and starts its removal from the server. Needs `server:update`.

DELETE /api/v1/servers/183009/ssh-keys/5121 Request

cURL

```bash
curl -X DELETE https://app.depfloy.com/api/v1/servers/183009/ssh-keys/5121 \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json"
```

Response

```json
{
  "status": "success",
  "message": "SSH key removal started."
}
```

---

## Errors

-   `403` — your role or the token’s abilities do not include the permission the endpoint needs.
-   `404` — the key or the server does not exist, or is outside your access.
-   `422` — validation failed, for example a missing `key_name` or a `public_key` that is not a valid public key.

See [Errors](https://depfloy.com/docs/api-reference/errors) for the response format.
