tencent cloud



Last updated: 2023-08-07 17:45:15

1. API Description

Domain name for API request: kms.tencentcloudapi.com.

This API is used to import key material into an EXTERNAL CMK. The key obtained through the GetParametersForImport API is used to encrypt the key material. You can only reimport the same key material into the specified CMK and set a new expiration time. After the CMK key material is imported, it cannot be replaced. After the key material is expired or deleted, the CMK will remain unavailable until the same key material is reimported. CMKs are independent, which means that the same key material can be imported into different CMKs, but data encrypted by one CMK cannot be decrypted by another one.
Key material can only be imported into CMKs in Enabled and PendingImport status.

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

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

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 Params. The value used for this API: ImportKeyMaterial.
Version Yes String Common Params. The value used for this API: 2019-01-18.
Region No String Common Params. This parameter is not required for this API.
EncryptedKeyMaterial Yes String Base64-encoded key material that encrypted with the PublicKey returned by GetParametersForImport. For the KMS of SM-CRYPTO version, the length of the key material should be 128 bits, while for KMS of FIPS-compliant version, the length should be 256 bits.
ImportToken Yes String Import token obtained by calling GetParametersForImport.
KeyId Yes String Specifies the CMK into which to import key material, which must be the same as the one specified by GetParametersForImport.
ValidTo No Integer Unix timestamp of the key material's expiration time. If this value is empty or 0, the key material will never expire. To specify the expiration time, it should be later than the current time. Maximum value: 2147443200.

3. Output Parameters

Parameter Name Type Description
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Importing key material

Input Example

Host: kms.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ImportKeyMaterial
<Common request parameters>

    "ValidTo": "0",
    "KeyId": "23e80852-1e38-11e9-b129-5cb9019b4b01",
    "ImportToken": "Sy+GF4f+XxUan1sfSBfqWQmyJeVO30wcqLEMoW4REpxBApJqYG9zc37OM0Z3qT/mvLofzM3hwVJSTzIITcAo6ew3LidOJ3nwNoVNOM2wnrL+g9puwP0GpbbSwTd16X9E",
    "EncryptedKeyMaterial": "dgqtAzLde+xsR5q3kwOsWu4bst7FaE4sbhhf1OHCMujhjTJTnFGEubKowVFnFC96e2vUvO5fwGvfNcPIDkg6q7iuFviM0BepCmF9Fyk3tluJVRf/Nv8FCccANXmsZDPxtSHdcD00/dQg1i2BIaLMP3/VFBDVEK7AzRhlTkrNiout4pavGSCAF+uBl2Vmnq6fF4DT37B0Q0WQ4NyfUwDCSR0VSF9vwqommhudJUhv4+21xHMgUCdbFvVoOmZP/Md5Sb4rbMbWi5qRpLusi8W3KKTyJ8onp7UC+0qi6DTw4XCq4UPniFNJXIxUOSVXpZHQKFCJXr6/cxNAci8eMTTwfA=="

Output Example

    "Response": {
        "RequestId": "1b580852-1e38-11e9-b129-5cb9019b4b00"

5. Developer Resources


TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

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

Error Code Description
InternalError Internal error.
InvalidParameter Invalid parameter.
InvalidParameter.DecryptMaterialError Decryption of EncryptedKeyMaterial failed.
InvalidParameterValue.InvalidKeyId Invalid KeyId.
InvalidParameterValue.MaterialNotMatch The key material is different from the one previously imported.
ResourceUnavailable.CmkNotFound The CMK does not exist.
ResourceUnavailable.CmkStateNotSupport This operation cannot be performed under the current CMK status.
ResourceUnavailable.TokenExpired Token has expired.
UnsupportedOperation.NotExternalCmk Incorrect CMK type. Only External CMKs are supported.
UnsupportedOperation.ServiceTemporaryUnavailable The service is temporarily unavailable.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support