Domain name for API request: kms.intl.tencentcloudapi.com.
Create a master key CMK (Custom Master Key) for user management data keys
A maximum of 100 requests can be initiated per second for this API.
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: CreateKey. |
| 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. |
| Alias | Yes | String | Alias that makes the key easier to identify and understand. It cannot be empty and must contain 1-60 alphanumeric characters, hyphens (-), or underscores (_), and start with a letter or digit. Aliases prefixed with kms- are reserved for cloud services. The alias must be unique. |
| Description | No | String | Description of the CMK. Maximum length: 1024 bytes. |
| KeyUsage | No | String | Specifies the purpose of the key. The default value is "ENCRYPT_DECRYPT", which indicates creating a symmetric encryption/decryption key. Other supported purposes: "ASYMMETRIC_DECRYPT_RSA_2048" indicates creating an RSA2048 asymmetric key for encryption/decryption; "ASYMMETRIC_DECRYPT_RSA_3072" indicates creating an RSA3072 asymmetric key for encryption/decryption; "ASYMMETRIC_DECRYPT_RSA_4096" indicates creating an RSA4096 asymmetric key for encryption/decryption; "ASYMMETRIC_DECRYPT_SM2" indicates creating an SM2 asymmetric key for encryption/decryption; "ASYMMETRIC_SIGN_VERIFY_SM2" indicates creating an SM2 asymmetric key for signature generation and verification; "ASYMMETRIC_SIGN_VERIFY_ECC" indicates creating an ECC asymmetric key for signature generation and verification; "ASYMMETRIC_SIGN_VERIFY_RSA_2048" indicates creating an RSA_2048 asymmetric key for signature generation and verification; "ASYMMETRIC_SIGN_VERIFY_RSA_3072" indicates creating an RSA_3072 asymmetric key for signature generation and verification; |
| Type | No | Integer | Specifies the key type. The default value is 1. 1 indicates the default type, where the CMK is created by KMS. 2 indicates the EXTERNAL type, where you need to import the key material. For more information, see the GetParametersForImport and ImportKeyMaterial APIs. |
| Tags.N | No | Array of Tag | Tag list. |
| HsmClusterId | No | String | HSM cluster ID corresponding to KMS Advanced Edition (valid only for KMS exclusive/managed service instances). |
| Parameter Name | Type | Description |
|---|---|---|
| KeyId | String | Globally unique identifier of the CMK |
| Alias | String | Alias that makes the key easier to identify and understand |
| CreateTime | Integer | Key creation time, unix timestamp |
| Description | String | Description of the CMK |
| KeyState | String | Status of the CMK |
| KeyUsage | String | Purpose of the CMK |
| TagCode | Integer | Return code of the tag operation. 0: Success; 1: Internal error; 2: Business processing error |
| TagMsg | String | Return message of the tag operation |
| HsmClusterId | String | HSM cluster ID (valid only for KMS exclusive/managed service instances) |
| 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. |
This example shows you how to create a Custom Master Key (CMK) for user-managed DEKs. Subsequently, you can call other APIs such as creating DEKs and performing encryption and decryption operations.
POST / HTTP/1.1
Host: kms.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateKey
<Common request parameters>
{
"Description": "test Description"
"Alias": "test8-lzc",
"KeyUsage": "ENCRYPT_DECRYPT",
"Type": 1,
"Tags": [
{
"TagKey": "env",
"TagValue": "dev"
}
]
}
{
"Response": {
"Alias": "test8-lzc",
"CreateTime": 1730347170,
"Description": "test description"
"HsmClusterId": "cls-hsm-3dflmo9g",
"KeyId": "87ff856e-973c-11ef-947b-525400d834e5",
"KeyState": "Enabled",
"KeyUsage": "ENCRYPT_DECRYPT",
"RequestId": "c44aba41-015a-45aa-9e55-1a08ac9d1d78",
"TagCode": 0,
"TagMsg": "ok"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
| Error Code | Description |
|---|---|
| FailedOperation.TaggingError | Tagging error. |
| InternalError | Internal error. |
| InvalidParameter | Invalid parameter. |
| InvalidParameterValue.AliasAlreadyExists | The alias already exists. |
| InvalidParameterValue.InvalidAlias | Incorrect alias format |
| InvalidParameterValue.InvalidHsmClusterId | Invalid HSM cluster ID. |
| InvalidParameterValue.InvalidKeyUsage | Incorrect KeyUsage parameter. |
| 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. |
| UnauthorizedOperation | Unauthorized operation. |
| UnsupportedOperation.ServiceTemporaryUnavailable | The service is temporarily unavailable. |
| UnsupportedOperation.UnsupportedKeyUsageInCurrentRegion | The encryption method is not supported in the current region. |
| UnsupportedOperation.UserVersionNotSupport | Unsupported user version. |
文档反馈