Skip to content
BatuWorks

App API

How the BatuWorks Kurgu desktop app (updater, sign-in, licensing) talks to batuworks.com. All endpoints return JSON; errors look like { "error": "<code>" }. When rate-limited you get 429 rate_limited with retry_after (seconds).

Update check: GET /api/app/latest

GET /api/app/latest?platform=windows
Authorization: Bearer kgt_…        (optional)

Response:

{
  "version": "0.10.0",
  "tag": "v0.10.0",
  "published_at": "2026-11-01T19:27:09Z",
  "notes": "…",
  "platform": "windows",
  "primary": { "id": "…", "name": "Kurgu-0.10.0-setup.exe", "kind": "win-setup", "size": 108407273,
               "sha256": "e67a…", "download_url": "https://…/api/download/file?t=…" },
  "assets": [ … ],
  "sha256sums": { "content": "<SHA256SUMS.txt>", "signature": "<base64 Ed25519>" },
  "authenticated": true
}
  • download_url is only filled with a valid app session (Bearer) and is valid for 5 minutes. Without a session it is null; the app sends the user to sign in or to the download page.
  • sha256sums.content + signature: a list signed with the developer's offline key, verified with PUBLIC_KEYS in kurgu/updater.py (the existing verify_signature works as-is). null for unsigned releases.
  • Updater flow: version > local version → verify the sha256sums signature → download primary.download_url → compare SHA-256 with the signed list → install.

Sign in from the app (device code, RFC 8628)

  1. POST /api/app/device/start with { device_name, platform, locale } → { device_code, user_code, verification_uri, verification_uri_complete, expires_in: 600, interval: 5 }. Open verification_uri_complete in the browser and show user_code. Keep device_code secret.
  2. Poll POST /api/app/device/token with { device_code, device_id } every interval seconds:
StatusBodyMeaning
400authorization_pendingNot approved yet, keep polling
400access_deniedThe user denied it
400expired_tokenCode expired (10 min), start over
400invalid_grantInvalid or already used
200{ app_token, token_type, entitlement }Signed in

Store app_token (kgt_…) in the OS keychain. The server only keeps its SHA-256 hash; the user can revoke it from the account dashboard. For device_id use a stable per-machine value (Windows MachineGuid, macOS IOPlatformUUID, Linux /etc/machine-id, ideally hashed with an app-specific salt).

  1. Refresh: POST /api/app/entitlement with Authorization: Bearer kgt_… → { entitlement }. 401 invalid_token means the session was revoked.
  2. Sign out: POST /api/app/logout (Bearer).

Entitlement file

Issued for both Free and Pro users and signed with Ed25519:

{
  "entitlement": {
    "v": 1, "product": "kurgu", "sub": "<user>", "plan": "free | pro | lifetime",
    "features": ["reframe", "brand_kits", …], "device": "<sha256(device)>",
    "license_id": "…", "key_hint": "AB12", "pro_until": "2027-01-08T…",
    "issued_at": "…", "expires_at": "<issued + 14 days>", "refresh_after": "<issued + 3 days>",
    "kid": "k1", "notice": "device_limit"
  },
  "signature": "<base64>",
  "alg": "Ed25519"
}
  • expires_at is the offline tolerance (14 days).
  • Pro is on when plan == "lifetime" or (plan == "pro" and now < pro_until).
  • device must match this machine's hash.
  • notice: "device_limit": the user has Pro but all 3 device slots are taken; this device got a Free entitlement.

Verification in Python: json.dumps(doc["entitlement"], sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode("utf-8") is the signed payload; verify with Ed25519PublicKey.from_public_bytes(...). Embed the public keys in the app (for reference: GET /api/license/public-keys).

Activation with a license key

EndpointBodyResponse
POST /api/license/activate{ key, device_id, device_name?, platform? }{ entitlement, devicesUsed, maxDevices }
POST /api/license/validate{ key, device_id }{ entitlement }
POST /api/license/deactivate{ key, device_id }{ removed }

Error codes: invalid_key (400), invalid_device (400), not_found (404), inactive / expired / not_activated (403), device_limit (409).