---
title: "Generate a QR code asset via Netlify Function"
method: POST
path: "/.netlify/functions/generate-qr"
---

# Generate a QR code asset via Netlify Function

`POST /.netlify/functions/generate-qr`

## Request body

- GenerateQrRequest
  - `value` string, required — Data encoded in the QR code
  - `format` 'svg' | 'png' | 'jpg' | 'webp' | 'pdf' | 'eps' — Output format for the QR code asset
  - `size` integer — Pixel width/height of the generated asset
  - `margin` integer — Quiet-zone margin around the QR code modules
  - `fgColor` string — Hex foreground color, for example #000000
  - `bgColor` string — Hex background color, for example #FFFFFF
  - `errorCorrectionLevel` 'L' | 'M' | 'Q' | 'H' — QR error correction level
  - `logo` string, nullable — Optional base64 data URL for a logo (PNG, JPG, or WEBP) to composite at the center. Files larger than 1MB are rejected.

## Response `200`

Generated QR code asset encoded as base64

- GenerateQrResponse
  - `success` boolean
  - `data` string — Base64 encoded asset bytes
  - `dataUrl` string — Ready-to-embed data URL built from contentType and base64 data
  - `downloadUrl` string — Relative GET URL for retrieving the generated asset without embedding base64 bytes. Emitted only for no-logo public HTTP(S) URL payloads that do not include obvious credential-style query parameters.
  - `contentType` string
  - `extension` string
  - `suggestedFilename` string
  - `byteLength` integer — Exact number of decoded bytes in the base64 data field
  - `dimensions` GeneratedAssetDimensions — Rendered asset dimensions. Raster and SVG assets use pixels; PDF and EPS use points.
    - `width` number, required
    - `height` number, required
    - `unit` 'px' | 'pt', required
  - `qrOptions` object — Normalized QR options used to generate the asset
    - `size` integer
    - `margin` integer
    - `errorCorrectionLevel` 'L' | 'M' | 'Q' | 'H'

## Other responses

- `400` — Invalid request
- `401` — Missing or invalid API key when key enforcement is enabled
- `405` — Method not allowed
- `429` — Too many requests. QR generation uses a cost-weighted per-client budget; honor the retry and rate-limit headers before resubmitting work.
- `500` — Server error

---

[API](https://skmtc.net/qrcodecrafter/apis/qrcodecrafter-api-2.md) · [All operations](https://skmtc.net/qrcodecrafter/apis/qrcodecrafter-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/qrcodecrafter/qrcodecrafter-api-2/versions/87cd2664770b/schema)
