All Products
Search
Document Center

Key Management Service:GetSecretValue

Last Updated:Mar 31, 2026

Retrieves the plaintext value of a secret from a KMS Instance gateway. The response includes the decrypted secret data along with version information, rotation status, and extended configuration if requested.

Request parameters

ParameterTypeRequiredDefaultExampleDescription
SecretNameStringYessecret001The name of the secret.
VersionStageStringNoACSCurrentACSCurrentThe stage label that identifies the secret version to retrieve. KMS returns the secret value of the version marked with the specified stage label. Valid values: ACSCurrent, ACSPrevious. Default value: ACSCurrent.
Note

For Resource Access Management (RAM) secrets, database secrets, and Elastic Compute Service (ECS) secrets, KMS returns only the versions marked with ACSCurrent or ACSPrevious. Database secrets include ApsaraDB RDS secrets, PolarDB secrets, and ApsaraDB for Redis/Tair secrets.

VersionIdStringNo00000000000000000000000000000001The version ID of the secret value to retrieve. If you specify both VersionStage and VersionId, KMS checks whether the specified version exists. If it exists, the secret value is returned. If it does not exist, a parameter error is returned.
Note

RAM secrets, database secrets, and ECS secrets do not support this parameter. If you specify VersionId for these secret types, the parameter is ignored.

FetchExtendedConfigBooleanNofalsefalseSpecifies whether to return the extended configuration of the secret. If set to true, the response includes the ExtendedConfig field. Default value: false.

Response elements

ParameterTypeExampleDescription
SecretNameStringsecret001The name of the secret.
SecretTypeStringGenericThe type of the secret. Valid values: Generic (generic secret), Rds (ApsaraDB RDS secret), Redis (ApsaraDB for Redis/Tair secret), RAMCredentials (RAM secret), ECS (ECS secret), PolarDB (PolarDB secret).
SecretDataStringtestdata1The plaintext secret value. KMS decrypts the stored ciphertext and returns the plaintext in this field.
SecretDataTypeStringbinaryThe format of the secret value. Valid values: text, binary.
VersionIdString00000000000000000000000000000001The version ID of the returned secret value.
VersionStagesList["ACSCurrent"]The stage labels attached to the returned secret version.
CreateTimeString2020-02-21T15:39:26ZThe time when the secret was created. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.
LastRotationDateString2020-07-05T08:22:03ZThe time when the secret was last rotated. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.
NextRotationDateString2020-07-06T18:22:03ZThe time when the secret is next scheduled to rotate. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.
AutomaticRotationStringEnabledThe status of automatic secret rotation. Valid values: Enabled (automatic rotation is enabled), Disabled (automatic rotation is disabled), Invalid (the status of automatic rotation is abnormal and KMS cannot automatically rotate the secret).
RotationIntervalString604800sThe interval between automatic rotations, in integer[unit] format. Currently, the only supported unit is s (seconds). For example, 604800s represents a 7-day rotation interval.
ExtendedConfigString{"SecretSubType":"SingleUser","DBInstanceId":"rm-uf667446pc955****","CustomData":{}}The extended configuration of the secret. This field is returned only when FetchExtendedConfig is set to true.
RequestIdString6a3e9c36-1150-4881-84d3-eb8672fcafadThe request ID.

Error codes

HTTP status codeError codeError messageDescription
404Forbidden.ResourceNotFoundThe resource does not exist in the system.The specified secret does not exist.
409Rejected.DisabledThe request was rejected because the key state is Disabled.The encryption key used to protect the secret is disabled.

For a full list of error codes, see Service error codes.