Querying Plaintext Secret Values in Batches
Function
This API is used to query plaintext secret values in batches. Only the latest secret value is obtained, that is, only the secret version whose status is SYSCURRENT is obtained.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/secrets/batch-get-secret-value
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details, see Obtaining a Project ID. Constraints N/A Range The value returned by the IAM API is used, which contains 32 characters. Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User token. It can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token. This parameter is optional if AK/SK authentication is used. Constraints N/A Range Obtain the value by calling the IAM API for obtaining the user token. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| secret_name_list | No | Array of strings | Definition Name of the secret whose value is to be obtained. Constraints N/A Range N/A Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| total_count | Integer | Definition Total number of returned secret versions. Range N/A |
| versions | Array of Version objects | Definition Secret version value. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| version_metadata | VersionMetadata object | Definition Secret version metadata. Range N/A |
| secret_binary | String | Definition Plaintext of a binary secret encoded using Base64. CSMS encrypts the plaintext and stores it in the initial version of the secret. Type: Base64-encoded binary data object. Range N/A |
| secret_string | String | Definition Plaintext of a text secret. CSMS encrypts the plaintext and stores it in the initial version of the secret. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition Secret version ID, which is unique under a secret object. Range N/A |
| create_time | Long | Definition Timestamp when a secret version was created, that is, total number of milliseconds since January 1, 1970. Range N/A |
| expire_time | Long | Definition Timestamp when a secret version expired, that is, the total milliseconds since January 1, 1970. This parameter is left blank by default. When version expiration events are subscribed to, the validity period is determined based on this parameter. Range N/A |
| kms_key_id | String | Definition ID of the KMS CMK used to encrypt secret values Range N/A |
| secret_name | String | Definition Secret name Range N/A |
| version_stages | Array of strings | Definition Secret version status list. Each status tag is unique for a secret version. If a status tag in use is added to a new version, the tag will be automatically removed from the original version. If version_stage is not specified, the temporary tag SYSCURRENT will be added to this version. Range N/A |
Example Requests
Obtain the values of secrets secretname1 and secretname2.
/v1/7fb65ef26f174116bd303ae2bab367a7/secrets/batch-get-secret-value
{
"secret_name_list" : [ "secretname1", "secretname2" ]
} Example Responses
Status code: 200
{
"versions" : [ {
"version_metadata" : {
"id" : "v5",
"create_time" : 1786671025000,
"expire_time" : null,
"secret_name" : "001123",
"kms_key_id" : "6452d410-dbb7-4700-9c10-9ff1d470e132",
"version_stages" : [ "SYSCURRENT" ]
},
"secret_string" : "{\"AA\":\"AA\"}"
}, {
"version_metadata" : {
"id" : "v2",
"create_time" : 1786671025000,
"expire_time" : null,
"secret_name" : "001123",
"kms_key_id" : "6452d410-dbb7-4700-9c10-9ff1d470e132",
"version_stages" : [ "SYSCURRENT" ]
},
"secret_string" : "{\"AA2\":\"AA\"}"
} ],
"total_count" : 2
} Status Codes
| Status Code | Description |
|---|---|
| 200 |
Error Codes
See Error Codes.