HTTP API reference

Every call is POST https://lichkey.com/api/v1/<operation> with a JSON object as the body; the OpenAPI document is generated from the same routes. Access is limited to the Anomaly team for now.

Authentication

Authorization: Bearer <credential>.

Where calls run

Each call is served from the Lichkey region nearest the Cloudflare location it lands on; the response's lichkey-region header says which. Writes go to the region that owns the key's group.

Keys

A key is a list of parts: ["acct_123", "grant", 9]. Parts are strings, numbers, booleans, bytes or bigints, ordered like Deno KV (bytes, then strings, numbers, bigints, booleans; a key sorts before the keys under it). The first part is the group: keys in a group are stored together, listed together and committed together. A key is at most 32 parts and 512 bytes encoded.

Values

Values are strings, numbers, booleans, bytes, sets, lists or documents. JSON carries what it can't say as tags:

An object with exactly one field starting with $ is a tag; any other object is a document. An update's value maps dotted field names to new values or to ops: {"$add": 1}, {"$add": "x"} (into a set), {"$remove": "x"}, {"$append": [..]}, {"$unset": true}. Messages are plain JSON. Durations (ttl, cache) are milliseconds or strings like "30s", "10m", "1d".

Results and errors

Entries are {"key", "value", "version", "expires"?}; a missing key is {"key", "value": null, "version": null}. Writes return {"ok": true, "version"}. A failed condition is a result with status 200: {"ok": false, "current": …} (for add, {"ok": false} when max or min refused it). Errors have a status and a stable code:

StatusCodeMeaning
400invalid, cross_groupThe body is malformed or breaks a rule (a commit across groups).
401unauthorizedMissing, invalid, expired or revoked credential.
403forbiddenA read-only token writing, or a key outside the token's prefix.
404not_foundNo such workspace, store or token.
409exists, idempotency_mismatchCreated before (ids are never reused), or an idempotency value reused with a different payload.
413too_largeThe body is over 8 MB.
415unsupportedThe body is declared as something other than JSON. A missing content type, or curl's default form type, is read as JSON.
429rate_limitedThe store is over its limit. Retry after Retry-After seconds.
503unavailable, contended, moved, behindTemporary. Retry after Retry-After seconds.
500internalA bug.

The body is {"error": {"code", "message", "retryable"}}.

Retries and idempotency

Writes take idempotency (or an Idempotency-Key header): a retry with the same value returns the first result for 24 hours, and a different payload with the same value is refused. Without one, retrying a write that timed out may apply it twice (a plain set is safe to repeat; an add isn't).

Pages

list returns up to limit entries of one group and a cursor when there are more. Cursors are signed: they only work for the same store and range, and can't be edited.

Limits

Per store, as safety rails: 1,000 calls and 1,000 write units per second by default (a many or commit is one call; one write unit per write per started KB). Values up to 350,000 bytes, messages up to 127 KB, up to 100 keys per many and 99 items per commit.

Data calls

POST /api/v1/get

Read a key.

{"key":["acct_123","profile"],"consistency":"strong"}

POST /api/v1/many

Read up to 100 keys, in order. Each meets its own guarantee; not a snapshot.

{"keys":[["acct_123","profile"],["acct_123","plan"]]}

POST /api/v1/set

Write a key. Without if, the last write wins. Takes an Idempotency-Key header.

{"key":["acct_123","profile"],"value":{"name":"dax","avatar":{"$bytes":"iVBORw0KGgo="}},"ttl":"30d"}

POST /api/v1/create

Write a key only if it doesn't exist: ok false if it does. Takes an Idempotency-Key header.

{"key":["handle","dax"],"value":"acct_123"}

POST /api/v1/update

Change fields of a document (created if missing), atomically at the owner. Returns the new document. Takes an Idempotency-Key header.

{"key":["acct_123","profile"],"value":{"name":"dax","logins":{"$add":1},"tags":{"$add":"admin"},"legacy":{"$unset":true}},"if":{"lt":["edits",100]}}

POST /api/v1/add

Add to a number atomically (a missing key counts as 0). Returns the new value; ok false when max or min refused it. ttl is set on creation and kept (fixed windows). Takes an Idempotency-Key header.

{"key":["ws_9","limit","2026-11-23"],"value":1,"max":1000,"ttl":"1d"}

POST /api/v1/delete

Delete a key. ok false if the condition failed. Takes an Idempotency-Key header.

{"key":["acct_123","session"],"if":{"eq":["revoked",true]}}

POST /api/v1/list

Entries in one group, in key order, a page at a time. prefix lists the keys under it; start is inclusive, end exclusive. The first part of each is the group.

{"prefix":["acct_123","grant"],"limit":100}

POST /api/v1/commit

Checks, writes and messages in one group, all or nothing. Messages are sent only if it commits. Takes an Idempotency-Key header.

{"checks":[{"key":["acct_123","profile"],"version":"0193f0a1b2c30000ab12"}],"writes":[{"type":"set","key":["acct_123","profile"],"value":{"name":"dax"}},{"type":"delete","key":["acct_123","grant","9"]}],"messages":[{"event":"renamed","account":"acct_123"}]}

Control calls

POST /api/v1/workspaces/create

Create a workspace; you become its owner. Ids are never reused. Up to 10 owned workspaces per person, your own included.

{"workspace":"acme","name":"Acme"}

POST /api/v1/workspaces/get

Read a workspace you belong to.

POST /api/v1/workspaces/list

The workspaces you belong to, with your role.

Body: {}.

POST /api/v1/workspaces/delete

Delete a workspace (owners): its stores and tokens stop working at once.

POST /api/v1/members/list

A workspace's members (any member can list).

POST /api/v1/members/remove

Remove a member (owners), or yourself (leave). The last owner can't. Their access stops within about 10 s, and store tokens they made in the workspace are revoked.

{"workspace":"acme","member":"<account sub>"}

POST /api/v1/invites/create

Invite someone (owners) by verified email, account id, or both. They join when they next sign in with that email or account, or by opening the link. Expires in 7 days; up to 50 pending per workspace.

{"workspace":"acme","email":"ana@anoma.ly"}

POST /api/v1/invites/list

With workspace: its pending invites (owners). Without: pending invites addressed to you.

POST /api/v1/invites/revoke

Revoke a pending invite (owners).

POST /api/v1/invites/accept

Accept an invite addressed to you: by its code (from a link), or by workspace and invite id (from invites/list). Used once.

{"code":"lki1.acme.…"}

POST /api/v1/stores/create

Create a store.

{"workspace":"acme","store":"main"}

POST /api/v1/stores/get

Read a store.

POST /api/v1/stores/list

A workspace's stores.

POST /api/v1/stores/delete

Delete a store: its tokens stop working at once.

POST /api/v1/stores/usage

Hourly usage of a store (UTC hours, approximate).

POST /api/v1/tokens/create

Create a store token. The token is returned once; only its hash is kept.

{"workspace":"acme","store":"main","access":"read","prefix":["acct_123"],"name":"reporting"}

POST /api/v1/tokens/list

A workspace's or store's tokens, without secrets.

POST /api/v1/tokens/revoke

Revoke a token.