tencent cloud

APIs

GetSecretValue

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-11-30 19:10:26

1. API Description

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

For a user-defined secret, this API is used to obtain the plaintext information of the secret by specifying the secret name and version.
For a cloud product secret such as a Mysql secret, this API is used to obtain the plaintext information of a historical rotated secret by specifying the secret name and historical version number. To obtain the plaintext of the secret version currently in use, set the version number to SSM_Current.

A maximum of 500 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: GetSecretValue.
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

Specifies the name of the credential.

VersionId No String

Specifies the version ID of the credential to read. If only VersionId is passed, the specified version is read. For cloud product credentials and Redis/MongoDB credentials, the current version can be read through SSM_Current.

Input limits: If VersionStage is also specified, both must point to the same version; Otherwise, ResourceNotFound is returned.

For custom, cloud product, and Redis/MongoDB credentials, if neither VersionId nor VersionStage is specified, the version pointed to by the Stage_Current tag is read by default. If this tag is not set, InvalidParameterValue is returned, and it does not fall back to SSM_Current.

EncryptionPublicKey No String

PEM-format public key used to encrypt the returned credential value. RSA 2048 and SM2 are supported. If not specified, the credential value is returned in the original way.

EncryptionAlgorithm No String

Asymmetric encryption algorithm. It takes effect only when EncryptionPublicKey is specified. Supported algorithms: SM2, SM2_C1C3C2_ASN1, RSAES_PKCS1_V1_5, RSAES_OAEP_SHA_1, and RSAES_OAEP_SHA_256. The default value is SM2.

VersionStage No String

Tag used to select the credential version. It supports custom, cloud product, and Redis/MongoDB credentials.

Valid values:

  • Stage_Current: Reads the version bound to the current version tag set by the user. The tag is not set automatically and does not migrate with the account.

Only Stage_Current is supported, and it is case-sensitive. If only the tag is passed, the value is obtained based on the binding relationship. If it is passed together with VersionId, both must point to the same version. If neither is passed, Stage_Current is resolved by default. If this tag is not set, InvalidParameterValue is returned.

3. Output Parameters

Parameter Name Type Description
SecretName String

Credential name.

VersionId String

Version number of the credential.

SecretBinary String

If binary data is specified when creating a credential (CreateSecret), this field is returned and encoded in base64. The application needs to decode the base64 data to obtain the original data.
Only one of SecretBinary and SecretString is not empty.

SecretString String

If plaintext data is specified when creating a credential (CreateSecret), this field is returned.
Only one of SecretBinary and SecretString is not empty.

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 Obtaining the Plaintext Secret Information

Obtaining the Plaintext Secret Information

Input Example

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

{
    "SecretName": "test3-secret",
    "VersionId": "v3"
}

Output Example

{
    "Response": {
        "RequestId": "91cec765-5604-4287-89b1-634357cfcd29",
        "SecretBinary": "5Yet5o2udmFsdWUyCg==",
        "SecretName": "test3-secret",
        "SecretString": "Secret value3",
        "VersionId": "v3"
    }
}

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 Operation failed.
FailedOperation.AccessKmsError KMS operation failed.
InternalError Internal error.
InvalidParameterValue Parameter value error.
OperationDenied.RoleNotExist Role does not exist.
ResourceNotFound Resources do not exist.
ResourceNotFound.SecretNotExist The credential does not exist.
ResourceUnavailable.NotPurchased The service has not been purchased.
ResourceUnavailable.ResourceDisabled The credential is disabled.
ResourceUnavailable.ResourcePendingDeleted The credential is in the scheduled deletion state.
ResourceUnavailable.ResourceUninitialized The credential is not initialized.
UnauthorizedOperation Unauthorized operation.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック