tencent cloud

Secrets Manager

CreateSecret

다운로드
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-11-30 19:10:36

1. API Description

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

This API is used to create a new secret encrypted and protected by KMS. You can create up to 1,000 secrets in each Region.

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: CreateSecret.
Version Yes String Common Params. The value used for this API: 2019-09-23.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
SecretName Yes String

Credential name, which must be unique within the same region and can contain up to 128 bytes. It can contain only letters, digits, hyphens (-), and underscores (_), and the first character must be a letter or digit. Once created, it cannot be modified.

VersionId No String

Credential version, which is used together with SecretName to query credential information. It can contain up to 64 bytes and can contain only letters, digits, hyphens (-), underscores (_), and periods (.), and must start with a letter or digit. If it is empty, the default initial credential version is used. This parameter is optional. If it is empty or the credential is a cloud product credential, the version defaults to SSM_Current.

Description No String

Description, which is used to describe the purpose in detail. It can contain up to 2048 bytes.

KmsKeyId No String

Specifies the KMS CMK used to encrypt the credential. If it is empty, the CMK created by Secrets Manager by default is used for encryption. You can also specify a KMS CMK created by yourself in the same region for encryption.

SecretType No Integer

Credential type. The default value is 0, which indicates a custom credential.

SecretBinary No String

Plaintext of the binary credential after base64 encoding. You must set either SecretBinary or SecretString, but not both. The maximum size is 32 KB.

SecretString No String

Plaintext of the text credential, which does not need to be base64 encoded. You must set either SecretBinary or SecretString, but not both. The maximum size is 32 KB.

AdditionalConfig No String

JSON string used to specify additional configuration for a specific credential type.

Tags.N No Array of Tag

Tag list.

KmsHsmClusterId No String

ID of the dedicated KMS cluster. This parameter is valid only when KmsKeyId is empty and the user's KMS has a valid HsmClusterId.

EncryptType No Integer

Credential encryption type.

Valid values:

  • 0: KMS key encryption
  • 1: Software key encryption

3. Output Parameters

Parameter Name Type Description
SecretName String

Name of the newly created credential.

VersionId String

Newly created credential version.

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

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 Creating a Secret

This example shows you how to create a custom secret.

Input Example

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

{
    "SecretName": "test3_secret",
    "VersionId": "v2.0",
    "Description": "Test custom secret creation",
    "KmsKeyId": "6abd1fdb-86d4-11ef-b72d-52540089bc41",
    "SecretType": 0,
    "SecretString": "Secret value2"
}

Output Example

{
    "Response": {
        "RequestId": "be7d863d-8d8d-4d28-97b7-3dad7236bb33",
        "SecretName": "test2_secret",
        "TagCode": 0,
        "TagMsg": "ok",
        "VersionId": "v2.0"
    }
}

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
FailedOperation.AccessKmsError KMS operation failed.
InternalError Internal error.
InvalidParameterValue Parameter value error.
InvalidParameterValue.TagKeysDuplicated Duplicate tag key.
InvalidParameterValue.TagsNotExisted The tag key or tag value does not exist.
LimitExceeded The quota limit is exceeded.
ResourceInUse.SecretExists The credential name already exists.
ResourceUnavailable.NotPurchased The service has not been purchased.
UnauthorizedOperation Unauthorized operation.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백