- Documentation
Elastic Compute Service
Elastic Compute Service
API Reference
Key pairs
DeleteKeyPairs - Deletes key pairs
Key pairs
DeleteKeyPairs - Deletes key pairs
DeleteKeyPairs - Deletes key pairs
Call the DeleteKeyPairs operation to delete one or multiple key pairs.
Usage notes
You cannot delete key pairs associated with instances. If you want to delete a key pair associated with one or more instances, disassociate it first via the DetachKeyPair operation. Debugging
API Explorer
You can initiate calls online through API Explorer without paying attention to the signature generation process and quickly obtain the call results.
Request parameters
Only the request parameters specific to this operation and some common parameters are listed below. For more information, refer to Common parameters. Action string required Sample value: DeleteKeyPairs
The action that you want to perform. Value: DeleteKeyPairs.
Version string required Sample value: 2020-04-01
The version of the API. Valid value: 2020-04-01.
ClientToken string Optional Sample value: 333456899ff****
The ClientToken is used to ensure the request idempotency. You can use the client to automatically generate a token, but you must make sure that the token is unique among different requests. This prevents repeated actions due to multiple client retries when the call of the API action times out or an internal server error occurs.
Value: Only ASCII characters are supported. The length is no more than 64 ASCII characters.
KeyPairNames.N string[] required Sample value: KeyPairNames.1=ssh_key_pair1&KeyPairNames.2=ssh_key_pair2
The key pair name. A maximum of 100 key pair names are supported.
- Argument - N: specifies the serial number of the key pair.
- Separate multiple key pairs with &.
Response parameters
Only the response parameters specific to this operation are listed below. For more information, refer to Response structure. tip
The following error codes for the operation are returned only when invalid values are specified for request parameters. If valid values are specified for the request parameters, no error code is displayed, and a status code of 200 is returned. However, this does not mean that the operation on all key pairs is successful. To view the operation result on one key pair, see the information in the following response parameters. OperationDetails object[] Sample value: --
The operation details.
Error object Sample value: --
The error message for the key pair being operated on.
Code string Sample value: InvalidKeyPair.NotFound
The error code for the failure of a specific individual request during batch operations. Valid values:
- MissingParameter.KeyPairName: The key pair name cannot be empty.
- InvalidKeyPair.NotFound: The specified key pair does not exist.
- InvalidKeyPair.InUse: The specified key pair is currently in use.
- FlowLimitExceeded: You have exceeded the rate limit for resource requests.
tip
Each Code corresponds to a Message in sequence.
Message string Sample value: The specified KeyPair does not exist.
The error information for the failure of a specific individual request during batch operations. Valid values:
- The required parameter KeyPairName is not supplied.
- The specified KeyPair does not exist.
- The specified KeyPair is in use.
- You've reached the limit on request rate of resources.
tip
Each Code corresponds to a Message in sequence.
KeyPairName string Sample value: ssh_key_pair1
The name of the operated key pair.
Sample request
Sample response
Error codes
The table below lists the business-related error codes of the operation. For more information, refer to Common error codes.
Last updated: 2026.06.18 17:48:24