Updated on 2026-09-20 GMT+08:00

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.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    csms:secret:batchGetSecretValue

    Read

    -

    -

    csms:secretVersion:batchGetSecretValue

    kms:cmk:decryptDataKey

URI

POST /v1/{project_id}/secrets/batch-get-secret-value

Table 1 Path Parameters

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

Table 2 Request header 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

Table 3 Request body parameters

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

Table 4 Response body parameters

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

Table 5 Version

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

Table 6 VersionMetadata

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.