CreateSecret

Last updated: 2021-08-02 11:35:24

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 parameter. The value used for this API: CreateSecret.
Version Yes String Common parameter. The value used for this API: 2019-09-23.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
SecretName Yes String Secret name, which must be unique within a region. The name can be up to 128 bytes, contain letters, digits, hyphens (-), and underscores (_), and must begin with a letter or digit.
VersionId Yes String Secret version. It can be up to 64 bytes, contain letters, digits, hyphens (-), and underscores (_), and must begin with a letter or digit. SecretName and VersionId are used to query the Secret information.
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.
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.
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 new credential information

Input Example

https://ssm.tencentcloudapi.com/?Action=CreateSecret
&SecretName=test_secret
&VersionId=v1.0
&Description=test create secret
&SecretString=test
&<Common request parameters>

Output Example

{
  "Response": {
    "RequestId": "9debf284-eff9-465a-97b7-163a8b1cccaf",
    "SecretName": "test_secret",
    "VersionId": "v1.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 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.