> ## 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 /color-converter

> Convert colors between HEX, RGB, and HSL formats in a single API call.

## Endpoint

```
POST https://api.bunny.build/api/v1/color-converter
```

## Authentication

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

## Overview

Convert colors between HEX, RGB, and HSL formats instantly. Submit a color in any of the three supported formats and receive the equivalent values in all three, eliminating manual conversion math in design tools, theming systems, and CSS generators.

## Use cases

* Convert brand colors between formats for cross-platform design systems
* Generate CSS custom properties in all formats from a single source
* Validate color inputs in design or configuration UIs
* Transform palette exports from design tools into developer-friendly formats

## Details

HEX values should include the `#` prefix (e.g. `#ff5733`). RGB components are integers 0–255. HSL hue is 0–360 degrees; saturation and lightness are percentages 0–100.

## Request body

Provide exactly one of `hex`, `rgb`, or `hsl`.

| Field | Type   | Required | Description                                                  |
| ----- | ------ | -------- | ------------------------------------------------------------ |
| `hex` | string | No       | Hex color string (e.g. `#ff5733`)                            |
| `rgb` | object | No       | RGB object with `r`, `g`, `b` integer fields (0–255)         |
| `hsl` | object | No       | HSL object with `h` (0–360), `s` (0–100), `l` (0–100) fields |

### Example — from HEX

```json theme={null}
{
  "hex": "#ff5733"
}
```

### Example — from RGB

```json theme={null}
{
  "rgb": { "r": 255, "g": 87, "b": 51 }
}
```

### Example — from HSL

```json theme={null}
{
  "hsl": { "h": 11, "s": 100, "l": 60 }
}
```

## Response

### 200 OK

| Field  | Type   | Description                                                                                                      |
| ------ | ------ | ---------------------------------------------------------------------------------------------------------------- |
| `hex`  | string | HEX representation (uppercase, e.g. `#FF5733`)                                                                   |
| `rgb`  | object | RGB object with integer fields `r`, `g`, `b` (0–255)                                                             |
| `hsl`  | object | HSL object with integer fields `h` (0–360), `s` (0–100), `l` (0–100)                                             |
| `cmyk` | object | CMYK object with integer fields `c`, `m`, `y`, `k` (0–100)                                                       |
| `css`  | object | Ready-to-use CSS strings: `hex` (string), `rgb` (e.g. `"rgb(255, 87, 51)"`), `hsl` (e.g. `"hsl(11, 100%, 60%)"`) |

**Example**

```json theme={null}
{
  "hex": "#FF5733",
  "rgb": { "r": 255, "g": 87, "b": 51 },
  "hsl": { "h": 11, "s": 100, "l": 60 },
  "cmyk": { "c": 0, "m": 66, "y": 80, "k": 0 },
  "css": {
    "hex": "#FF5733",
    "rgb": "rgb(255, 87, 51)",
    "hsl": "hsl(11, 100%, 60%)"
  }
}
```

### 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

```json theme={null}
{
  "detail": "Provide exactly one of: hex, rgb, hsl"
}
```

### 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/color-converter \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"hex": "#ff5733"}'
```
