Skip to main content

Delete SSH Key Pair

DELETE /v2.1/{project_id}/os-keypairs/{keypair_name}

Delete a key pair identified by its keypair_name. The operation is idempotent: deleting a non‑existent key pair returns 404 (Not Found). No response body is returned on success.

Request​

Parameters​

NameInTypeDescription
project_idpathstringThe UUID of the project (tenant).
keypair_namepathstringThe name of the key pair to delete.
user_id (Optional)bodystringUser ID of the key pair owner (admin-only to delete for another user). New in version 2.10

Sample Request​

curl -ks -X DELETE \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: gAAAAA<...>' \
-H 'X-OpenStack-Nova-API-Version: 2.72' \
https://api.vietnix.cloud:8774/v2.1/{project_id}/os-keypairs/apikey1

Replace {project_id} with your actual project UUID and apikey1 with the key pair name you wish to remove.

Response​

Successful deletion returns no body. Depending on microversion and backend behavior you may receive either 202 Accepted (asynchronous) or 204 No Content.

Status Codes​

Success​

CodeReason
202 - AcceptedRequest accepted for processing (may be asynchronous).
204 - No ContentKey pair deleted successfully.

Error​

CodeReason
401 - UnauthorizedAuthentication failed or missing.
403 - ForbiddenPolicy does not allow this operation.
404 - Not FoundKey pair not found.

Notes & Best Practices​

  • Ensure the key pair is not referenced by automation scripts or orchestration templates before removal.
  • Deleting a key pair does not affect existing instances that already have the public key injected; it only prevents future associations.