TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dadu0699/qr-code/llms.txt
Use this file to discover all available pages before exploring further.
/api/qr/generate endpoint accepts a URL and returns a complete SVG document encoding that URL as a QR code. The SVG can be embedded inline in HTML, served as a file download, or converted to a raster image. Call this endpoint whenever you need a scannable QR code at runtime — no pre-generation or storage required.
Request
Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
Body
The HTTP or HTTPS URL to encode in the QR code. Must be a valid absolute URL — relative paths are not accepted. Maximum length is 2048 characters. URLs using any protocol other than
http: or https: (e.g. ftp://, file://) are rejected.Optional color overrides for the QR code. When omitted, the default dark-on-light palette is used (
#000000 on #FFFFFF).In the underlying
qrcode library, dark refers to the QR modules (foreground) and light refers to the background. For maximum scanner compatibility, keep sufficient contrast between the two colors — dark modules on a light background is the conventional choice.Response
200 OK
Returns the QR code as an SVG document.| Header | Value |
|---|---|
| Content-Type | image/svg+xml |
A complete SVG document string. The root element is
<svg xmlns="http://www.w3.org/2000/svg" ...> containing the QR code paths rendered at the requested colors. The response body is plain text — read it with response.text(), not response.json().Error Responses
| Status | Error message | Cause |
|---|---|---|
| 400 | Invalid JSON body | Request body is not valid JSON |
| 400 | Invalid request body | Body is not a JSON object |
| 400 | URL is required | url field is missing or empty |
| 400 | URL exceeds maximum length of 2048 characters | URL is longer than 2048 characters |
| 400 | Invalid URL | url is not a valid absolute URL |
| 400 | URL protocol must be http or https | url uses ftp://, file://, or another non-HTTP protocol |
| 400 | Invalid color | color field is present but is not an object |
| 400 | Invalid dark color | color.dark is not a valid hex color string |
| 400 | Invalid light color | color.light is not a valid hex color string |
| 500 | Failed to generate QR code | Internal QR generation error |
Content-Type: application/json and the body shape { "error": "<message>" }.
Code Examples
CORS and OPTIONS
Like all API endpoints,/api/qr/generate includes CORS headers on every response:
| Header | Value |
|---|---|
| Access-Control-Allow-Methods | POST, OPTIONS |
| Access-Control-Allow-Headers | Content-Type |
| Access-Control-Max-Age | 86400 |
| Vary | Origin |
Access-Control-Allow-Origin is reflected only when the request Origin matches an entry in the ALLOWED_ORIGINS Worker environment variable.
Sending an OPTIONS request to this endpoint returns 204 No Content with the same CORS headers — no body — to satisfy browser preflight checks.