Generate Random Secret

Prev Next

Available in VPC

Generate a random string that can be used as a secret value. The random string can be generated by adding conditions such as whether it contains English letters, numbers, special characters, or spaces, and can be specified as the secret value for the Pending stage in Update Pending Stage after it is generated. For more information on how to automatically populate the secret rotation target value and register it as a Pending stage, see Add Pending Stage.

Request

This section describes the request format. The method and URI are as follows:

Method URI
POST /action/v1/secrets/{secretId}/jobs/{jobToken}/generate-random-secret

Request headers

For information about the headers common to all Secret Manager APIs, see Secret Manager request headers.

Request path parameters

You can use the following path parameters with your request:

Field Type Required Description
secretId String Required Secret ID
jobToken String Required Job token

Request body

You can include the following data in the body of your request:

Field Type Required Description
length Integer Required Random string length (character)
  • 5-32 (default: 12)
excludeCharacters String Optional Excluded characters
  • If there are multiple, concatenate them into a single string with no separator.
excludeNumbers Boolean Optional Whether to exclude numbers
  • true | false (default)
    • true: Exclude
    • false: Not exclude
excludePunctuation Boolean Optional Whether to exclude special characters
  • true | false (default)
    • true: Exclude
    • false: Not exclude
excludeUppercase Boolean Optional Whether to exclude uppercase letters
  • true | false (default)
    • true: Exclude
    • false: Not exclude
excludeLowercase Boolean Optional Whether to exclude lowercase letters
  • true | false (default)
    • true: Exclude
    • false: Not exclude
includeSpace Boolean Optional Whether to include spaces
  • true (default) | false
    • true: Include
    • false: Not include
requireEachIncludedType Boolean Optional Whether to include all character types (uppercase, lowercase, numbers, special characters, and spaces) that you haven't excluded
  • true (default) | false
    • true: Include all
    • false: Not include all

Request example

The request example is as follows:

curl --location --request POST 'https://secretmanager.apigw.ntruss.com/action/v1/secrets/{secretId}/jobs/{jobToken}/generate-random-secret' \
--header 'x-ncp-apigw-timestamp: {Timestamp}' \
--header 'x-ncp-iam-access-key: {Access Key}' \
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "length": 5,
    "excludeCharacters": "",
    "excludeNumbers": false,
    "excludePunctuation": false,
    "excludeUppercase": false,
    "excludeLowercase": false,
    "includeSpace": false,
    "requireEachIncludedType": true
}'

Response

This section describes the response format.

Response body

The response body includes the following data:

Field Type Required Description
randomString String - Random string

Response status codes

For information about the HTTP status codes common to all Secret Manager APIs, see Secret Manager response status codes.

Response example

The response example is as follows:

{
    "randomString": "2!?xY"
}