tencent cloud

Feedback

CreateSecret

Last updated: 2023-09-18 17:15:29

1. API Description

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

This API is used to create a KMS-encrypted Secret. You can create and store 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 No String Common Params. This parameter is not required for this API.
SecretName Yes String Secret name, which must be unique in the same region. It can contain 128 bytes ([a-z], [A-Z], [0-9], [-_]). It must begin with a letter or digit. Note that it cannot be modified once created.
VersionId No String Secret version. It can contain up to 64 bytes ([a-z], [A-Z], [0-9], [-_.]). It must begin with a letter or digit. SecretName and VersionId are used to query the Secret information. If it is left empty, the initial Secret version number is used by default.
Description No String Description information, such as the detailed use cases. It can be up to 2048 bytes.
KmsKeyId No String KMS CMK used for Secret encryption. If this parameter is left empty, SecretsManager will create a CMK by default. You can also specify a KMS CMK that is created in the same region.
SecretType No Integer Secret type. It defaults to custom.
SecretBinary No String Base64-encoded plaintext of a binary Secret. Either SecretBinary or SecretString must be set. A maximum of 4096 bytes is supported.
SecretString No String Plaintext of a Secret, in text format. Base64 encoding is not required. Either SecretBinary or SecretString must be set. A maximum of 4096 bytes is supported.
AdditionalConfig No String Additional configuration of the Secret in JSON format
Tags.N No Array of Tag List of tags.

3. Output Parameters

Parameter Name Type Description
SecretName String Name of the new Secret.
VersionId String ID of the new Secret version.
TagCode Integer Return code of tag operation. 0: success; 1: internal error; 2: business processing error
Note: This field may return null, indicating that no valid value was found.
TagMsg String Return message of tag operation.
Note: This field may return null, indicating that no valid value was found.
RequestId String The unique request ID, which is returned for each request. 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.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateSecret
<Common request parameters>

{
    "VersionId": "v1.0",
    "SecretString": "test",
    "Description": "test create secret",
    "SecretName": "test_secret"
}

Output Example

{
    "Response": {
        "RequestId": "9debf284-eff9-465a-97b7-163a8b1cccaf",
        "SecretName": "test_secret",
        "VersionId": "v1.0",
        "TagCode": 1,
        "TagMsg": "success"
    }
}

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 An internal error occurred.
InvalidParameterValue The parameter value is invalid.
InvalidParameterValue.TagKeysDuplicated The tag keys are duplicated.
InvalidParameterValue.TagsNotExisted The tag key or tag value does not exist.
LimitExceeded The quota limit is exceeded.
ResourceInUse.SecretExists The Secret name already exists.
ResourceUnavailable.NotPurchased The service is not purchased.
UnauthorizedOperation The operation is unauthorized.
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