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.
Source
Request
Parameters
| Name | In | Type | Description |
|---|---|---|---|
| project_id | path | string | The UUID of the project (tenant). |
| keypair_name | path | string | The name of the key pair to delete. |
| user_id (Optional) | body | string | User 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 andapikey1with 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
| Code | Reason |
|---|---|
| 202 - Accepted | Request accepted for processing (may be asynchronous). |
| 204 - No Content | Key pair deleted successfully. |
Error
| Code | Reason |
|---|---|
| 401 - Unauthorized | Authentication failed or missing. |
| 403 - Forbidden | Policy does not allow this operation. |
| 404 - Not Found | Key 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.