
# QR & barcode

Two generators — no input file, just the data to encode. `POST https://api.relaystation.ai/v1/qr` and `POST https://api.relaystation.ai/v1/barcode`.

## Billing

Flat per call (no per-page/per-MB unit — there's no input file), at the operator-tunable `cputools.price.{qr,barcode}.generate.flat_micros` (launch default $0.0002). The live `402` challenge is authoritative.

| Op | Billed on | Rate |
|---|---|---|
| `qr` | per call | $0.0002 flat |
| `barcode` | per call | $0.0002 flat |

The encoded `data` is capped at 4096 characters; over it returns `422 DATA_TOO_LONG` before any charge.

## qr

Generate a QR code as PNG or SVG. `format` is `png` (default) or `svg`; `size` (px), `margin` (modules), and `ecc` (error-correction level `L` | `M` | `Q` | `H`) are optional.

```json
POST /v1/qr
{ "data": "https://relaystation.ai", "format": "svg", "ecc": "M" }
```

## barcode

Generate a 1D barcode (Code128, EAN, UPC, and friends). `type` selects the symbology; `format` is `png` (default) or `svg`.

```json
POST /v1/barcode
{ "data": "0123456789", "type": "code128", "format": "png" }
```

Both return the image in the uniform **output envelope** (inline base64, or a presigned `outputUrl` for a large SVG).

## Sample

```bash
curl -X POST https://api.relaystation.ai/v1/qr \
  -H 'X-Payment: <base64 EIP-3009 auth>' \
  -H 'Idempotency-Key: qr-20260606' \
  -H 'Content-Type: application/json' \
  -d '{"data":"https://relaystation.ai","format":"png"}'
```

## Errors

- `402 PAYMENT_REQUIRED` — no valid payment.
- `422 DATA_TOO_LONG` — the data exceeds 4096 characters (charged nothing).
- `400 VALIDATION_ERROR` — the body failed schema validation.

## Next

[PDF tools](/docs/pdf-tools) · [CSV tools](/docs/csv-tools) · [Image tools](/docs/image-tools) · [Pricing](/pricing) · [API reference](/api-reference)
