API documentation Web hosting accessible to everyone Visit LWS

Add an SSH key

POST /api/v1/ssh-keys

operationIdpostSshKey

Required level
Operations
Rate limit
mutation, 300 calls per hour

Registers a public key on the account. It is active as soon as it is created.

The key is rejected if its algorithm is not recognized, or if it is an RSA key shorter than 2048 bits. The response contains the key record: note its id, which you need to disable or delete it. If the record could not be read back, the response is limited to {"created": true}: find the key with GET /ssh-keys.

Request body

  • key string

    OpenSSH public key, as in the .pub file

    required
Example request
{
  "key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINK0AO80+x734if/v0cHQXq3DTEQDjY2M0t6Mm3lDOiC poste-admin"
}

Responses

201

Key registered

{
  "data": {
    "id": "47",
    "type": "ssh-ed25519",
    "comment": "poste-admin",
    "active": true,
    "fingerprint": "SHA256:lpEBpHL5EO65b9cDXg8YjfqlnovHfCn+3faPLPbfnZI",
    "fingerprint_md5": "ab:c7:15:6a:9a:4e:fb:02:1b:b8:ab:3f:e5:41:67:a2",
    "weak": false
  }
}
Response fields 8
  • data object required
  • id string

    Example: 47

  • type string

    Example: ssh-ed25519

  • comment string

    Comment embedded in the key

  • fingerprint string

    SHA-256 fingerprint, ssh-keygen -l format

  • fingerprint_md5 string

    MD5 fingerprint, the one shown in the panel

  • active boolean

    Installed automatically when a VPS is created or reinstalled

  • weak boolean

    Inherited key that would be refused if added today (RSA under 2048 bits): listed so it can be disabled or deleted, refused at reinstallation

400

Invalid parameters: validation_failed — unreadable key, unknown type, or RSA key shorter than 2048 bits.

