API

The Sassly QR API lets you create and manage QR codes from your own app or server: create dynamic codes, change their destinations, download images, generate codes in bulk, and fetch scan statistics. The API is available on Pro.

This page is an introduction. The full list of endpoints, the content schema for each type, and the style schema are in the API reference. You can download the OpenAPI spec at /en/docs/api/openapi.yaml.

Authentication

Creating an API key

  1. Open the API keys page in the app.
  2. Click Create API key and give it a name you'll recognize, such as "Online store server".
  3. Copy the key. It's shown only once. After that, you'll only see its first 12 characters (the prefix).

API key rules:

  • Up to 10 active keys per account. Create one key per app or server so you can revoke them individually.
  • You can revoke a key anytime with Revoke. Apps using it lose access immediately.
  • Keys only work while Pro is active. When Pro ends, requests with a key are refused with 403 plan_required. The same key works again as soon as Pro is active again.

Keep keys somewhere safe, such as a server environment variable. Never put a key in front-end code, a mobile app, or a repository.

Header format

Send the key in the Authorization header on every request:

Authorization: Bearer sqr_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Keys always start with sqr_ followed by 40 characters. When the Authorization header is present, cookies are ignored.

Base URL and format

https://qr.sassly.ai/api/v1
  • Request and response bodies are JSON (UTF-8). Send Content-Type: application/json on requests that have a body.
  • Unknown fields in the body are rejected with validation_error.
  • Error message text follows the Accept-Language header (id or en).

Success responses

A single object:

{
  "data": {
    "id": "qr_01JAZ0R1B2C3D4E5F6G7H8J9K0",
    "object": "qr",
    "name": "Coffee Shop Menu"
  }
}

A list, with paging details in meta:

{
  "data": [],
  "meta": { "page": 1, "per_page": 20, "total": 135 }
}

Error responses

{
  "error": {
    "code": "validation_error",
    "message": "Some fields are invalid. Please check them.",
    "fields": {
      "content.url": "The destination URL is invalid."
    }
  }
}
  • code is stable and safe to use in your program's logic. The message text may change.
  • fields appears when the error relates to specific fields.
  • For quota_exceeded, the response also includes meta with the limit and current usage.

Error codes

HTTP code Meaning
400 invalid_json The body isn't valid JSON
401 unauthenticated Not signed in, or the session has expired
401 invalid_api_key The API key is wrong or has been revoked
403 csrf_invalid The CSRF token is missing or wrong (web session requests only)
403 forbidden Your role in the collection doesn't allow this action
403 plan_required A Pro-only feature, or an API key used while the plan isn't Pro
403 quota_exceeded A Free plan limit was reached (meta has the limit and usage)
403 read_only The collection or code is read-only because of Free plan limits
403 account_suspended The account is suspended
404 not_found It doesn't exist, or you don't have access to it
405 method_not_allowed Wrong HTTP method for this endpoint
409 conflict Conflicts with the current state, such as deleting a collection that isn't empty
413 payload_too_large The body or file is too large
422 validation_error Invalid input (see fields)
422 qr_payload_too_large The content is too long to fit in a QR code
422 unsafe_url The destination URL failed the safety check or is not allowed by policy
429 rate_limited Too many requests
500 server_error Something went wrong on our side
503 service_unavailable A supporting service (such as rendering) is temporarily unavailable

Rate limits

Context Limit
Per API key 60 requests per minute and 10,000 requests per day
POST /render 30 requests per minute
Logo uploads 20 per hour

Every response includes the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers. If you go over a limit, you get 429 rate_limited with a Retry-After header (in seconds). Wait that long before trying again.

Pagination

List endpoints accept ?page= and ?per_page=. The default is 20 items per page, and the maximum is 100. The total number of items is in meta.total.

curl "https://qr.sassly.ai/api/v1/qr?page=2&per_page=50" \
  -H "Authorization: Bearer $SQR_API_KEY"

ID format

All public IDs have a prefix that tells you what they are:

Prefix Object
usr_ User
col_ Collection
qr_ QR code
logo_ Logo
inv_ Invitation
key_ API key
pay_ Payment
ntf_ Notification
rpt_ Abuse report

Example: col_01JAZ0Q6M7K3V5X8Y2N4P6R8T0. Treat IDs as opaque strings.

Time format

All times are ISO-8601 in UTC, such as 2026-10-01T14:30:00Z. Convert them to local time on your side (WIB is UTC+7).

The exception: the from and to parameters for statistics take YYYY-MM-DD dates in WIB.

