---
title: "POST /v1/{+location}:generateRandomBytes"
method: POST
path: "/v1/{+location}:generateRandomBytes"
tags: ["projects"]
---

# POST /v1/{+location}:generateRandomBytes

`POST /v1/{+location}:generateRandomBytes`

Generate random bytes using the Cloud KMS randomness source in the provided location.

## Path parameters

- `location` string, required

## Request body

- GenerateRandomBytesRequest — Request message for KeyManagementService.GenerateRandomBytes.
  - `protectionLevel` 'PROTECTION_LEVEL_UNSPECIFIED' | 'SOFTWARE' | 'HSM' | 'EXTERNAL' | 'EXTERNAL_VPC' | 'HSM_SINGLE_TENANT' — The ProtectionLevel to use when generating the random data. Currently, only HSM protection level is supported.
  - `lengthBytes` integer — The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/cloudkms.md) · [All operations](https://skmtc.net/google/apis/cloudkms/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/cloudkms/versions/576b283e53dd/schema)
