Updated on 2025-11-06 GMT+08:00

Modifying the Account Password Policy

Function

This API is used to modify the account password policy.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

iam:securitypolicies:updatePasswordPolicyV5

Write

-

-

-

-

URI

PUT /v5/password-policy

Request Parameters

Table 1 Request body parameters

Parameter

Mandatory

Type

Description

maximum_consecutive_identical_chars

No

Integer

The maximum number of times that a character is allowed to consecutively present in a password. Value range: [0,32].

Minimum: 0

Maximum: 32

minimum_password_age

No

Integer

The minimum period (minutes) after which users are allowed to make a password change. Value range: [0,1440].

Minimum: 0

Maximum: 1440

minimum_password_length

No

Integer

The minimum number of characters that a password must contain. Value range: [8,32].

Minimum: 8

Maximum: 32

password_reuse_prevention

No

Integer

The number of times that a password cannot be reused. Value range: [0,24].

Minimum: 0

Maximum: 24

password_not_username_or_invert

No

Boolean

Whether to disallow the username or the username spelled backwards for passwords. The default value is true, indicating that the password cannot be the username or the username spelled backwards.

password_validity_period

No

Integer

Password validity period (days). Value range: [0,180].

Minimum: 0

Maximum: 180

password_char_combination

No

Integer

The minimum number of character types that a password must contain. Value range: [2,4].

Minimum: 2

Maximum: 4

allow_user_to_change_password

No

Boolean

Indicates whether IAM users are allowed to change their passwords. This is not applicable to the root user.

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

password_policy

PasswordPolicy object

Password policy.

Table 3 PasswordPolicy

Parameter

Type

Description

maximum_consecutive_identical_chars

Integer

Maximum number of consecutive identical characters.

maximum_password_length

Integer

Maximum number of characters that a password can contain.

minimum_password_age

Integer

Minimum password age (minute).

minimum_password_length

Integer

Minimum number of characters that a password must contain.

password_reuse_prevention

Integer

Number of recent passwords disallowed.

password_not_username_or_invert

Boolean

Whether to disallow the username or the username spelled backwards for passwords. The default value is true, indicating that the password cannot be the username or the username spelled backwards.

password_requirements

String

Characters that a password must contain.

password_validity_period

Integer

Password validity period (days).

password_char_combination

Integer

Minimum number of character types that a password must contain.

allow_user_to_change_password

Boolean

Indicates whether IAM users are allowed to change their passwords. This is not applicable to the root user.

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

request_id

String

Request ID.

encoded_authorization_message

String

Encrypted authentication failure information, which can be decrypted using the STS5 decryption API.

Example Requests

Modifying the account password policy

PUT https://{endpoint}/v5/password-policy

{
  "maximum_consecutive_identical_chars" : 0,
  "minimum_password_age" : 0,
  "minimum_password_length" : 8,
  "password_reuse_prevention" : 1,
  "password_not_username_or_invert" : true,
  "password_validity_period" : 180,
  "password_char_combination" : 2,
  "allow_user_to_change_password" : true
}

Example Responses

Status code: 200

Successful

{
  "password_policy" : {
    "maximum_consecutive_identical_chars" : 0,
    "maximum_password_length" : 32,
    "minimum_password_age" : 0,
    "minimum_password_length" : 8,
    "password_reuse_prevention" : 1,
    "password_not_username_or_invert" : true,
    "password_requirements" : "A password must contain at least two of the following: uppercase letters, lowercase letters, digits, and special characters.",
    "password_validity_period" : 180,
    "password_char_combination" : 2,
    "allow_user_to_change_password" : true
  }
}

Status Codes

Status Code

Description

200

Successful

400

Bad request

403

Forbidden

Error Codes

See Error Codes.