stratus-db

The stratus-db API

An HTTP API over JSON (or transit). The clients for JavaScript, Python and ClojureScript call exactly these routes; this page is what they do underneath.

Getting started

Sign in, make an API key on the dashboard, and send it with every request:

Authorization: Bearer stk_...
Content-Type: application/json
curl https://api.stratus-db.com/v1/dbs -H "Authorization: Bearer $STRATUS_KEY"

Databases

An account has as many databases as its plan allows, each with its own data, indexes and history.

RouteBodyAnswer
GET /v1/dbsthe live databases' records; ?deleted=true for deleted ones too, ?name=orders for one by name
POST /v1/dbs{"name": "orders", "primary-key": "order/id"} its record, with its id
GET /v1/dbs/<id>its record
PATCH /v1/dbs/<id>{"name": "orders-2"}its record
DELETE /v1/dbs/<id>its record, deleted; its data is purged after a week
GET /v1/dbs/<id>/statusits t, its indexes and their states, and its history window

Names are unique among live databases. The primary key attribute is fixed when the database is created.

Rows and values

Transactions

POST /v1/dbs/<id>/transact applies a transaction atomically and keeps it in the database's history forever (or for the history window you set).

{"tx":      [{"order/id": "o-1", "order/status": {"$kw": "status/open"}, "order/total": 25}],
 "retract": [{"order/id": "o-2", "order/tags": {"$set": ["urgent"]}}],
 "delete":  ["o-3"],
 "tx-id":   "import-2026-10-13-001",
 "match":   [{"order/id": "o-1", "order/status": null}]}

Every part is optional. They apply in this order:

PartWhat it does
txRows to write. A row is created if it doesn't exist. Each attribute named is set to its value; attributes not named are left as they are. A set value adds its elements to the set the attribute holds.
retractAttributes to remove from rows. For a set, the named elements are removed (the attribute goes once the set is empty); for any other value the attribute is removed. The row stays, even with no attributes left.
deletePrimary keys (or tagged row ids) of rows to delete.
tx-idYour id for the transaction (a UUID or a string of up to 256 characters). Sending the same transaction again with the same id applies nothing and answers as the first time did, with "duplicate": true, so a retry after a lost answer is safe. The last 100,000 ids are remembered; the same id with different commands is 409 tx-id-reused.
matchA compare-and-set: rows whose attributes must hold these values now (null: the attribute is absent). If any doesn't, nothing is applied and the answer is 409 conflict: read again and retry.

A row in tx or retract may name itself by its row id in its key's place: {"order/id": {"stratus/id": 7}, "order/status": ...}.

The answer is {"t": 42, "pks": [...], "ids": [...]}: the transaction's number in the database's history, and the primary keys and row ids of the tx rows, in order.

How history records a transaction. Each part becomes commands, one per attribute, which history and the changes feed return as {"pk", "att", "value", "op"}:

opMeaning
stratus/set-valuethe attribute was set to the value
stratus/conj-setthe value was added to the attribute's set
stratus/disjthe value (or the attribute) was removed
stratus/deletethe row was deleted

Put many rows in one transaction rather than sending many transactions: a database commits one transaction at a time, each a durable write.

Reading rows

POST /v1/dbs/<id>/pull with {"pks": ["o-1", "o-9", {"stratus/id": 7}]} answers {"rows": [row, null, row]}: the rows in the keys' order (primary keys or tagged row ids), null for a missing one, at most 10,000 keys.

Add "as-of": 40 to read the database as it stood after transaction 40, anywhere inside its history window. Queries take it too.

Queries

POST /v1/dbs/<id>/query selects rows by predicates on ready indexes and returns them a page at a time, in row id order: the order rows were made. The language is small on purpose: narrow the rows with an index, then filter, sort or join the page in your own code.

{"where":  ["and", ["=", "order/status", {"$kw": "status/open"}],
                   ["range", "order/total", 100, null]],
 "select": ["order/total"],
 "limit":  500,
 "order":  "desc",
 "after":  4127}
PredicateMatches rows whose attribute ...
["=", att, v]is v (a set: holds v)
["range", att, from, to]is at least from and less than to; null leaves that end open
["prefix", att, "s"]is a string starting with "s"
["and", p, ...]match every p
["or", p, ...]match some p

Multi-attribute indexes

An index of several attributes, in order, keys each row by the tuple of its values. With an index of ["order/customer", "order/date"], one customer's orders are one run of the index in date order, so "this customer's orders in September" reads that run instead of every September order.

