> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bunny.build/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /random-password/generate

> Generate cryptographically secure random passwords with configurable length and character sets, plus entropy-in-bits for strength policy enforcement.

## Endpoint

```
POST https://api.bunny.build/api/v1/random-password/generate
```

## Authentication

| Header         | Required | Value                    |
| -------------- | -------- | ------------------------ |
| `X-API-Key`    | Yes      | Your API key (`bun_...`) |
| `Content-Type` | Yes      | `application/json`       |

## Overview

Generate cryptographically secure random passwords on demand. Bunny's Password Generator lets you control length and character sets (uppercase, lowercase, numbers, and symbols) and returns the password alongside its charset size and entropy in bits so you can enforce your own strength policy.

## Use cases

* Generate temporary passwords for new user accounts
* Power password suggestion UI in signup flows
* Create secure API tokens and secret keys
* Automate credential generation in DevOps pipelines

## Details

Length range: 4–256 characters. Entropy is calculated as `floor(log2(charset_size) * length)`. If no character sets are specified, lowercase and numbers are used by default. All randomness is sourced from the platform's cryptographically secure RNG.

## Request body

| Field       | Type    | Required | Description                                   |
| ----------- | ------- | -------- | --------------------------------------------- |
| `length`    | integer | No       | Password length (default: `16`, range: 4–256) |
| `uppercase` | boolean | No       | Include uppercase letters (default: `true`)   |
| `lowercase` | boolean | No       | Include lowercase letters (default: `true`)   |
| `numbers`   | boolean | No       | Include digits (default: `true`)              |
| `symbols`   | boolean | No       | Include special characters (default: `false`) |

### Example

```json theme={null}
{
  "length": 16,
  "uppercase": true,
  "lowercase": true,
  "numbers": true,
  "symbols": true
}
```

## Response

### 200 OK

| Field          | Type    | Description                                                    |
| -------------- | ------- | -------------------------------------------------------------- |
| `password`     | string  | The generated password                                         |
| `length`       | integer | Actual length of the password                                  |
| `charset_size` | integer | Number of unique characters in the pool used for generation    |
| `entropy_bits` | integer | Password entropy in bits: `floor(log2(charset_size) * length)` |

**Example**

```json theme={null}
{
  "password": "aB3$kLm9!Xz2#qRt",
  "length": 16,
  "charset_size": 88,
  "entropy_bits": 102
}
```

### 401 Unauthorized

```json theme={null}
{
  "detail": "Missing API key. Include X-API-Key header."
}
```

### 402 Payment Required

```json theme={null}
{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}
```

### 422 Unprocessable Entity

Invalid parameters.

```json theme={null}
{
  "detail": "Length must be between 4 and 128"
}
```

### 429 Too Many Requests

```json theme={null}
{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}
```

## cURL example

```bash theme={null}
curl -X POST https://api.bunny.build/api/v1/random-password/generate \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"length": 16, "uppercase": true, "lowercase": true, "numbers": true, "symbols": true}'
```
