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

> Generate barcodes and QR codes on demand. Supports QR, Code 128, EAN-13, PDF417, Data Matrix, and more, returned as a base64-encoded PNG.

## Endpoint

```
POST https://api.bunny.build/api/v1/barcode
```

## Authentication

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

## Overview

Generate barcodes and QR codes on demand. Bunny's Barcode API converts any text or URL into a pixel-perfect image: QR codes, Code 128, EAN-13, PDF417, Data Matrix, and more. Returns a base64-encoded PNG ready to embed in web pages, PDFs, or print flows.

## Use cases

* Product labels and inventory management
* QR code generation for links and contact cards
* Shipping and logistics barcode printing
* Event tickets and access passes

## Details

Supported types: `qrcode`, `code128`, `code39`, `ean13`, `ean8`, `upca`, `upce`, `pdf417`, `datamatrix`, `azteccode`, `interleaved2of5`. All barcodes are rendered as PNG at a fixed scale with human-readable text below the symbol where applicable.

## Request body

| Field  | Type   | Required | Description                                                            |
| ------ | ------ | -------- | ---------------------------------------------------------------------- |
| `data` | string | Yes      | The data to encode in the barcode                                      |
| `type` | string | No       | Barcode type (e.g. `qrcode`, `code128`, `ean13`). Default: `"code128"` |

### Example

```json theme={null}
{
  "type": "qrcode",
  "data": "https://example.com"
}
```

## Response

### 200 OK

| Field            | Type   | Description                      |
| ---------------- | ------ | -------------------------------- |
| `barcode_base64` | string | Base64-encoded PNG barcode image |
| `mime_type`      | string | Always `"image/png"`             |
| `type`           | string | The barcode type used            |
| `data`           | string | The encoded data                 |

**Example**

```json theme={null}
{
  "barcode_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
  "mime_type": "image/png",
  "type": "qrcode",
  "data": "https://example.com"
}
```

### 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": "Invalid barcode type or data"
}
```

### 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/barcode \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"type": "qrcode", "data": "https://example.com"}'
```
