API documentation

This is the raw integration guide, rendered as-is — also available unstyled at this same URL for scripts/agents (we content-negotiate on Accept). See also /llms.txt.

# qr42-app public API — integration guide

This is the third-party-facing companion to the code. If you're a brand
integrating qr42-app into your own systems (a PIM, an ERP, a CI pipeline
that publishes product data), this is what you can actually call today.

**Honest scope**: this is the API-key-authenticated automation surface. Account administration (orgs, billing, team management, brand-host onboarding, disputes, webhook management, admin) is dashboard-only — session-cookie authenticated. **Everything below** accepts an API key: inspect your org & entitlements; claim identifiers and create products; add, edit, bulk-import and remove links; export print-ready QR & 1D barcode labels (SVG and PNG); manage hosted landing pages and short links; and read scan analytics.

## Rate limits

API keys are rate-limited to **120 requests per minute per key** (60-second UTC windows). Every API-key response includes:

- X-RateLimit-Limit — requests allowed per minute
- X-RateLimit-Remaining — requests remaining in the current window
- X-RateLimit-Reset — UTC unix timestamp when the window resets

Exceeding the limit returns 429 Too Many Requests with a Retry-After header.

## Getting a key

Team roles apply: any member can read, an editor can change products, links and claims, and only an admin or owner can create or revoke API keys, manage webhooks, invite members or change billing.

There's currently no way to create a key without a dashboard session —
API keys are minted from inside the app, not self-service via API:

1. Sign in at https://qrcode42.com/dashboard (magic link or passkey).
2. Create or select your org.
3. **API Keys** tab -> give it a name, pick scopes, create.
4. Copy the raw key immediately — it's shown exactly once
   (qr42_live_...). Only its SHA-256 hash is ever stored; if you lose
   it, revoke it and mint a new one.

Every key is scoped to **one org** and to specific **scopes**:

| Scope | Grants |
|---|---|
| (any valid key) | GET /api/v1/org (whoami, granted scopes, live plan entitlements) |
| gtins:write | POST /api/v1/gtins, POST /api/v1/products |
| gtins:read | GET /api/v1/gtins, GET /api/v1/products, GET /api/v1/products/:id/label (+ /qr.png, /barcode.png) |
| links:read | GET /api/v1/products/:id/links |
| links:write | POST, PATCH, DELETE on /api/v1/products/:id/links, POST /api/v1/bulk-import |
| shortlinks:read | GET /api/v1/short-links |
| shortlinks:write | POST /api/v1/short-links, PATCH/DELETE /api/v1/short-links/:id |
| landingpages:read | GET /api/v1/landing-pages, GET /api/v1/landing-pages/:id |
| landingpages:write | POST /api/v1/landing-pages |
| analytics:read | GET /api/v1/analytics, GET /api/v1/orgs/:orgId/analytics |

A key can hold multiple scopes at once. Request only what you need.

## Authenticating

Every request below takes the raw key as a bearer token:

Authorization: Bearer qr42_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

A missing/invalid/revoked key gets a 401:
{ "error": "Invalid or revoked API key" }

A key missing the required scope for the endpoint you called gets a 403:
{ "error": "API key missing gtins:write scope" }

There is deliberately no way to tell "key doesn't exist" apart from "key
was revoked" from the error alone — same reasoning as this app's magic
links and passkey challenges: don't leak which failure mode occurred.

## Endpoints

### POST /api/v1/gtins — claim a GTIN

Claims a GTIN-14 on a host for your org. On the shared qr-42.com host
this starts "pending" and needs admin review before it resolves publicly
— claiming isn't the same as going live. On a brand host you already own
(Custom Hostname onboarded), it auto-verifies immediately.

Requires scope: gtins:write

curl -X POST https://qrcode42.com/api/v1/gtins \
  -H "Authorization: Bearer qr42_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "gtin14": "00000012345007",
    "hostname": "qr-42.com",
    "evidenceUrl": "https://yourbrand.com/products/trail-mix"
  }'

| Field | Required | Notes |
|---|---|---|
| gtin14 | yes | Exactly 14 digits, real GS1 mod-10 check digit — see GTIN-14 validation below. Rejected at claim time, not later. |
| keyAi | no | The GS1 key the identifier belongs to: "01" (GTIN, the default), "414" (GLN, a location: 13 digits, mod-10 check digit), "8004" (GIAI, an asset: 4 to 30 characters), "8003" (GRAI, a returnable asset: 14 digits starting with 0, plus an optional serial of up to 16 characters) or "00" (SSCC, a shipment: 18 digits, mod-10 check digit). For any key other than 01 the gtin14 field carries that key's identifier. Omit keyAi and everything behaves exactly as before. Anything else is rejected with 400. Only a GLN accepts a scope (scope.ext); the other keys take no qualifiers. A GIAI or GRAI serial can't contain an apostrophe. A link list for a non-GTIN is returned as { key: { ai, id }, links } instead of { gtin14, links }, and its label is the QR code only (only a GTIN has a 1D barcode). |
| hostname | yes | A QR Code 42 shared domain (qr-42.com or qr42.link), or a brand host your org already owns. Any other hostname is rejected with 403. |
| kind | no | "shared" (default) or "brand". Must match reality. |
| evidenceUrl | no | A URL an admin can check to confirm ownership (a listing page, a packaging photo). |

Success (201):
{
  "id": "claim_...", "org_id": "org_...", "gtin14": "00000012345007",
  "host_id": "host_...", "status": "pending",
  "evidence_ref": "https://yourbrand.com/products/trail-mix",
  "verified_by": null, "verified_at": null, "created_at": "2026-09-30 12:00:00"
}

Common errors (400): a bad checksum, a GTIN already claimed (pending or
verified) on that host by anyone, or a kind:"brand" claim against a
hostname that isn't an onboarded brand host for your org.

### POST /api/v1/products — create or update a product

Attaches a name/brand to a GTIN for your org. This is a real upsert:
call it again with the same gtin14 to update name/brandName on the
existing row (a field you omit is left untouched, not blanked). Returns
201 the first time, 200 on every update after. Takes the same optional keyAi
as POST /api/v1/gtins ("01" default, "414" GLN, "8004" GIAI, "8003" GRAI or "00" SSCC); a claim only
covers its own key.

Requires scope: gtins:write

curl -X POST https://qrcode42.com/api/v1/products \
  -H "Authorization: Bearer qr42_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "gtin14": "00000012345007", "name": "Trail Mix, 12oz", "brandName": "Your Brand" }'

Response:
{
  "id": "prod_...", "org_id": "org_...", "gtin14": "00000012345007",
  "name": "Trail Mix, 12oz", "brand_name": "Your Brand",
  "image_url": null, "default_lang": null
}

### GET /api/v1/products/:id/links — list a product's links

Requires scope: links:read

curl https://qrcode42.com/api/v1/products/prod_xxxxx/links \
  -H "Authorization: Bearer qr42_live_..."

:id must be a product your org owns — otherwise 403, not the data.

Response (each link carries an id for PATCH/DELETE, plus the resolver fields):
{
  "gtin14": "00000012345007",
  "links": [
    { "id": "link_...", "linkType": "gs1:pip", "href": "https://yourbrand.com/products/trail-mix", "title": "Trail Mix product page", "lang": "en", "country": "US", "isDefault": true }
  ]
}

### POST /api/v1/products/:id/links — add a link

Adds one link to a product on a specific host. **You need a verified
claim for this GTIN on that host first** — this call 403s otherwise. On
the shared host, "verified" means an admin has reviewed your claim; this
can't be skipped via the API.

Requires scope: links:write

curl -X POST https://qrcode42.com/api/v1/products/prod_xxxxx/links \
  -H "Authorization: Bearer qr42_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "hostname": "qr-42.com", "linkType": "gs1:pip",
    "href": "https://yourbrand.com/products/trail-mix",
    "title": "Trail Mix product page", "lang": "en", "country": "US", "isDefault": true
  }'

| Field | Required | Notes |
|---|---|---|
| hostname | yes | Must have a verified claim for this product's identifier. It authorizes the add; the link then goes live on every host the product is verified on. |
| linkType | yes | A GS1 link type (gs1:pip, gs1:pdf, etc.) or your own custom string. |
| href | yes | Must be http:// or https:// — anything else is rejected server-side. |
| title | yes | Required by the resolver's linkset schema (RFC 9264). |
| lang, country | no | Scopes the link for language/country negotiation. |
| mediaType | no | e.g. text/html, application/pdf. |
| isDefault | no | true or false (anything else is a 400). Marks this the fallback link and clears the flag on the others. |
| scope | no | { cpv, lot, serial } for a GTIN, or { ext } for a GLN — qualifier scoping (Starter and above). |

Once added, live on the resolver within seconds — no separate "publish"
step. Adding the exact same link again returns 200 and adds nothing, so a timed-out request is safe to retry. If the link was saved but a host couldn't be updated, the response is 502 with { saved: true, failedHosts }; send the request again (or edit any link) to finish. Response (201) is the product's full current link list, same
shape as GET .../links above.

