Help & DocumentationCloud Virtual Machine

DescribeKeyPairs

Last updated: 2018-10-12 16:02:57

1. API Description

Domain name for API request: cvm.tencentcloudapi.com

This API (DescribeKeyPairs) is used to query key pair information.

  • Key pair is a pair of keys generated by an algorithm. In the generated key pair, one key is open to the public and called public key, and the other key is kept by user and called private key. The public key content of a key pair can be queried via this API, but the private key content is not retained by system.

A maximum of 10 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: cvm.ap-shanghai-fsi.tencentcloudapi.com

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: DescribeKeyPairs
Version Yes String Common parameter. The value used for this API: 2017-03-12
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
KeyIds.N No Array of String ID of key pair, such as skey-11112222. (This API supports filtering multiple IDs at a time. For the format of this parameter, please see the id.N section in the API Introduction). The parameter does not support specifying both KeyIds and Filters. You can query a key pair ID by logging in to the Console.
Filters.N No Array of Filter Filter conditions.
  • project-id - Integer - Required: No - (Filter condition) Filter by project ID. You can query the project ID via project list, or call the API DescribeProject to obtain the project ID from the projectId field value in the returned result.
  • key-name - String - Required: No - (Filter condition). Filter by key pair name.
  • The parameter does not support specifying both KeyIds and Filters.
    Offset No Integer Offset. Default is 0. For more information about Offset, please see the relevant section in API Introduction.
    Limit No Integer Number of values to be returned. Default is 20. Maximum is 100. For more information about Limit, please see the relevant section in API Introduction.

    3. Output Parameters

    Parameter Name Type Description
    TotalCount Integer The number of key pairs matching the filter condition.
    KeyPairSet Array of KeyPair List of details of key pairs.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Error Codes

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    InternalServerError Internal error.
    InvalidFilter Invalid filter.
    InvalidFilterValue.LimitExceeded FilterNumber of parameter values exceeds the limit.
    InvalidKeyPair.LimitExceeded Number of key pairs exceeds the limit.
    InvalidKeyPairId.Malformed Invalid key pair ID. The specified key pair ID is in an incorrect format. For example, skey-1122 has an invalid ID length.
    InvalidParameter Invalid parameter. The parameter does not meet the requirement or is not supported.
    InvalidParameterValue Invalid parameter value. The parameter value is in an incorrect format or is not supported.
    InvalidParameterValueLimit Number of parameter values exceeds the limit.
    InvalidParameterValueOffset Invalid parameter value. The specified Offset is invalid.

    5. Example

    Example 1 Example

    Input example

    https://cvm.tencentcloudapi.com/?Action=DescribeKeyPairs
    &Filters.0.Name=key-name
    &Filters.0.Values.0=Tencent
    &Offset=0
    &Limit=20
    &<Common request parameters>

    Output example

    {
      "Response": {
        "KeyPairSet": [
          {
            "AssociatedInstanceIds": [],
            "CreateTime": "2016-12-02T00:22:40Z",
            "Description": "",
            "KeyId": "skey-mv9yzyjj",
            "KeyName": "Tencent",
            "PublicKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDP0Yw2T4itUKOJQIK69c1Asy1UO88cxEbujR5Jbr0e/Ey1v4ZKAUzDnsBnFlf4hKPA1YvMB8RBYj4GcLtM7PrKnBNNram8rgl73X/klOO8oqKv+J/XUA7KHH1Y6wcn1RTRTMdDHbGhW1q/UpfeylNTbf+wEIWhEfaL5FKQm4hqCw== skey_112168"
          }
        ],
        "RequestId": "6ef60bec-0242-43af-bb20-270359fb54a7",
        "TotalCount": 1
      }
    }