Updated on 2025-08-28 GMT+08:00

Rotating a Secret

Function

Executes rotation secrets immediately. Creates a new secret version in the specified secret to encrypt and store secret values randomly generated in the background. At the same time, the newly created secret version is marked as SYSCURRENT.

Constraints

The RotateSecret API does not support rotation of common secrets.

A user account has the following rights:

Change the RDS database password

Query key details

Query the key list

Create a DEK

Decrypt the DEK

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/secrets/{secret_name}/rotate

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

secret_name

Yes

String

Secret name

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

version_id

String

Version identifier of a secret.

secret_name

String

Secret name.

rotation_task_id

String

ID of the secret rotation task

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

error

ErrorDetail object

Error message

Table 5 ErrorDetail

Parameter

Type

Description

error_code

String

Error code returned for an error request.

error_msg

String

Error information returned for an error request.

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

error

ErrorDetail object

Error message

Table 7 ErrorDetail

Parameter

Type

Description

error_code

String

Error code returned for an error request.

error_msg

String

Error information returned for an error request.

Status code: 403

Table 8 Response body parameters

Parameter

Type

Description

error

ErrorDetail object

Error message

Table 9 ErrorDetail

Parameter

Type

Description

error_code

String

Error code returned for an error request.

error_msg

String

Error information returned for an error request.

Status code: 404

Table 10 Response body parameters

Parameter

Type

Description

error

ErrorDetail object

Error message

Table 11 ErrorDetail

Parameter

Type

Description

error_code

String

Error code returned for an error request.

error_msg

String

Error information returned for an error request.

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

error

ErrorDetail object

Error message

Table 13 ErrorDetail

Parameter

Type

Description

error_code

String

Error code returned for an error request.

error_msg

String

Error information returned for an error request.

Status code: 502

Table 14 Response body parameters

Parameter

Type

Description

error

ErrorDetail object

Error message

Table 15 ErrorDetail

Parameter

Type

Description

error_code

String

Error code returned for an error request.

error_msg

String

Error information returned for an error request.

Status code: 504

Table 16 Response body parameters

Parameter

Type

Description

error

ErrorDetail object

Error message

Table 17 ErrorDetail

Parameter

Type

Description

error_code

String

Error code returned for an error request.

error_msg

String

Error information returned for an error request.

Example Requests

None

Example Responses

Status code: 200

Request succeeded.

{
  "rotation_task_id" : "a71a4b47-6cac-4f11-92c1-21a165bb6401"
}

Status Codes

Status Code

Description

200

Request succeeded.

400

Invalid request parameter.

401

A username and password are required.

403

Authentication failed.

404

The requested resource does not exist or is not found.

500

Internal service error.

502

The request failed to be fulfilled because the server received an invalid response from the upstream server.

504

Gateway timed out.

Error Codes

See Error Codes.