Add an SSH key
POST/api/v1/ssh-keys/import
Adds a public key you already have.
Request body
| Field | Type | Description |
|---|---|---|
| key_name | string, optional | Key name (letters, digits, space, . _ -; max 64). Auto-generated if empty. |
| public_key | stringrequired | Public key in OpenSSH format (e.g., 'ssh-ed25519 AAAA... comment') |
Example request
curl -X POST "https://platform.serverscamp.com/api/v1/ssh-keys/import" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"key_name": "laptop",
"public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... me@laptop"
}'import os, requests
token = os.environ["API_TOKEN"]
r = requests.post(
f"https://platform.serverscamp.com/api/v1/ssh-keys/import",
headers={"Authorization": f"Bearer {token}"},
json={
"key_name": "laptop",
"public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... me@laptop"
},
)
r.raise_for_status()
print(r.json())const r = await fetch(`https://platform.serverscamp.com/api/v1/ssh-keys/import`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"key_name": "laptop",
"public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... me@laptop"
}),
});
console.log(r.status, await r.json());Answer
Status 201 with this body.
| Field | Type | Description |
|---|---|---|
| id | integerrequired | Key ID |
| key_name | stringrequired | Key name |
| key_type | stringrequired | Key type (ed25519, rsa, ecdsa, etc.) |
| public_key | stringrequired | Public key in OpenSSH format |
| fingerprint | stringrequired | Key fingerprint (SHA256) |
| has_private_key | booleanrequired | Whether private key is available for download |
| created_at | string, optional | Creation timestamp |
| comment | string, optional | Trailing comment from OpenSSH public key (e.g. user@host) |
| bits | integer, optional | Key strength in bits |
| source | string | 'generated' if private key is stored, else 'imported' |
| strength | string | 'modern' for ed25519/ecdsa, 'legacy' for rsa |
| state | string | 'in-use' if at least one VM trusts this key, else 'unused' |
| last_attached_at | string, optional | When the most recent VM using this key was created |
| trusted_by | list of SSHKeyTrustedVM | VMs that have this key installed |
| trusted_by[].vm_uuid | stringrequired | |
| trusted_by[].name | stringrequired |
{
"id": 42,
"key_name": "laptop",
"key_type": "ed25519",
"public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... me@laptop",
"fingerprint": "SHA256:7Ke...",
"has_private_key": false,
"created_at": "2026-10-23T09:00:00Z"
}Errors
| Status | When |
|---|---|
400 | Not a public key in OpenSSH format |
401 | No token, or a token that is not valid |
409 | The key is already in your account |
422 | The body or a parameter is not what the operation takes |
Every operation can also answer 401 without a valid token. All errors