{
  "type": "https://docs.lws.fr/kvm/errors/validation-failed",
  "title": "Paramètres invalides",
  "status": 400,
  "code": "validation_failed",
  "detail": "Clé SSH refusée. Attendu : une clé publique OpenSSH d'un type reconnu, les clés RSA devant faire au moins 2048 bits.",
  "request_id": "3f9a1c07b2e45d18",
  "errors": {
    "key": "Clé SSH refusée. Attendu : une clé publique OpenSSH d'un type reconnu, les clés RSA devant faire au moins 2048 bits."
  }
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Short title, in French

    Example: VPS introuvable

    required
  • status integer (int64)

    HTTP status

    Example: 404

    required
  • code string

    Stable machine-readable code (see "Errors" in Getting started)

    Example: vm_not_found

    required
  • detail string

    Detailed message, in French

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identifier of the request, to give to support

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: message per faulty parameter

  • required_level string

    insufficient_scope: level required by the operation

    one of: read, exploitation, full

  • task_id string

    task_already_running: task running on this VPS

    Example: tsk_000002d5

  • family string

    rate_limited: exhausted rate limit family

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: hourly limit of the family

  • retry_after integer (int64)

    rate_limited: seconds to wait

  • lock string

    server_locked: lock set by the hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, an operation is running, retry after Retry-After; suspended, the VPS is hibernating, start it first; support_notified, abnormal lock, the LWS team has been notified and is taking care of it

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: nature of the intervention, start and expected end (null for an incident)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
401

Authentication refused: invalid_token — Authorization header missing or malformed, or unknown key; access_disabled — API access turned off for this account, or API service temporarily turned off by LWS.

Authorization header missing or malformed, or unknown key

{
  "type": "https://docs.lws.fr/kvm/errors/invalid-token",
  "title": "Authentification invalide",
  "status": 401,
  "code": "invalid_token",
  "detail": "Clé inconnue ou révoquée.",
  "request_id": "3f9a1c07b2e45d18"
}

API access turned off for this account, or API service temporarily turned off by LWS

{
  "type": "https://docs.lws.fr/kvm/errors/access-disabled",
  "title": "Accès API désactivé",
  "status": 401,
  "code": "access_disabled",
  "detail": "L'accès API est désactivé pour ce compte. Réactivez-le depuis la page « API / MCP » du panel.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Short title, in French

    Example: VPS introuvable

    required
  • status integer (int64)

    HTTP status

    Example: 404

    required
  • code string

    Stable machine-readable code (see "Errors" in Getting started)

    Example: vm_not_found

    required
  • detail string

    Detailed message, in French

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identifier of the request, to give to support

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: message per faulty parameter

  • required_level string

    insufficient_scope: level required by the operation

    one of: read, exploitation, full

  • task_id string

    task_already_running: task running on this VPS

    Example: tsk_000002d5

  • family string

    rate_limited: exhausted rate limit family

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: hourly limit of the family

  • retry_after integer (int64)

    rate_limited: seconds to wait

  • lock string

    server_locked: lock set by the hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, an operation is running, retry after Retry-After; suspended, the VPS is hibernating, start it first; support_notified, abnormal lock, the LWS team has been notified and is taking care of it

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: nature of the intervention, start and expected end (null for an incident)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
403

Access denied: insufficient_scope — key level too low; ip_not_allowed — calling address not authorized.

key level too low

{
  "type": "https://docs.lws.fr/kvm/errors/insufficient-scope",
  "title": "Droits insuffisants",
  "status": 403,
  "code": "insufficient_scope",
  "detail": "Niveau de permission « exploitation » requis.",
  "request_id": "3f9a1c07b2e45d18",
  "required_level": "exploitation"
}

calling address not authorized

{
  "type": "https://docs.lws.fr/kvm/errors/ip-not-allowed",
  "title": "Adresse non autorisée",
  "status": 403,
  "code": "ip_not_allowed",
  "detail": "L'adresse 203.0.113.10 ne figure pas parmi les adresses autorisées de ce compte.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Short title, in French

    Example: VPS introuvable

    required
  • status integer (int64)

    HTTP status

    Example: 404

    required
  • code string

    Stable machine-readable code (see "Errors" in Getting started)

    Example: vm_not_found

    required
  • detail string

    Detailed message, in French

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identifier of the request, to give to support

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: message per faulty parameter

  • required_level string

    insufficient_scope: level required by the operation

    one of: read, exploitation, full

  • task_id string

    task_already_running: task running on this VPS

    Example: tsk_000002d5

  • family string

    rate_limited: exhausted rate limit family

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: hourly limit of the family

  • retry_after integer (int64)

    rate_limited: seconds to wait

  • lock string

    server_locked: lock set by the hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, an operation is running, retry after Retry-After; suspended, the VPS is hibernating, start it first; support_notified, abnormal lock, the LWS team has been notified and is taking care of it

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: nature of the intervention, start and expected end (null for an incident)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
429

Rate limit exceeded: rate_limited — hourly limit of the family exhausted.

{
  "type": "https://docs.lws.fr/kvm/errors/rate-limited",
  "title": "Quota dépassé",
  "status": 429,
  "code": "rate_limited",
  "detail": "Quota dépassé pour les opérations de type « mutation » : 300 appels par heure. Réessayez dans 95 seconde(s).",
  "request_id": "3f9a1c07b2e45d18",
  "family": "mutation",
  "limit": 300,
  "retry_after": 95
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Short title, in French

    Example: VPS introuvable

    required
  • status integer (int64)

    HTTP status

    Example: 404

    required
  • code string

    Stable machine-readable code (see "Errors" in Getting started)

    Example: vm_not_found

    required
  • detail string

    Detailed message, in French

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identifier of the request, to give to support

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: message per faulty parameter

  • required_level string

    insufficient_scope: level required by the operation

    one of: read, exploitation, full

  • task_id string

    task_already_running: task running on this VPS

    Example: tsk_000002d5

  • family string

    rate_limited: exhausted rate limit family

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: hourly limit of the family

  • retry_after integer (int64)

    rate_limited: seconds to wait

  • lock string

    server_locked: lock set by the hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, an operation is running, retry after Retry-After; suspended, the VPS is hibernating, start it first; support_notified, abnormal lock, the LWS team has been notified and is taking care of it

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: nature of the intervention, start and expected end (null for an incident)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
502

Dependency unreachable: upstream_unavailable — key management API unreachable.

{
  "type": "https://docs.lws.fr/kvm/errors/upstream-unavailable",
  "title": "Service momentanément indisponible",
  "status": 502,
  "code": "upstream_unavailable",
  "detail": "La liste des clés SSH n'a pas pu être obtenue. Réessayez dans quelques instants.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Short title, in French

    Example: VPS introuvable

    required
  • status integer (int64)

    HTTP status

    Example: 404

    required
  • code string

    Stable machine-readable code (see "Errors" in Getting started)

    Example: vm_not_found

    required
  • detail string

    Detailed message, in French

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identifier of the request, to give to support

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: message per faulty parameter

  • required_level string

    insufficient_scope: level required by the operation

    one of: read, exploitation, full

  • task_id string

    task_already_running: task running on this VPS

    Example: tsk_000002d5

  • family string

    rate_limited: exhausted rate limit family

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: hourly limit of the family

  • retry_after integer (int64)

    rate_limited: seconds to wait

  • lock string

    server_locked: lock set by the hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, an operation is running, retry after Retry-After; suspended, the VPS is hibernating, start it first; support_notified, abnormal lock, the LWS team has been notified and is taking care of it

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: nature of the intervention, start and expected end (null for an incident)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
Show the code examples and the test console
POST /ssh-keys
LWS_API_KEY='…'curl -X POST \  "https://panelkvm.lwspanel.com/api/v1/ssh-keys" \  -H "Authorization: Bearer $LWS_API_KEY" \  -H "Content-Type: application/json" \  -d '{"key":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINK0AO80+x734if/v0cHQXq3DTEQDjY2M0t6Mm3lDOiC poste-admin"}'
$lwsApiKey = '…';$ch = curl_init("https://panelkvm.lwspanel.com/api/v1/ssh-keys");curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, [    "Authorization: Bearer " . $lwsApiKey,    "Content-Type: application/json",]);curl_setopt($ch, CURLOPT_POSTFIELDS, '{"key":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINK0AO80+x734if/v0cHQXq3DTEQDjY2M0t6Mm3lDOiC poste-admin"}');$res = json_decode(curl_exec($ch), true);
import requestsLWS_API_KEY = "…"res = requests.post(    "https://panelkvm.lwspanel.com/api/v1/ssh-keys",    headers={        "Authorization": "Bearer " + LWS_API_KEY,    },    json={"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINK0AO80+x734if/v0cHQXq3DTEQDjY2M0t6Mm3lDOiC poste-admin"},)print(res.json())
const LWS_API_KEY = "…";const res = await fetch("https://panelkvm.lwspanel.com/api/v1/ssh-keys", {  method: "POST",  headers: {    "Authorization": "Bearer " + LWS_API_KEY,    "Content-Type": "application/json",  },  body: JSON.stringify({"key":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINK0AO80+x734if/v0cHQXq3DTEQDjY2M0t6Mm3lDOiC poste-admin"}),});const data = await res.json();
lwsApiKey := "…"body := strings.NewReader(`{"key":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINK0AO80+x734if/v0cHQXq3DTEQDjY2M0t6Mm3lDOiC poste-admin"}`)req, _ := http.NewRequest("POST",    "https://panelkvm.lwspanel.com/api/v1/ssh-keys", body)req.Header.Set("Authorization", "Bearer "+lwsApiKey)req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)