Skip to content

Add an SSH key

POST/v1/ssh-keys

Adds an SSH public key to your account and to the workspace. The key must be a single line in OpenSSH authorized_keys format, such as the contents of ~/.ssh/id_ed25519.pub.

Names and keys are unique per account, across all your workspaces: you cannot add two keys with the same name, or the same key twice.

Requires the owner, admin or developer role. Viewers get 403.

Authentication

Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.

Headers

X-Workspace-SlugstringRequired

Slug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.

Request body

namestringRequired

Label for the key. Leading and trailing spaces are trimmed. Must be unique among your keys.

public_keystringRequired

The public key in OpenSSH authorized_keys format (<type> <base64> [comment]). Leading and trailing whitespace is trimmed.

Response

201

The key was added.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
uidstringRequired

Unique identifier of the key. Use it in ssh_key_uids when creating a VM.

namestringRequired

Label given to the key.

fingerprintstringRequired

SHA-256 fingerprint of the public key, in the same format as ssh-keygen -l.

created_atstring (date-time)Required

When the key was added.

Errors

StatusMeaning
400Validation failed: invalid request (malformed JSON, or name or public_key missing or empty), name and public_key are required (a field is only whitespace), invalid ssh public key, an ssh key with this name already exists, or this ssh key has already been added to your account. A missing X-Workspace-Slug header returns workspace is required.
401The API key is missing, invalid, expired or revoked.
403You cannot access the workspace, your role does not allow this action, or the account is suspended.

Errors use the standard error format.