Method: locations.generateRandomBytes Stay organized with collections Save and categorize content based on your preferences.
Full name: projects.locations.generateRandomBytes
Generate random bytes using the Cloud KMS randomness source in the provided location.
HTTP request
POST https://cloudkms.googleapis.com/v1/{location=projects/*/locations/*}:generateRandomBytesThe URLs usegRPC Transcoding syntax.
Path parameters
| Parameters | |
|---|---|
location |
The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1". |
Request body
The request body contains data with the following structure:
| JSON representation |
|---|
{"lengthBytes":integer,"protectionLevel":enum ( |
| Fields | |
|---|---|
lengthBytes |
The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes. |
protectionLevel |
The |
Response body
Response message forKeyManagementService.GenerateRandomBytes.
If successful, the response body contains data with the following structure:
| JSON representation |
|---|
{"data":string,"dataCrc32c":string} |
| Fields | |
|---|---|
data |
The generated data. A base64-encoded string. |
dataCrc32c |
Integrity verification field. A CRC32C checksum of the returned |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloudkmshttps://www.googleapis.com/auth/cloud-platform
For more information, see theAuthentication Overview.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-11 UTC.