You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
Key pairs
DeleteKeyPairs - Deletes key pairs
Copy page
Download PDF
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​
​
GET /?Action=DeleteKeyPairs&Version=2020-04-01&KeyPairNames.1=ssh_key_pair1&KeyPairNames.2=ssh_key_pair2 HTTP/1.1​
Host: ecs.cn-beijing.volcengineapi.com​
Region: cn-beijing​
Service: ecs​
​
Sample response​
​
{​
"ResponseMetadata": {​
"RequestId": "202106111445100102252431000052****",​
"Action": "DeleteKeyPairs",​
"Version": "2020-04-01",​
"Service": "ecs",​
"Region": "cn-beijing"​
},​
"Result": {​
"OperationDetails": [​
{​
"KeyPairName": "ssh_key_pair1",​
"Error": null​
},​
{​
"KeyPairName": "ssh_key_pair2",​
"Error": {​
"Code": "InvalidKeyPair.NotFound",​
"Message": "The specified KeyPair does not exist."​
}​
}​
]​
}​
}​
​
Error codes​
The table below lists the business-related error codes of the operation. For more information, refer to Common error codes.​
​
Status code​
Error code​
Error message​
Description​
400​
LimitExceeded.MaximumKeyPairNames​
You've reached the limit on the number of KeyPairNames that you can set.​
The number of specified key pair names exceeds the upper limit.​
400​
InvalidClientToken.Malformed​
The specified ClientToken is malformed.​
The specified ClientToken is invalid.​
400​
InvalidArgument​
The specified argument is invalid.​
The specified parameter is invalid.​
400​
IdempotentParameterMismatch​
The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.​
The idempotent parameters are inconsistent.​
400​
MissingParameter.KeyPairNames​
The required parameter KeyPairNames is not supplied.​
The key pair name cannot be empty.​
412​
IdempotentProcessing​
The request uses the same client token as a previous one that is still in process.​
The previous idempotent request is still in process. Please try again later.​
429​
FlowLimitExceeded​
You've reached the limit on request rate of resources.​
Request rate of resources exceeds the limit.​
500​
InternalError​
An internal error has occurred.​
An internal error occurred. Try again. If multiple attempts fail, submit a ticket.​
​
​
Last updated: 2026.06.18 17:48:24