Get a branded QR code for a link

THE CALL, PART BY PART

method

GET

host

strait.link

version

/v1

resource

/links/{slug}/qr

GET /v1/links/{slug}/qr

Auth: secret key as Authorization: Bearer. Server-side only.

Request

A print-ready QR code (PNG or SVG) that opens the link's short URL. It uses the workspace's QR style (Dashboard → Settings → QR codes: colour, background, app icon in the middle); query parameters override it for this one code. By default the code adds utm_source=qr, so scans show as the qr channel in analytics (an existing utm_source on the link is kept). The code must be darker than its background with a contrast of at least 3:1, or the request is refused with 400. With a logo the code uses error correction H. The logo is the app icon from Settings: PNG, JPEG or WebP in SVG codes, PNG only in PNG codes; X-Strait-Qr-Logo says whether it was embedded. Rate limit: 60 codes a minute per workspace; PNG renders also share a server-wide budget (large PNGs may get 429, retry or use SVG).

Parameters

slug required string path
The link's slug: the part after your link domain, e.g. summer
format "png" | "svg" query
Image format
size integer query
Width and height in pixels
margin integer query
Quiet zone around the code, in modules
color string query
Code colour as hex (1f2937, or %231f2937). Default: the workspace's QR colour, else black.
background string query
Background colour as hex. Default: the workspace's QR background, else white.
logo boolean query
Put the app icon in the middle. Default: the workspace's QR setting.
preset string query
Start from a saved QR style (Settings → QR codes) instead of the workspace default; color, background and logo still override it. Unknown id: 400.
track boolean query
Add utm_source=qr so scans count as the qr channel
download boolean query
true: Content-Disposition attachment (a browser saves the file)
tenantId string query
Dashboard sessions only: the workspace id (a secret key already names its workspace)

Response

  • 200 The QR code
  • 400 Invalid parameter, or colours that would not scan (code lighter than the background, or contrast under 3:1)
  • 401 Missing or invalid secret key / session
  • 404 No active link with this slug in the workspace
  • 429 More than 60 codes a minute for this workspace (Retry-After: 1), or PNG rendering is busy server-wide (Retry-After: 2; SVG is not limited by it)
Request · curl
curl -X GET "https://strait.link/v1/links/summer/qr?format=png&size=1024" \
  -H "Authorization: Bearer $SECRET_KEY" \
  --fail -o summer-qr.png

The response, printed

Response 200 headers (format=png)
HTTP/1.1 200 OK
Content-Type: image/png
Content-Disposition: inline; filename="summer-qr.png"
X-Strait-Qr-Url: https://hilltop.strait.link/summer?utm_source=qr
X-Strait-Qr-Logo: off
Response 200 headers (format=svg)
HTTP/1.1 200 OK
Content-Type: image/svg+xml
Content-Disposition: inline; filename="summer-qr.svg"
X-Strait-Qr-Url: https://hilltop.strait.link/summer?utm_source=qr
X-Strait-Qr-Logo: off
Response 200 body (format=svg)
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 37 37" shape-rendering="crispEdges"><rect width="37" height="37" fill="#ffffff"/><path fill="#1f2937" d="M2 2h7v1h-7z…"/></svg>