PredicateMatches rows whose tuple ...
["=", ["a", "b"], [x, y]]is [x, y]
["=", ["a", "b"], [x]]starts with x
["range", ["a", "b"], from, to]is between two tuples (a shorter one is padded with null, which sorts first)
["prefix", ["a", "b"], [x, "s"]]starts with x, then a string starting with "s"
{"where": ["range", ["order/customer", "order/date"],
                    ["c-17", {"$inst": "2026-09-01T00:00:00Z"}],
                    ["c-17", {"$inst": "2026-10-01T00:00:00Z"}]]}

A predicate names the index's attributes exactly, in its order.

Counts

POST /v1/dbs/<id>/count counts the rows a predicate matches without reading them, from its indexes alone:

{"where": ["=", "order/status", {"$kw": "status/open"}]}

Indexes

Add indexes while the database runs, on any attribute, as many as you like. A new index is building until it covers every row, in the background and without slowing writes, then ready.

RouteBodyAnswer
POST /v1/dbs/<id>/indexes{"att": "order/status"} {"att": "order/status", "state": "building"}
POST /v1/dbs/<id>/indexes {"att": ["order/customer", "order/date"], "required": ["order/customer"]} a multi-attribute index (2 to 8 attributes)
DELETE /v1/dbs/<id>/indexes/order/statusdropped at once
DELETE /v1/dbs/<id>/indexes/order/customer,order/date a multi-attribute index, its names joined by commas

History and changes

Nothing is overwritten. Every transaction stays in the database's history, which you can read, query as of, and fork from.

Forks

POST /v1/dbs/<id>/fork with {"name": "orders-ci", "t": 40} makes a new database: this one as it stood after transaction 40 (or now, without t). It takes seconds whatever the size: the fork shares the parent's data and stores only what it changes, and both histories record the fork. Its indexes come along, ready. Use one for a test run, a branch or an experiment, then delete it.

Erasure

POST /v1/dbs/<id>/excise with {"rows": ["o-3"], "attributes": [{"pk": "o-1", "att": "customer/email"}]} removes rows and attributes from every read path, history and as-of reads included, and from the database's forks. The changes feed reports the excision, so a pipeline can erase what it copied.

API keys

RouteBodyAnswer
GET /v1/keysthe account's keys (never their secrets)
POST /v1/keys{"name": "ci", "scope": [db-id, ...]} {"key": "stk_...", "record": {...}}: the key, shown once
DELETE /v1/keys/<key-id>revoked

A key with a scope reaches only those databases. Managing keys takes a key whose scope is every database.

JSON values

Plain JSON wherever a value is unambiguous: strings, booleans, null, arrays, objects, integers within ±253, and doubles. Everything else is a tag, an object with one key starting with $:

ValueJSON
UUID{"$uuid": "0192a3b4-c5d6-7e8f-8123-456789abcdef"}
Instant{"$inst": "2026-10-09T14:23:05.123456Z"}
Local date{"$localDate": "2026-10-09"}
Decimal{"$numberDecimal": "1.10"} (the scale is kept)
Long past ±253{"$numberLong": "9007199254740993"}
Keyword{"$kw": "status/open"}
Set{"$set": ["urgent", "q4"]}
List{"$list": [1, 2]} (arrays are vectors)
Bytes{"$binary": {"base64": "AQL/", "subType": "00"}}
Big integer, ratio{"$bigint": "123..."}, {"$ratio": "1/3"}
NaN, ±Infinity{"$numberDouble": "NaN"}

An object's keys are attribute names. A number with a fraction or exponent is a double; one without is a long. An unknown tag is refused. A value sent as a plain string is a string: send a UUID key as {"$uuid": ...}.

Errors and limits

An error answers {"error": "conflict", "message": "..."} with its status:

StatusErrors
400invalid, invalid-query: a malformed request
403the key can't reach that database; plan-limit, storage-limit: the plan's limits
404an unknown route or database
409conflict, tx-id-reused, name-taken, no-index, index-not-ready, index-failed, index-exists, too-old (before the history window)
413a single row too large to send
429the database is busy (retry with backoff), or quota-exceeded: the plan's monthly transactions or queries are used up

stratus-db is a young service, and some limits show it: a database commits about 20 transactions a second (put many rows in each), queries are the small language above, and a page is at most about 4 MB.