Main endpoints

Method Path What it does
GET /me Profile, plan, limits, and usage
GET /collections Collections you own and ones you've joined
GET /qr List codes (filter by collection_id, type, mode, status, q)
POST /qr Create a code
GET /qr/{id} Get a code
PATCH /qr/{id} Change a code's name, content, or design
DELETE /qr/{id} Delete a code
GET /qr/{id}/image Download the image (format=png, svg, or pdf)
GET /qr/{id}/stats Scan statistics
GET /qr/{id}/stats.csv Export statistics as CSV
POST /render Render a static code without saving it, for bulk generation

Other endpoints, such as duplicating, moving between collections, and the logo library, are in the API reference.

A few notes:

  • POST /qr: name, type, and content are required. mode defaults to static. If you leave out collection_id, the code goes into your default collection. style can be partial; anything you leave out uses the defaults.
  • PATCH /qr/{id}: for a dynamic code, changing content changes the destination without changing the image. For a static code, changing content changes the image.
  • GET /qr/{id}/image: size applies to PNG (256–4096 px, default 1024). Add download=1 to receive the file as an attachment.
  • POST /render: the body takes type, content, style, format (svg, png, or pdf), and size. It always produces a static code, stores nothing, and doesn't count towards your QR limits. The response is the image file itself, with an X-QR-Scanability header (good, check, or hard) you can use to check results automatically.
  • GET /qr/{id}/stats: takes from and to (YYYY-MM-DD, WIB). The default is the last 30 days, and the maximum range is 366 days. If the owner of the code's collection isn't on Pro, the response only has the total scans, with "detail": false.

Complete examples

The examples below do five things: create a dynamic URL code, change its destination, download a PNG, generate codes in bulk with stateless rendering, and fetch statistics. Store your API key in the SQR_API_KEY environment variable:

export SQR_API_KEY="sqr_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Replace col_01JAZ0Q6M7K3V5X8Y2N4P6R8T0 with your collection's ID (see GET /collections), or remove that field to use your default collection.

curl

1. Create a dynamic URL code

curl -X POST "https://qr.sassly.ai/api/v1/qr" \
  -H "Authorization: Bearer $SQR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "collection_id": "col_01JAZ0Q6M7K3V5X8Y2N4P6R8T0",
    "name": "Coffee Shop Menu",
    "type": "url",
    "mode": "dynamic",
    "content": { "url": "https://example.com/menu" },
    "style": { "dots": { "shape": "rounded", "color": "#17456C" } }
  }'

Response (shortened):

{
  "data": {
    "id": "qr_01JAZ0R1B2C3D4E5F6G7H8J9K0",
    "object": "qr",
    "name": "Coffee Shop Menu",
    "type": "url",
    "mode": "dynamic",
    "content": { "url": "https://example.com/menu" },
    "short_url": "https://qr.sassly.ai/k8fp2xq",
    "status": "active",
    "scanability": { "level": "good", "warnings": [], "min_print_cm": 2.0 },
    "scan_count": 0,
    "created_at": "2026-10-01T14:30:00Z",
    "updated_at": "2026-10-01T14:30:00Z"
  }
}

2. Change the destination

curl -X PATCH "https://qr.sassly.ai/api/v1/qr/qr_01JAZ0R1B2C3D4E5F6G7H8J9K0" \
  -H "Authorization: Bearer $SQR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "content": { "url": "https://example.com/october-menu" } }'

3. Download a PNG

curl -o coffee-shop-menu.png \
  "https://qr.sassly.ai/api/v1/qr/qr_01JAZ0R1B2C3D4E5F6G7H8J9K0/image?format=png&size=1024&download=1" \
  -H "Authorization: Bearer $SQR_API_KEY"

4. Bulk rendering (stateless)

Create 20 static codes for 20 tables. The 2-second pause keeps you under the limit of 30 per minute.

for table in $(seq 1 20); do
  curl -s -X POST "https://qr.sassly.ai/api/v1/render" \
    -H "Authorization: Bearer $SQR_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"type\": \"url\", \"content\": {\"url\": \"https://example.com/menu?table=$table\"}, \"format\": \"png\", \"size\": 1024}" \
    -o "table-$table.png"
  sleep 2
done

5. Fetch statistics

curl "https://qr.sassly.ai/api/v1/qr/qr_01JAZ0R1B2C3D4E5F6G7H8J9K0/stats?from=2026-09-01&to=2026-09-30" \
  -H "Authorization: Bearer $SQR_API_KEY"

