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

Updating the Secret Version

Function

This API is used to update the validity period of a specified secret version. Only enabled secrets can be updated. If the associated subscription events include version expired events, only one notification is triggered each time the version validity period is updated.

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:updateVersion

    Write

    secretName *

    • csms:Type

    • csms:VersionId

    • g:EnterpriseProjectId

    • g:ResourceTag/<tag-key>

    csms:secretVersion:update

    -

URI

PUT /v1/{project_id}/secrets/{secret_name}/versions/{version_id}

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

secret_name

Yes

String

Definition

Secret name.

Constraints

N/A

Range

The value must match the regular expression ^[a-zA-Z0-9_-]{1,64}$.

Default Value

N/A

version_id

Yes

String

Definition

Secret version, which stores the secret version content. Secret versions are numbered v1, v2, v3, and so on based on their creation time.

Constraints

A secret can have up to 20 versions.

Range

The value must match the regular expression v[0-9]{1,10}.

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

expire_time

Yes

Long

Definition

Timestamp when a secret version expired, that is, the total seconds 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.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

version_metadata

VersionMetadata object

Definition

Secret version metadata.

Range

N/A

Table 5 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 seconds since January 1, 1970.

Range

N/A

expire_time

Long

Definition

Timestamp when a secret version expired, that is, the total seconds 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

Update the secret version. The expiration date is 1696838472000.

{
  "expire_time" : 1696838472000
}

Example Responses

Status code: 200

Request succeeded.

{
  "version_metadata" : {
    "id" : "v3",
    "kms_key_id" : "b168fe00ff56492495a7d22974df2d0b",
    "create_time" : 1581507580000,
    "secret_name" : "secret-name-demo",
    "version_stages" : [ "SYSCURRENT" ]
  }
}

Status Codes

Status Code

Description

200

Request succeeded.

Error Codes

See Error Codes.