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
- The base URL is
https://api.stratus-db.com; every route below starts with/v1. - Bodies are JSON with typed values (below), or transit-json with
Content-Type: application/transit+json. The answer comes in the request's format (or the oneAcceptnames). - A new key works within a minute or two.
- A database answers one request at a time. When it's busy the answer is 429: retry with backoff (the clients do).
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.
| Route | Body | Answer |
|---|---|---|
GET /v1/dbs | the 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>/status | its 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
- A row is a map of attributes to values. Any row takes any attribute: there is no schema to declare.
- Every row has its primary key attribute: a UUID, a string or a long. Generate keys on
your side: the clients'
squuid()makes UUIDs that sort in creation order, or use keys your application already has. - Every row also gets a row id,
"stratus/id": a long the database assigns when the row is made, in order, and never reuses (a deleted key made again gets a new one). Rows come back carrying it. To name a row by its id where a key goes, tag it:{"stratus/id": 7}. A bare integer is always a primary key. - Values come back exactly as written: a decimal keeps its scale, an instant its microseconds, a keyword stays a keyword, a long stays a long.
- A set value holds many values for one attribute (tags, say). Writing a set adds its elements; queries match any element.
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:
| Part | What it does |
|---|---|
tx | Rows 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. |
retract | Attributes 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. |
delete | Primary keys (or tagged row ids) of rows to delete. |
tx-id | Your 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. |
match | A 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"}:
op | Meaning |
|---|---|
stratus/set-value | the attribute was set to the value |
stratus/conj-set | the value was added to the attribute's set |
stratus/disj | the value (or the attribute) was removed |
stratus/delete | the 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}
| Predicate | Matches 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 |
- Every attribute a predicate names needs a ready index (below).
- The answer is
{"rows": [...], "next": 4127, "t": 42}. Passnext, the last row's id, asafterfor the following page; it isnullafter the last.limitis 1 to 100,000 (default 1,000); a page also stops at about 4 MB. "order": "desc"returns the newest rows first; the default is"asc".selectkeeps only those attributes (and the primary key and row id).- Values compare by type, then value:
nullfirst; numbers by value across types (1equals1.0); strings, keywords, UUIDs and instants in their own order. A value of the wrong type matches nothing: the string"status/open"isn't the keyword{"$kw": "status/open"}. - An
=, andand/orof them, cost about a page however many rows match. Arangeorprefixcosts about its matches, up to a bound, then walks rows in order.
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.
| Predicate | Matches 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"}]}
- The answer is
{"count": 1530, "t": 42}: exact, as oft. whereis required and takes any query predicate;"as-of"works as it does for a query. The clients' call iscount(count-rowsin ClojureScript).- An
=, andand/orof them, count quickly however many rows match. Arangeorprefixcosts about the number of distinct values it spans. - A count is a query against your plan's quota.
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.
| Route | Body | Answer |
|---|---|---|
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/status | dropped at once | |
DELETE /v1/dbs/<id>/indexes/order/customer,order/date | a multi-attribute index, its names joined by commas |
GET /v1/dbs/<id>/statuslists each index's state underindexes(a multi-attribute one under its names joined by commas). Wait forreadybefore querying it.- A set value is indexed element by element.
- A multi-attribute index holds the rows with at least one of its attributes and every
attribute in
required. A missing attribute isnull, which sorts first. Its attributes can't hold sets: once it is requested, a transaction writing a set into one of them is refused. Requesting the same attributes with anotherrequiredis 409index-exists: drop it first.
History and changes
Nothing is overwritten. Every transaction stays in the database's history, which you can read, query as of, and fork from.
GET /v1/dbs/<id>/history?from=1&limit=100: the transactions from t on, each with its time and commands, andnextfor the following page.POST /v1/dbs/<id>/changesfor pipelines:{"from-time": "2026-10-11T00:00:00Z", "to-time": "2026-10-12T00:00:00Z", "shape": "entities"}(or"from"/"to"as t's,"pks","limit","after")."attributes"gives one entry per command;"entities"one per row a transaction touched, as it stood after. Start the next window at the answer'sto.PUT /v1/dbs/<id>/history-retentionwith{"days": 365}(30 to 36,500, as your plan allows) or{"days": null}to keep history forever. As-of reads and forks reach as far back as the window.
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
| Route | Body | Answer |
|---|---|---|
GET /v1/keys | the 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 $:
| Value | JSON |
|---|---|
| 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:
| Status | Errors |
|---|---|
| 400 | invalid, invalid-query: a malformed request |
| 403 | the key can't reach that database; plan-limit,
storage-limit: the plan's limits |
| 404 | an unknown route or database |
| 409 | conflict, tx-id-reused, name-taken,
no-index, index-not-ready, index-failed,
index-exists, too-old (before the history window) |
| 413 | a single row too large to send |
| 429 | the 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.