Response (shortened):

{
  "data": {
    "qr_id": "qr_01JAZ0R1B2C3D4E5F6G7H8J9K0",
    "total_scans": 1234,
    "last_scanned_at": "2026-09-30T11:02:45Z",
    "detail": true,
    "from": "2026-09-01",
    "to": "2026-09-30",
    "range_scans": 812,
    "unique_scans": 640,
    "daily": [
      { "day": "2026-09-01", "scans": 25, "unique_scans": 21 },
      { "day": "2026-09-02", "scans": 31, "unique_scans": 27 }
    ],
    "breakdown": {
      "device": [ { "label": "mobile", "scans": 790 }, { "label": "desktop", "scans": 22 } ],
      "os": [ { "label": "Android", "scans": 540 } ],
      "browser": [ { "label": "Chrome", "scans": 498 } ],
      "country": [ { "label": "ID", "scans": 801 } ],
      "city": [ { "label": "Jakarta", "scans": 344 } ]
    }
  }
}

For per-scan data as CSV, call GET /qr/{id}/stats.csv with the same parameters.

PHP

Uses PHP's built-in curl extension, with no extra libraries.

<?php
// Run: SQR_API_KEY=sqr_xxx php example.php

const BASE_URL = 'https://qr.sassly.ai/api/v1';

