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_urlis only filled with a valid app session (Bearer) and is valid for 5 minutes. Without a session it isnull; 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 withPUBLIC_KEYSinkurgu/updater.py(the existingverify_signatureworks as-is).nullfor unsigned releases.- Updater flow:
version> local version → verify thesha256sumssignature → downloadprimary.download_url→ compare SHA-256 with the signed list → install.
Sign in from the app (device code, RFC 8628)
POST /api/app/device/startwith{ device_name, platform, locale }→{ device_code, user_code, verification_uri, verification_uri_complete, expires_in: 600, interval: 5 }. Openverification_uri_completein the browser and showuser_code. Keepdevice_codesecret.- Poll
POST /api/app/device/tokenwith{ device_code, device_id }everyintervalseconds:
| Status | Body | Meaning |
|---|---|---|
| 400 | authorization_pending | Not approved yet, keep polling |
| 400 | access_denied | The user denied it |
| 400 | expired_token | Code expired (10 min), start over |
| 400 | invalid_grant | Invalid 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).
- Refresh:
POST /api/app/entitlementwithAuthorization: Bearer kgt_…→{ entitlement }.401 invalid_tokenmeans the session was revoked. - 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_atis the offline tolerance (14 days).- Pro is on when
plan == "lifetime"or (plan == "pro"and now <pro_until). devicemust 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
| Endpoint | Body | Response |
|---|---|---|
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).