### PATCH /api/v1/products/:id/links/:linkId — edit a link

Requires scope: links:write

Changes only the fields you send; everything else keeps its value. null clears an optional field (lang, country, mediaType, scope). Setting isDefault: true makes it the product's one default link and clears the flag on the others. Every link in a response carries an id, which is what this takes. The change is republished on every host the product is verified on.

curl -X PATCH https://qrcode42.com/api/v1/products/prod_xxxxx/links/link_xxxxx -H "Authorization: Bearer qr42_live_..." -H "Content-Type: application/json" -d '{ "href": "https://yourbrand.com/products/trail-mix-v2", "lang": null }'


The response is the product's full link list, the same shape as GET .../links. A bad href or title, or a scope that doesn't fit the identifier's key, is a 400; a link id that isn't on this product is a 404.

### DELETE /api/v1/products/:id/links/:linkId — remove a link

Requires scope: links:write

Removes one link and republishes the product everywhere it is verified. Returns the remaining link list. If it was the last link, the product stays claimed but resolves to "no link published" until you add one.

### GET /api/v1/gtins — your claims and their status

Requires scope: gtins:read

{
  "claims": [
    { "id": "claim_...", "gtin14": "00000012345007", "key_ai": "01", "hostname": "qr-42.com", "host_kind": "shared",
      "status": "verified", "evidence_ref": null, "verified_at": "2026-11-05 14:02:11", "created_at": "2026-11-04 09:30:00" }
  ]
}


status is pending, verified, rejected or revoked. This is how you check whether a claim has been approved without polling the dashboard (or subscribe to the claim.verified webhook event instead).

### GET /api/v1/products — your products

Requires scope: gtins:read

Returns { "products": [ { "id", "gtin14", "key_ai", "name", "brand_name" } ] }.

### Short links

Short links are plain redirects qr42.link/{code} (also qr-42.com/s/{code}) that don't need a GTIN. Create and edit them with a key:

| Route | Scope | Does |
|---|---|---|
| GET /api/v1/short-links | shortlinks:read | Lists your short links with their URLs. |
| POST /api/v1/short-links | shortlinks:write | Body { "code", "targetUrl", "expiresAt"? , "hostname"? }. Code is 3 to 64 lowercase letters, digits or hyphens. |
| PATCH /api/v1/short-links/:id | shortlinks:write | Body { "targetUrl"?, "expiresAt"? (null clears), "active"? }. The code never changes: it's what's printed. |
| DELETE /api/v1/short-links/:id | shortlinks:write | Stops the redirect (410) and frees the plan slot; the code stays reserved so nobody else can take it over. |

Creating one is limited by your plan like in the dashboard; a short link on another org is a 403.

### GET /api/v1/org — key self-check & entitlements

Available to any valid active API key regardless of scopes — ideal for connection tests (Zapier, Make, n8n, CI) and checking remaining plan quotas.

curl https://qrcode42.com/api/v1/org \
  -H "Authorization: Bearer qr42_live_..."

Returns { "org": { "id", "name", "plan", "planLabel", "status", "comped" }, "key": { "id", "name", "prefix", "scopes" }, "entitlements": { ... } }.

### GET /api/v1/products/:id/label — print-ready QR & barcode export

Requires scope: gtins:read (and a verified claim for this product on hostname).

| Route | Returns |
|---|---|
| GET /api/v1/products/:id/label?hostname=qr-42.com | JSON { uri, qrSvg, barcodeSvg, size } (minimum print sizes in mm; barcodeSvg is null for non-GTIN keys) |
| GET /api/v1/products/:id/label/qr.png?hostname=qr-42.com | Binary image/png GS1 Digital Link QR code |
| GET /api/v1/products/:id/label/barcode.png?hostname=qr-42.com | Binary image/png 1D barcode (UPC-A / EAN-13 / ITF-14; GTIN only) |

### Landing pages

| Route | Scope | Does |
|---|---|---|
| GET /api/v1/landing-pages | landingpages:read | Lists your hosted /l/{slug} pages with their live url. |
| GET /api/v1/landing-pages/:id | landingpages:read | Fetches one landing page by id. |
| POST /api/v1/landing-pages | landingpages:write | Creates or updates a /l/{slug} page (hostname, slug, title, plus optional bodyText, imageUrl, ctaText, ctaHref, brandName, theme "dark"|"light", accentColor #rrggbb). Live immediately. |

### POST /api/v1/bulk-import — batch CSV link import

Requires scope: links:write

Body: { "csv": "gtin14,hostname,linkType,href,title,...\n..." }. Publishes links onto already-verified claims in one call. Returns 200 when every row succeeds, or 207 Multi-Status on partial success with per-line errors.

### GET /api/v1/analytics (and GET /api/v1/orgs/:orgId/analytics) — scan analytics

Requires scope: analytics:read

Aggregate scan counts for your org: total scans, scans per UTC day, top link types and top countries, across every GTIN you hold a verified claim on plus every short link you own. No IP addresses or individual scan events are stored or returned. Use /api/v1/analytics to automatically target your API key's org, or /api/v1/orgs/:orgId/analytics with an explicit org ID.

curl "https://qrcode42.com/api/v1/analytics?days=30" \
  -H "Authorization: Bearer qr42_live_..."

When using the :orgId path, it must match the org the key belongs to — any other org returns 403.

| Query param | Notes |
|---|---|
| id | Optional. A GTIN-14 you hold a verified claim on (or {ai}:{id} for non-GTIN keys such as 414:{gln}), or a short-link code you own, to get just that one. Anything else returns 404. |
| days | Optional whole number of days (UTC, ending today). Can narrow the window, never widen it: Free/Starter keep 30 days, Lifetime Tier 1 keeps 90 days, Growth/Scale and Lifetime Tiers 2-3 keep 365 days, Enterprise and Lifetime Tier 4 keep 730 days. Defaults to your plan's full window. |
| from, to | Optional exact range of UTC days like 2026-11-01, both ends included (to defaults to today, from to the start of your plan's window). Unlike days, a range outside your window is a 400 rather than being trimmed, and you can't combine it with days. The response echoes from and to. |

Response:
{
  "windowDays": 30,
  "hasIds": true,
  "totalScans": 412,
  "byDay": [ { "day": "2026-11-04", "scans": 37 } ],
  "byLinkType": [ { "value": "gs1:pip", "scans": 390 } ],
  "byCountry": [ { "value": "US", "scans": 301 } ]
}

## GTIN-14 validation

Every GTIN must be exactly 14 digits with a real GS1 mod-10 check digit.
A syntactically-plausible but checksum-invalid GTIN is rejected
immediately with "Invalid GTIN check digit (expected N, got M)".

Worked example for 00000012345007:
- First 13 digits: 0000001234500.
- Rightmost-first, alternating weights 3,1,3,1...:
  0·3 + 0·1 + 5·3 + 4·1 + 3·3 + 2·1 + 1·3 + 0·1 + 0·3 + 0·1 + 0·3 + 0·1 + 0·3 = 33.
- Check digit = (10 - (33 % 10)) % 10 = 7. Matches the trailing 7 — valid.

## Webhooks: daily scan summaries

Instead of polling the analytics endpoint, you can have us POST a summary of your scans to a URL you choose, once per finished UTC day. It is the same kind of aggregate data as the analytics endpoint (counts only: no IP addresses and no individual scans). A day with no scans sends nothing.

Add endpoints in the dashboard (Analytics tab, Webhooks), or with the session-authenticated routes below. They are deliberately not available to an API key, so a leaked key can't point our servers at arbitrary URLs. Webhooks need a plan with API access, and an org can have up to 3 endpoints.

# add an endpoint: the response includes the signing secret, shown exactly once
curl -X POST https://qrcode42.com/api/v1/orgs/org_xxxxx/webhooks \
  --cookie "qr42_session=..." -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/qr42-webhook" }'


| Route | Does |
|---|---|
| POST /api/v1/orgs/:orgId/webhooks | Adds an endpoint. Returns the secret once. |
| GET /api/v1/orgs/:orgId/webhooks | Lists endpoints with their last delivery. Never returns a secret. |
| PATCH /api/v1/orgs/:orgId/webhooks/:id | Changes which events an endpoint receives. |
| POST /api/v1/orgs/:orgId/webhooks/:id/test | Sends a sample summary now (marked "test": true), at most once a minute. |
| GET /api/v1/orgs/:orgId/webhooks/:id/deliveries | The last 30 deliveries, with status codes and errors. |
| POST /api/v1/orgs/:orgId/webhooks/:id/enable | Turns a switched-off endpoint back on. |
| DELETE /api/v1/orgs/:orgId/webhooks/:id | Removes an endpoint and its delivery log. |

The URL must be https:// on port 443, with a normal public hostname: no IP addresses, no localhost or internal names, no credentials in the URL, and not one of our own domains.

### Events

Each endpoint subscribes to one or more events ("events": [...] when you add it, or PATCH /api/v1/orgs/:orgId/webhooks/:id with { "events": [...] } later). The default is just the daily summary.

| Event | When |
|---|---|
| scan.daily | Once per finished UTC day that had scans (the payload below). |
| claim.verified | The moment a claim is approved, or a brand-host claim verifies itself. |
| claim.rejected | The moment a claim is rejected in review. |

A claim event looks like this, and is sent within seconds (not at the nightly run):

{
  "id": "whd_...",
  "event": "claim.verified",
  "orgId": "org_...",
  "claim": { "id": "claim_...", "keyAi": "01", "identifier": "00000012345007", "hostname": "qr-42.com", "status": "verified", "reviewedAt": "2026-11-05 14:02:11" }
}


You get exactly one delivery per claim per event, however many times the review route is retried. The signature, headers and retries are the same as for the daily summary.

### What we send (the daily summary)

A POST with a JSON body:

{
  "id": "whd_...",
  "event": "scan.daily",
  "day": "2026-11-04",
  "orgId": "org_...",
  "totalScans": 412,
  "byIdentifier": [ { "id": "00000012345007", "scans": 390 }, { "id": "rally", "scans": 22 } ],
  "otherScans": 0,
  "byLinkType": [ { "value": "gs1:pip", "scans": 390 } ],
  "byCountry": [ { "value": "US", "scans": 301 } ]
}


byIdentifier lists your top 100 identifiers for the day; anything beyond that is rolled into otherScans. A GTIN appears as its 14 digits, a short link as its code, and any other GS1 key as {ai}:{id} (for example 414:1234567890128). byLinkType and byCountry are the top 20 and use the same shape as the analytics endpoint.

Headers: X-QR42-Event, X-QR42-Delivery (the same value as id; use it to ignore a repeat) and X-QR42-Signature.

### Verifying the signature

X-QR42-Signature looks like t=1762300800,v1=5257a8.... v1 is the hex HMAC-SHA256, keyed with your signing secret, of the string <t>.<raw request body>. Compute it over the raw bytes you received (not a re-serialised copy) and compare in constant time. Reject anything whose t is more than 5 minutes old.

// Node.js
import { createHmac, timingSafeEqual } from "node:crypto";

function verify(rawBody, header, secret) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
  const expected = createHmac("sha256", secret).update(parts.t + "." + rawBody).digest("hex");
  const a = Buffer.from(expected), b = Buffer.from(parts.v1 ?? "");
  return a.length === b.length && timingSafeEqual(a, b);
}


### Delivery and retries

Any 2xx response counts as delivered. Anything else (another status, a redirect, which we never follow, a timeout after 10 seconds, or a network error) is a failure and is retried: after 5 minutes, 30 minutes, 2 hours, 12 hours, then 24 hours, six attempts in all, always with the identical body and X-QR42-Delivery. If three days in a row fail completely the org's owners get a warning email, and if five do, the endpoint is switched off and they get another; turn it back on once the receiver is fixed. Nothing is lost while it is off: the same data stays available in the dashboard and the analytics endpoint.

## What's explicitly NOT available via API key

- Creating an org, or an API key itself — session-only.
- Claim verification on the shared host — admin review only, no API path.
- Deleting products or claims, revoking/rotating a key — dashboard only.
- Brand-host onboarding, billing, disputes, team
  management, webhook management, anything under /api/v1/admin/* — all
  dashboard/session-only.

## MCP Server (Model Context Protocol)

Connect AI agents (Claude Code, Claude Desktop, Cursor, Google Antigravity, VS Code, Windsurf) directly over Streamable HTTP at:

  https://qrcode42.com/mcp

Authentication uses the same API key header:

  Authorization: Bearer qr42_live_YOUR_KEY

validate_gs1_identifier works without authentication. All 18 org tools enforce the same API key scopes and rate limits (120 req/min) as the REST endpoints above.

Quick install examples (full setup guide at https://qrcode42.com/docs/mcp):

  # Claude Code
  claude mcp add --transport http qr42 https://qrcode42.com/mcp --header "Authorization: Bearer qr42_live_YOUR_KEY"

  # Google Antigravity (agy)
  agy mcp add --header "Authorization: Bearer qr42_live_YOUR_KEY" qr42 https://qrcode42.com/mcp

Cookie settings

Choose which cookies we may use. You can change this at any time from the footer. See the privacy policy.