function sqr(string $method, string $path, ?array $body = null, bool $raw = false)
{
    $headers = ['Authorization: Bearer ' . getenv('SQR_API_KEY')];
    $ch = curl_init(BASE_URL . $path);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    if ($body !== null) {
        $headers[] = 'Content-Type: application/json';
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $response = curl_exec($ch);
    if ($response === false) {
        throw new RuntimeException('Connection failed: ' . curl_error($ch));
    }
    $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
    if ($status >= 400) {
        $error = json_decode($response, true)['error'] ?? [];
        throw new RuntimeException($status . ' ' . ($error['code'] ?? '') . ': ' . ($error['message'] ?? ''));
    }

    return $raw ? $response : json_decode($response, true);
}

// 1. Create a dynamic URL code
$qr = sqr('POST', '/qr', [
    'collection_id' => 'col_01JAZ0Q6M7K3V5X8Y2N4P6R8T0',
    'name'          => 'Coffee Shop Menu',
    'type'          => 'url',
    'mode'          => 'dynamic',
    'content'       => ['url' => 'https://example.com/menu'],
    'style'         => ['dots' => ['shape' => 'rounded', 'color' => '#17456C']],
])['data'];
$qrId = $qr['id'];
echo "Created: {$qrId} -> {$qr['short_url']}\n";

// 2. Change the destination
sqr('PATCH', "/qr/{$qrId}", ['content' => ['url' => 'https://example.com/october-menu']]);

// 3. Download a PNG
$png = sqr('GET', "/qr/{$qrId}/image?format=png&size=1024&download=1", null, true);
file_put_contents('coffee-shop-menu.png', $png);

// 4. Bulk rendering: 20 static codes for 20 tables
for ($table = 1; $table <= 20; $table++) {
    $file = sqr('POST', '/render', [
        'type'    => 'url',
        'content' => ['url' => "https://example.com/menu?table={$table}"],
        'format'  => 'png',
        'size'    => 1024,
    ], true);
    file_put_contents("table-{$table}.png", $file);
    sleep(2); // stay under 30 renders per minute
}

// 5. Fetch statistics
$stats = sqr('GET', "/qr/{$qrId}/stats?from=2026-09-01&to=2026-09-30")['data'];
echo "Total scans: {$stats['total_scans']}\n";
if ($stats['detail']) {
    echo "Unique scans in this range: {$stats['unique_scans']}\n";
}

JavaScript (fetch)

For Node.js 18 or later (fetch is built in). Save it as example.mjs.

// Run: SQR_API_KEY=sqr_xxx node example.mjs
import { writeFile } from 'node:fs/promises';

const BASE_URL = 'https://qr.sassly.ai/api/v1';

async function sqr(method, path, body) {
  const headers = { Authorization: `Bearer ${process.env.SQR_API_KEY}` };
  if (body !== undefined) headers['Content-Type'] = 'application/json';

  const res = await fetch(BASE_URL + path, {
    method,
    headers,
    body: body !== undefined ? JSON.stringify(body) : undefined,
  });
  if (!res.ok) {
    const { error = {} } = await res.json().catch(() => ({}));
    throw new Error(`${res.status} ${error.code}: ${error.message}`);
  }
  return res;
}

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

// 1. Create a dynamic URL code
const created = await (await sqr('POST', '/qr', {
  collection_id: 'col_01JAZ0Q6M7K3V5X8Y2N4P6R8T0',
  name: 'Coffee Shop Menu',
  type: 'url',
  mode: 'dynamic',
  content: { url: 'https://example.com/menu' },
  style: { dots: { shape: 'rounded', color: '#17456C' } },
})).json();
const qrId = created.data.id;
console.log(`Created: ${qrId} -> ${created.data.short_url}`);

// 2. Change the destination
await sqr('PATCH', `/qr/${qrId}`, { content: { url: 'https://example.com/october-menu' } });

// 3. Download a PNG
const png = await sqr('GET', `/qr/${qrId}/image?format=png&size=1024&download=1`);
await writeFile('coffee-shop-menu.png', Buffer.from(await png.arrayBuffer()));

// 4. Bulk rendering: 20 static codes for 20 tables
for (let table = 1; table <= 20; table++) {
  const file = await sqr('POST', '/render', {
    type: 'url',
    content: { url: `https://example.com/menu?table=${table}` },
    format: 'png',
    size: 1024,
  });
  await writeFile(`table-${table}.png`, Buffer.from(await file.arrayBuffer()));
  await sleep(2000); // stay under 30 renders per minute
}

// 5. Fetch statistics
const stats = await (await sqr('GET', `/qr/${qrId}/stats?from=2026-09-01&to=2026-09-30`)).json();
console.log(`Total scans: ${stats.data.total_scans}`);
if (stats.data.detail) {
  console.log(`Unique scans in this range: ${stats.data.unique_scans}`);
}

Don't call the API with an API key directly from a browser. Anyone can read a key in front-end code.

Python (requests)

# Run: SQR_API_KEY=sqr_xxx python example.py
import os
import time

import requests

BASE_URL = "https://qr.sassly.ai/api/v1"

session = requests.Session()
session.headers["Authorization"] = "Bearer " + os.environ["SQR_API_KEY"]


def sqr(method, path, json=None, params=None):
    res = session.request(method, BASE_URL + path, json=json, params=params, timeout=30)
    if res.status_code >= 400:
        try:
            error = res.json().get("error", {})
        except ValueError:
            error = {}
        raise RuntimeError(f"{res.status_code} {error.get('code')}: {error.get('message')}")
    return res


# 1. Create a dynamic URL code
qr = sqr("POST", "/qr", json={
    "collection_id": "col_01JAZ0Q6M7K3V5X8Y2N4P6R8T0",
    "name": "Coffee Shop Menu",
    "type": "url",
    "mode": "dynamic",
    "content": {"url": "https://example.com/menu"},
    "style": {"dots": {"shape": "rounded", "color": "#17456C"}},
}).json()["data"]
qr_id = qr["id"]
print(f"Created: {qr_id} -> {qr['short_url']}")

# 2. Change the destination
sqr("PATCH", f"/qr/{qr_id}", json={"content": {"url": "https://example.com/october-menu"}})

# 3. Download a PNG
png = sqr("GET", f"/qr/{qr_id}/image?format=png&size=1024&download=1")
with open("coffee-shop-menu.png", "wb") as f:
    f.write(png.content)

# 4. Bulk rendering: 20 static codes for 20 tables
for table in range(1, 21):
    file = sqr("POST", "/render", json={
        "type": "url",
        "content": {"url": f"https://example.com/menu?table={table}"},
        "format": "png",
        "size": 1024,
    })
    with open(f"table-{table}.png", "wb") as f:
        f.write(file.content)
    time.sleep(2)  # stay under 30 renders per minute

# 5. Fetch statistics
stats = sqr("GET", f"/qr/{qr_id}/stats", params={"from": "2026-09-01", "to": "2026-09-30"}).json()["data"]
print(f"Total scans: {stats['total_scans']}")
if stats["detail"]:
    print(f"Unique scans in this range: {stats['unique_scans']}")

Versioning

  • The current version is v1, at /api/v1.
  • Changes that stay compatible, such as new endpoints or new response fields, can be added to v1. Make sure your code ignores response fields it doesn't recognize.
  • Breaking changes will go into /api/v2. We'll give at least 90 days' notice.

Changelog

  • v1 — 1 October 2026: first release.

Help

If you run into a problem or need help with an integration, contact admin@sambu.la. Include the endpoint, the request time (UTC), and the error code you received. Never send your full API key.