# Qruuk Open API (v1) Base URL: https://api.qruuk.com/v1 Auth: `Authorization: Bearer qk_live_…` (create keys with the create_api_key tool, or in Settings → API keys). Scopes: cards:issue, cards:validate, customers:read, customers:write, events:read, sales:write, account:read, account:write, integrations:manage. A call without the needed scope returns 403. Errors: `{ "error": { "code": "bad_request|unauthorized|forbidden|not_found|internal", "message": "…" } }`. Rate limit: per IP; 429 with Retry-After when exceeded. ## GET /me The account and scopes behind the key. → 200 `{ "data": { "accountId", "name", "scopes": [...], "installation": null | { "id", "addon" } } }` ## POST /cards/issue (scope cards:issue) Issue a card to a customer. Counts as a pass for billing. Body: `{ "productId": uuid, "email"?: string, "firstName"?: string, "validFrom"?: ISO date, "validUntil"?: ISO date, "uses"?: 1–1000, "marketingConsent"?: boolean }` → 201 `{ "id", "code", "cardUrl" }` Refused with 403 `planLimitReached:passes:50` when a Free account has used its 50 new cards this month. ## POST /cards/validate (scope cards:validate) Validate a scanned card: the code, or the full card URL the customer's QR encodes. Body: `{ "code": string }` → 200 `{ "status": "stamped|redeemed|duplicate|reward_ready|admitted|already_used|entry_ok|punch_ok|depleted|expired|not_yet_valid", "code", "productType", "cardName", "customerName", "stamps", "stampGoal", "rewardDescription", "rewardReady", "usesRemaining", "usesTotal", "validFrom", "validUntil", "usedAt" }` A second scan of the same card within 10 s is a "duplicate", not a second stamp. ## GET /customers (scope customers:read) Query: `search`, `marketingConsent=true|false`, `sort=recent|joined|name`, `limit` (1–100, default 25), `offset`. → 200 `{ "rows": [...], "total" }` ## GET /customers/:id (scope customers:read) → 200 the customer with their cards and activity. ## POST /customers (scope customers:write) Create or update a customer by email (deduplicated per account). Body: `{ "email", "firstName"?, "lastName"?, "phone"?, "marketingConsent"? }` → 200 `{ "id" }` Marketing consent can only be granted here, never withdrawn (customers unsubscribe through their own link). ## GET /programs (any cards, sales or account scope) The account's programs, e.g. for a dropdown in an automation tool. → 200 `{ "data": [{ "id", "name", "type", "status" }] }` ## GET /events (scope events:read) Recent events, the same payloads webhooks deliver. Query: `type` (one event type), `since` (ISO time: newer events, oldest first — for polling), `limit` (1–100, default 25). Kept 30 days. → 200 `{ "data": [{ "id", "type", "createdAt", "data" }] }` ## GET /webhooks · POST /webhooks · DELETE /webhooks/:id (scope events:read) REST-hook subscriptions owned by this key (what Zapier, Make and n8n use when a workflow is turned on/off). POST body: `{ "url": https URL, "events": [event types] , "source"?: "zapier|make|n8n|api" }` → 201 `{ "id", "url", "events", "secret" }` (the signing secret is shown once). DELETE → 204. ## POST /sales (scope sales:write) A sale in another system (shop, POS, booking tool) that should stamp a loyalty card, following the stamp rules the merchant set for "Zapier, Make, n8n or your code" (Settings → Till connections, or the update_sales_rules tool). Idempotent on `id` per `source`. Body: `{ "id", "amount" (e.g. "12.50") | "amountCents", "currency"?, "occurredAt"?, "type"?: "sale|refund|cancelled", "refundOf"?, "source"?, "customer"?: { "cardCode" (code or card URL) | "email" | "phone" | "id", "name"? } }` → 200 processed / 202 queued `{ "data": { "id", "status", "outcome", "stamps", "cardId", "customerId" } }` (customer fields only for keys that also have customers:read). 409 `sales_not_connected` until the merchant turns it on.