tencent cloud

ImportDataKey
Last updated: 2025-12-04 15:44:12
ImportDataKey
Last updated: 2025-12-04 15:44:12

1. API Description

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

Data key import API, managed by KMS.

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: ImportDataKey.
Version Yes String Common Params. The value used for this API: 2019-01-18.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
DataKeyName Yes String Name of the data key.
ImportKeyMaterial Yes String If the imported key is plaintext data key, it is the base64 plaintext data key after conversion. if the imported key is ciphertext data key, it is the ciphertext data key generated by the KMS GenerateDataKey interface.
ImportType Yes Integer 1: ciphertext import (data key generated by KMS api) 2: plaintext import.
Description No String Describes the data key. maximum 100 bytes.
KeyId No String When importing an encrypted data key, no need to input the root key. if the input is provided, validate whether the KeyId matches the one in the ciphertext.
When importing plaintext data key, KeyId cannot be empty. the data key is encrypted with the specified root key.
HsmClusterId No String HSM cluster ID corresponding to the KMS exclusive edition. if HsmClusterId is specified, it indicates the root key is in this cluster and verifies whether KeyId corresponds to HsmClusterId.
Tags.N No Array of Tag Tag list

3. Output Parameters

Parameter Name Type Description
KeyId String Globally unique CMK id.
DataKeyId String Globally unique id of DataKey. no. show on portal/domestic and international sites.
TagCode Integer Response code of the Tag operation. 0: success; 1: internal error; 2: business processing error.
TagMsg String Response of the Tag operation.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Data Key Import Example

Input Example

POST / HTTP/1.1
Host: kms.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ImportDataKey
<Common request parameters>

{
    "DataKeyName": "test_weijia_0123456",
    "ImportKeyMaterial": "MTIzNAo=",
    "ImportType": 2,
"Description": "Data key import test"
    "KeyId": "0397abd8-4029-11f0-aa65-52540064acab"
}

Output Example

{
    "Response": {
        "DataKeyId": "eb46f9c0-5015-11f0-ace9-525400eb1719",
        "KeyId": "0397abd8-4029-11f0-aa65-52540064acab",
        "RequestId": "85568b48-a19c-43e1-9850-6d9101dc2b3a"
    }
}

5. Developer Resources

SDK

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
AuthFailure.UnauthorizedOperation Unauthorized operation.
FailedOperation.TaggingError Tagging error.
InternalError Internal error.
InvalidParameter Invalid parameter.
InvalidParameterValue.InvalidDataKeyName Invalid data key name.
InvalidParameterValue.InvalidImportKeyMaterial The imported data key is valid.
InvalidParameterValue.InvalidKeyId Invalid KeyId.
InvalidParameterValue.InvalidKeyUsage Incorrect KeyUsage parameter.
InvalidParameterValue.InvalidPlaintext Invalid Plaintext.
InvalidParameterValue.InvalidType Incorrect Type parameter.
InvalidParameterValue.TagKeysDuplicated Duplicate tag key.
InvalidParameterValue.TagsNotExisted The tag key or tag value does not exist.
LimitExceeded.CmkLimitExceeded The number of CMKs has reached the upper limit.
LimitExceeded.DataKeyLimitExceeded DataKey exceeds the upper limit.
ResourceUnavailable.CmkArchived The CMK has been archived.
ResourceUnavailable.CmkDisabled The CMK has been disabled.
ResourceUnavailable.CmkNotFound The CMK does not exist.
ResourceUnavailable.CmkStateNotSupport This operation cannot be performed under the current CMK status.
ResourceUnavailable.KeyPendingDelete The key is not available as it’s pending deleted.
UnauthorizedOperation Unauthorized operation.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback