All Products
Search
Document Center

Key Management Service:GetRandomPassword

Last Updated:Mar 12, 2026

Generates a random password string.

Operation description

For more information about the access policy required by a RAM user or RAM role to call this API, see Resource Access Management.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

PasswordLength

string

No

The number of bytes that the password to be generated contains.

Valid values: 8 to 128.

Default value: 32

32

ExcludeCharacters

string

No

The characters that are not included in the password to be generated.

Valid values:

Valid characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ! \"#$%&'()*+,-. /:;<=>? @[\] your_project_id} ~ .

This parameter is empty by default.

ABCabc

ExcludeLowercase

string

No

Specifies whether to exclude lowercase letters.

Valid values:

  • true

  • false

false

ExcludeUppercase

string

No

Specifies whether to exclude uppercase letters.

Valid values:

  • true

  • false

false

ExcludeNumbers

string

No

Specifies whether to exclude digits.

Valid values:

  • true

  • false

false

ExcludePunctuation

string

No

Specifies whether to exclude special characters.

Valid values:

  • true

  • false

false

RequireEachIncludedType

string

No

Specifies whether to include all the preceding character types.

Valid values:

  • true

  • false

true

Response elements

Element

Type

Description

Example

object

RandomPassword

string

The generated random password.

IxGn>NMmNB(y?iZ

RequestId

string

The request ID.

6b0cbe25-5e33-467e-972e-7a83c6c97604

Examples

Success response

JSON format

{
  "RandomPassword": "IxGn>NMmNB(y?iZ
            

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter some of the specified parameters "\" is not valid
500 InternalFailure Internal Failure

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.