Skip to content
Hayonix

API reference · SSH keys

Add an SSH public key

POST/v1/ssh-keys
API keyssh_key:createProjectIdempotency-Key
TypeScript
client.sshKeys.create()
Python
client.ssh_keys.create()
CLI
hayonix ssh-keys add

Adds a public key to the project. Pods of the project with SSH on accept it within moments, without restarting any container. Adding a key that is already in the project is a conflict.

Project API key (Authorization: Bearer sk_…), or a console session. Requires the ssh_key:create permission (a key's scope, or a role that includes it).

Examples

The samples read API_KEY and API_BASE_URL from the environment (see Setup). Values are examples.

curl -sS "$API_BASE_URL/ssh-keys" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "laptop",
  "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHZG+FGe8of8lnaS3zftZ6bPg69OKrEd9xvDOWK5wqx0 laptop"
}'

Request

Headers
HeaderRequiredDescription
AuthorizationyesBearer and your API key. The key implies its project.
X-Project-Idsession onlyThe project to act in, for console sessions. Requests with an API key leave it out.
Idempotency-KeynoMakes a retry safe: the same key and request within 24 hours return the original response (see Idempotency). The SDKs send one for you.

Body

JSON (application/json): CreateSshKeyRequest.

  • namestring

    Defaults to the key's comment

    1–100 characters

  • public_keystringrequired

    One OpenSSH public key line

    1–16384 characters

Response

201 SshKey — The new key

  • objectstringrequired

    Always `ssh_key`: the type of this object

    One ofssh_key

  • idstringrequired

    Unique ID (`ssh_…`)

    ID with prefix ssh_

  • project_idstringrequired

    Project it belongs to

    ID with prefix prj_

  • namestringrequired

    Its name

  • public_keystringrequired

    Key type and base64 key data, without the comment

  • fingerprintstringrequired

    SHA-256 fingerprint, in the form `ssh-keygen -l` prints

  • created_by_user_idstring | nullrequired

    ID of the user who created it

  • created_byobject | nullrequired

    Who created it (null: created by the platform)

    Show 3 fields of created_by
    • objectstringrequired

      Always `person`

      One ofperson

    • idstringrequired

      The person’s user ID (`usr_…`)

    • namestring | nullrequired

      Their name as they set it; null when they are no longer a member of the organization

  • created_atstring (date-time)required

    When it was created (ISO 8601, UTC)

Example response
Example response
{
  "object": "ssh_key",
  "id": "ssh_01jc5zq4m8k3v6x9t2w7r0b1e4",
  "project_id": "prj_01jc5zq4m8k3v6x9t2w7r0b1e4",
  "name": "string",
  "public_key": "string",
  "fingerprint": "SHA256:…",
  "created_by_user_id": "string",
  "created_by": {
    "object": "person",
    "id": "string",
    "name": "string"
  },
  "created_at": "2026-01-01T00:00:00.000Z"
}

Errors

Errors use the standard envelope. What this operation can answer:

Errors
StatusTypeWhen
400invalid_request_errorA parameter or body field is missing or not allowed; param names it.
401authentication_errorThe key or session is missing, revoked or expired.
403permission_errorThe credential lacks the permission this needs, or the organization is suspended.
409conflict_error idempotency_in_progressA request with the same Idempotency-Key is still running.
422idempotency_error idempotency_key_reusedThe Idempotency-Key was used with a different request.
429rate_limit_error rate_limitedToo many requests; retry after retry-after seconds.