HTTP reference

Where to look a thing up: every route, the filters of the query string, the headers that hold a write or mark a read, the statuses a refusal answers with, subscriptions, polling and the change stream. A first request is on HTTP endpoint; tokens and policies are on HTTP security and scoped access.

Routes

GET    /                        version and collection list
GET    /collections             schemas
GET    /<name>?<filter>         rows
GET    /<name>?<filter>&count   number of matching rows
GET    /<name>?select=status,count(*),sum(total)&group=status&order=sum(total).desc
                                aggregates, whole or per group
GET    /<name>?<filter>&facet=brand%20top%205,color
                                rows, and each value's count beside them
POST   /<name>                  body: {...} or [{...}] -- an id that is taken: 409
POST   /<name>?returning=id,title   the rows made, ids and all (* every field), not their count
PATCH  /<name>?<filter>         body: {...}
DELETE /<name>?<filter>
PATCH  /<name>/all              no filter — deliberately explicit
DELETE /<name>/all
GET    /<name>/<id>             the row, its tag in ETag (<a href="#conditional">If-None-Match</a>: 304)
PUT    /<name>/<id>             body: {...} -- the row written whole: 201 made, 200 over it
PATCH  /<name>/<id>             body: {...} -- If-Match: only over the row tagged, else 412
DELETE /<name>/<id>
POST   /<name>/near             body: {"vector":[...], "limit":10}
GET    /<name>/changes?since=N  subscription (SSE): shape plus incremental diff
POST   /query                   body: {"query":"<FennecQL>","params":[...]}
POST   /batch                   one query body per line (NDJSON)
POST   /_call/<name>            body: {"params":{...}} -- the named statement, answered as /query answers it
POST   /_hooks/<hook>           another service's event, verified by its signature, no token (--hooks; <a href="/docs/webhooks">Webhooks</a>)
GET    /_metrics               counters and gauges, Prometheus's text format
GET    /_changes?since=N        every write on disk after N, a JSON line each (--cdc)
GET    /_changes?consumer=C     from where consumer C committed
POST   /_changes/consumers/C    make C (201), at {"since": N} or the last write; one already there stays put (200; a since ahead of it: 409)
PATCH  /_changes/consumers/C    body: {"since": N} -- move C: commit what it read, or go back
GET    /_changes/consumers      each consumer, where it is and how far behind
DELETE /_changes/consumers/C
GET    /_whoami                 who the server takes the token for, the roles it read, the rules that apply to it and the statements it may call
GET    /_schema                 the schema as a description (Schema in code), each collection's bound statements beside it, then the scheduled ones as schedules and the webhook consumers as hooks; ?as=fennecql: as its statements, the bound, the scheduled and the webhook ones after them
POST   /_schema/plan            body: a description -- what an apply would do; ?mode=follow: what the server lacks
POST   /_schema/apply           body: a description -- migrations, then what only adds; the server's token
POST   /_mcp                    MCP for agents (--mcp): one JSON-RPC message a request
GET    /_health                 {"ok": true}, with no token and no lock: a container's health check
GET    /_openapi.json           the OpenAPI 3.1 document of every route here, with no token (<a href="#openapi">below</a>)
The _replication, _schema and _metrics routes

With --replication-token, /_replication is taken as well: the stream a replica is fed, its status, and a replica's promotion — see Replication. It asks for that token rather than --http-token, and a collection named _replication is then out of HTTP's reach.

/_schema compares a schema declared in code with the server's, in the engine every SDK's check goes through — see Schema in code. Its body is the description, {"format": 1, "fennecql": "create collection ...", "migrations": [...]} or its collections as JSON. A plan answers {"applied", "ran", "migrations", "statements", "refusals"}, and writes nothing; with ?mode=follow it says only what the code declares and the server lacks, which a scoped token may ask of the collections it reads. An apply takes the server's token, runs the migrations not yet recorded and the additions under the write lock as one block, and answers 409 with the refusals when anything is refused, having written nothing. The record is _migrations, one of the server's own collections: no statement changes it, the server's token's either, so a list starts over in a new file, or on a tenant node in a new tenant. A description declaring one of those collections, or a migration still to run that makes, changes or writes one, is refused (403) before anything runs; one the server recorded is never run again, and is not asked.

To the server's token alone, each collection's object in GET /_schema carries the statements bound to its writes: "bindings":[{"name":"paid","events":"set","text":"create statement paid after set orders ..."}]. ?as=fennecql writes each definition after the collections. Either body reads back through POST /_schema/plan and /_schema/apply, a plan reading the bindings listed; events may be left out, and a binding listed with events its text does not bind is refused (400). A scoped token sees no binding there, no name and no text.

Likewise, where the database holds a scheduled statement, GET /_schema carries a top-level "schedules" after collections, to the server's token: [{"name", "schedule", "text", "next", "last", "held"}], the last three as statements lists them (Scheduled statements). ?as=fennecql writes each scheduled definition after the collections and the bound statements. Either form reads back through POST /_schema/plan as a plan of nothing, and a listed schedule other than its text's is refused. A scoped token's /_schema names none.

And where it holds a webhook consumer, a top-level "hooks" follows "schedules" (or collections), to the server's token: [{"name", "hook", "text", "armed"}]. armed is whether this server holds a secret for the hook, as statements lists it; a secret itself is never listed. ?as=fennecql writes each hook's definition after the scheduled ones. Either form reads back through POST /_schema/plan as a plan of nothing, and a listed hook other than the one its text takes is refused (400, is listed with the hook `github`, and its text takes `stripe`'s events). A scoped token's /_schema names none.

A bound, scheduled or hook-taking statement the schema broke — its collection or a field it reads dropped — is listed with why, "broken":"..." after its text, as statements lists it; the plan reads it back holding it to no collection, so the server's own description still plans nothing. ?as=fennecql writes it as comments, a -- broken: ... line and its definition beneath, each line -- : the text declares only what its collections can hold.

With --mcp, /_mcp is the Model Context Protocol's endpoint: an agent's schema, search, query and get tools, and write and a memory where asked for, each a statement held to the request's token as /query is — see Agents and MCP. Without the flag it answers 404.

/_metrics is the server's statements, latency and data in Prometheus's text format, readable with --http-token or the admin token — see Monitoring. The underscore keeps it out of the way of a collection called metrics; a collection called _metrics cannot be read over GET.

The OpenAPI document

GET /_openapi.json is an OpenAPI 3.1 description of every route above: its parameters, the query string's clauses, each body, each answer and its status, the refusal's {"error": ...} and a 503's retry_after, the headers that carry meaning (Idempotency-Key, Fennec-Wait, Fennec-After, Fennec-Read, If-Match, If-None-Match, ETag, X-Request-Id, Retry-After) and a row's 304 and 412, the tokens a route takes — the server's, a scoped JSON Web Token, a node's admin token, the replication token, a router's --token — and a subscription as text/event-stream. It asks no token: it is the binary's, the same for every server of its kind whatever its flags or data, so a route served only under a flag says so (x-fennec-flag) as each place serves it — a file's /_changes under --cdc, a node's tenants' under --replication-token; a file's hook under --hooks, a tenant's under --admin-token, whose routes set its secrets — and its info.version is the document's own, never the build's, which only a token reads; it moves where a break is made on purpose (below). A GET that answers HEAD lists a head operation beside it; the others (the change stream, a replica's stream and status, a subscription, the admin's reads) answer GET alone. A file's server describes its routes; a tenant node (--dir) its own at the root, /_admin/ marked with the admin token, and each tenant's below /t/{tenant}; fennec-shard what a tenant's client calls through it, with the same operation ids as a node's (tenantQuery), and its own /_metrics, /_studio/ and /_replication (its /_shard/ routes are in the sharding reference). Every route the server answers is in it, and nothing else: CI sends each operation of the document to a running server, a node and a router, with its token and without, and finds each route of their code in the document.

curl -s http://127.0.0.1:8080/_openapi.json -o fennecdb.json

# Swagger UI on the document (a page on another origin reads it with --http-cors)
docker run -p 8081:8080 -e SWAGGER_JSON_URL=http://127.0.0.1:8080/_openapi.json swaggerapi/swagger-ui

# a client in any language OpenAPI Generator writes
npx @openapitools/openapi-generator-cli generate -i fennecdb.json -g python -o fennec-client

The official SDKs (Languages) speak the same routes with the query builder and the sync on top; a generated client is for a language they do not cover, or a contract test.

Compatibility

The REST API only grows. There is no /v1/ in a path: a route keeps its method, its path, its parameters and what its answer holds, and what is new comes beside it. CI holds every pull request's three documents (a file's server, a tenant node, a router) to the ones committed before it, and to main's with main's own copy of the check, so a change the documents show breaking a client fails unless it is named as a break on purpose, with its reason.

The check reads the documents, not the code. It sees what they say: every operation and the flags it is served under, its id, its path, query and header parameters, its request body field by field, its statuses, the fields and headers of its answers with their types and which are required, and the security schemes and scopes it takes. It does not see what they leave unsaid: a change of behaviour behind the same shapes, or a default -- the documents state none, what a parameter left out means is in its description. A body that takes any field, a document or a hook's event, is described as open, and held only to being an object.

What
May change without noticea new route; a new optional parameter, header or body field; a new field or header in an answer, or one made always present; a status for a new case, or a status folded into its range (200 into 2XX); a request type taking more (a value, a longer list, another form, int32 to int64); a flag a route needed no longer needed; a token or a scope no longer asked; the words of a refusal's error, a description, the order of an object's fields. A client ignores what it does not know and reads a refusal by its status.
Announced firsta route removed or moved, its operationId or a path parameter renamed, or a flag added to what serves it (x-fennec-flag); a parameter or body field removed or made required; a request type taking less, or its pattern changed at all; a documented status, answer field or header removed, one no longer always present, or a field's or header's type changed; a token or a scope asked where none was, or a security scheme defined otherwise; what a parameter left out means. Each is made on purpose, named with its reason, and moves the document's info.version, a whole number, forward.

A route on its way out is deprecated: true in the OpenAPI document (with x-fennec-sunset where a date is set), and every answer its handler gives, a refusal among them, says so in the standard headers, so a client, a proxy or a log search sees it before it goes. A refusal made before the handler runs carries none: a token missing or wrong, a hook's event whose signature does not verify, a 503 for a connection no thread was free for. Under --http-cors the three headers are exposed to a page on another origin:

Deprecation: @1794096000
Sunset: Sat, 08 May 2027 00:00:00 GMT
Link: <https://fennecdb.com/docs/http-reference#compatibility>; rel="deprecation"; type="text/html"

Deprecation (RFC 9745) is when it was deprecated, in seconds since the epoch; Sunset (RFC 8594) the date after which it may go, where one is set; the Link the page saying what replaces it. Its removal comes later, past that date where one is set, in a release whose notes name it. Nothing is deprecated today.

Filters

Filter in the query string as field=operator.value, for example ?year=gte.2024. For anything the pattern cannot say, use ?where= with FennecQL.

Operatorseq neq lt lte gt gte like has in is
Negationthe not. prefix — ?summary=not.is.null, ?year=not.eq.1999
Shorthandan unrecognised prefix makes the whole value an equality: ?year=2024
List?year=in.(1999,2023)
Pathsa path into a json field where a field goes: ?meta.lang=tr, ?meta.source.rank=gte.2, ?select=title,meta.source.site, ?order=meta.source.rank.desc; the value is read as JSON reads it — a number, true, null, a quoted string — and as the text it is otherwise. A body's object is a json field's value, every number in it as written, and PATCH with {"meta.lang": "en"} sets one key inside the field (Objects and paths)
Clausesselect order limit offset count where lookup
Ordering?order=year.desc,title.asc; a collation among the modifiers puts text in its order — ?order=name.und.desc is order name collate und desc, name.tr Turkish (Collation)
Free expression?where=year >= 2024 and tags has "rust" — full FennecQL
How a filter value is typed

Values are parsed by the field's type: ?year=gte.2024 is an int, ?published=gte.2024-01-01 is a timestamp. An unknown field returns 404. where= exists for what the pattern cannot hold — or groups and function calls.

Send the vector in a POST body to /<name>/near, with an optional filter. Add "match" to mix in keyword search.

curl -X POST http://127.0.0.1:8080/articles/near -d '{
  "vector": [0.1, 0.2, 0.3],
  "ef": 128, "limit": 5,
  "select": ["title"],
  "where": "year >= 2024"
}'
# [{"title":"the rust book","_score":0.97}]
  • field can be left out when the collection has one vector field.
  • Query-string filters are combined with the body's where.
Why near is a POST

near is a POST rather than a query parameter because a 768-dimension embedding does not fit in a query string. Squeezing it into the URL — base64, truncation — is unreadable and runs into proxy and server URL ceilings. PostgREST's model does not cover fennecdb's headline feature, so near gets its own endpoint, and it takes a filter in the body.

If the collection has a single vector field, field can be left out. Filters in the query string are anded with the where in the body.

A vector in an answer, and a _score, is its f32s written as the shortest decimals that read back as them — 0.1 as it was written, the text pgvector gives — rather than the 0.10000000149011612 of the f64 each widens to. A reader that takes a number as an f64 and rounds it to f32, as a Float32Array does, gets every one back: the one f32 an f64 would round away, 7.038531e-26, is written as its f64.

Any other float is its f64's shortest decimal, but a whole one short of 263 either side, which is every digit of the int it is: the float 260 is 1152921504606846976, not 1152921504606847000, which the server reads back as another int — an int and a float compare by their true values — so a number read from an answer and sent back as a parameter finds the row it came from. A client sending a whole number of 253 or more writes every digit of it the same way. A number a request sends past a float's range — 1e400, 1e-400 — is refused (400), naming it and the byte it starts at, never read as an infinity or 0 (limits).

A "match" makes it hybrid: BM25 over the collection's @text field ranks the same request, and the two rankings are fused by reciprocal rank (fuse). match_field names the text field when there are several; match_fuzzy (true, or 0 to 2 edits) and match_prefix read its words as match ... fuzzy and prefix do; fuse_k and candidates are the rank offset (0 to 1 000 000) and how many candidates each side ranks (1 to 10 000).

curl -X POST http://127.0.0.1:8080/articles/near -d '{
  "vector": [0.1, 0.2, 0.3],
  "match": "borrow checker lifetimes",
  "limit": 10
}'

Embedding a collection

Use lookup to nest matching rows of another collection under each row, such as each product's latest reviews.

curl 'http://127.0.0.1:8080/products?limit=20&select=name\
&lookup=reviews&reviews.on=product_id&reviews.stars=gte.4\
&reviews.order=created.desc&reviews.limit=3'
# [{"name":"Kahve","reviews":[{...},{...},{...}]}, ...]
  • Prefix the child's options with its name: reviews.on, reviews.limit.
  • Chain levels with a comma: lookup=orders,lines.
  • A key over several fields lists a field of each side: lines.on=org,order&lines.parent=org,id, FennecQL's on (org, order) = (org, id).
  • A level that folds aggregates in its select, as the query's own does: orders.select=count(*),sum(total), each parent's children folded, and orders.group=status a row a group, its order naming columns (orders.order=count(*).desc). Off a query's groups, <name>.parent names a column of its list: /orders?select=courier,count(*)&group=courier&lookup=couriers&couriers.on=user&couriers.parent=courier.
How lookup parameters are prefixed

lookup=<name> names the collection once; every key prefixed with it configures the clause — on (required, the child's field holding the key), parent, select, order, limit, offset, required, where, and any field name as a condition, in the same op.value form the parent's filters use. Prefixing is what keeps the two sides apart in a query string, the way the clause's position does in FennecQL.

curl 'http://127.0.0.1:8080/shops?limit=20&select=name\
&lookup=orders,lines&orders.on=shop_id&orders.limit=3\
&lines.on=order_id&lines.limit=5'
# [{"name":"Merkez","orders":[{"code":"A","lines":[{...}]}, ...]}, ...]

A comma-separated list chains, read left to right, each name binding to the one before it and each level keeping its own prefix. A query string has no position to scope by, so the order is written out; the meaning is the same one FennecQL gets from position, up to the same 8 levels.

lookup is a reserved key here, so a field named lookup cannot be filtered over the REST path — the FennecQL and fennec-server paths are unaffected, as with the other reserved names.

A query with a lookup answers with the children nested under the collection's name — one object per parent, with an empty array where nothing matched, and a chain nests all the way down.

curl -X POST http://127.0.0.1:8080/query \
  -H 'content-type: application/json' \
  -d '{"query":"get products limit 20 lookup reviews on product_id limit 3"}'
# [{"id":1,"name":"Kahve","reviews":[{"id":1,"stars":5,"body":"guzel"}]}, ...]

Calling a named statement

POST /_call/<name> calls the named statement <name> with the arguments in its body, by name — the call <name> $1 it stands for, run and answered as /query runs and answers that statement: the last statement of its body's rows, Fennec-Seq and all. A statement of no arguments takes no body.

curl -X POST http://127.0.0.1:8080/_call/transfer -H "Authorization: Bearer $TOKEN" \
  -H 'Idempotency-Key: t-2026-11-01-7' \
  -d '{"params": {"from": 1, "to": 2, "amount": 300}}'
  • The body holds params alone, an object of the arguments by name (or null); anything beside it is a 400, never ignored. The server's token passes the claims a statement reads over /query, call transfer $1 as $2.
  • The path takes a POST alone (405 otherwise). A path of its own, so a proxy, a firewall's rule or the router tells one call from another without reading a body; under a tenant it is /t/<tenant>/_call/<name>.
  • In order, a call is answered: 401 without a token that verifies; 403 for a token bound to another tenant; 429 past --request-rate, then past --call-rate; 404 for a statement not granted to a scoped token or none of that name, in the same words; 403 for a claim it declares that the token lacks; 400 for an argument missing, extra, null or of another type, or a check that is false; 403 for an append-only update or delete, or, for a statement whose body writes, a read-only server, a replica or a request marked Fennec-Read: replica, judged alike over /_call, /query and /batch; 409 for a broken statement, saying why, or a unique value taken; 412 for a require not met, with its reason; 400 past --call-max-rows; then what any write meets — 422, 507, 500 outcome: unknown, 503, 504. A tenant being moved, or one whose node's lease is out, answers a call 503 to come back before any of it is judged — the copy that answers may not hold the statements the tenant's home does — but one whose statement it holds and reads, which it answers as it answers a get.
  • A statement whose body only reads is called as a read: beside the other reads, under no write lock, on a snapshot where it reads many rows, keeping no key and moving no change — so a read-only server, a replica and a call marked Fennec-Read: replica, sent near through a router, answer it, as they answer a get. Its Fennec-Seq is the change it read at.
  • An Idempotency-Key makes a call once: sent again, the first answer is replayed (Idempotent-Replayed: true); the key with another path or body is 422.
  • Fennec-Wait holds a call as it would hold its body's sets and dels (below); a page on another origin calls as it queries, under --http-cors.
  • Counted in /_stats/statements as call <name> $1 however it came, logged by --slow-ms by that shape and the version that ran, and traced with db.stored_procedure.name; a router counts it under the route call, never its name.

Writing over the row you read

GET /<name>/<id> answers the row as an object and its tag in ETag. Send the tag back with a write to that row in If-Match and the write is made only if the row is still the one you read; if another write changed it since, the answer is 412 Precondition Failed and nothing is written. HTTP's own headers, as RFC 9110 has them: any client, proxy or generated SDK knows them.

curl -si http://127.0.0.1:8080/orders/42
# HTTP/1.1 200 OK
# ETag: "5c0e4a91d27b3f6e8a1c2d9b0e7f4a35"
# {"id":42,"status":"open","total":129.5}

curl -si -X PATCH http://127.0.0.1:8080/orders/42 \
  -H 'If-Match: "5c0e4a91d27b3f6e8a1c2d9b0e7f4a35"' -d '{"status":"paid"}'
# HTTP/1.1 200 OK
# ETag: "a8d2f17c03b94e5d6c1e0f2a9b8d7c64"   the row's tag after the write
# {"updated":1}

# the same request again: the row moved on, so nothing is written
# HTTP/1.1 412 Precondition Failed
# {"error":"If-Match: the row is not the one tagged, it changed since"}
If-Match: "<tag>"on PATCH, PUT or DELETE: written only over the row of that tag (a list of tags: any of them); else 412. A weak tag (W/"…") names no row for a write.
If-Match: *written only where the row is there; a missing row is 412, and a PUT makes none
If-None-Match: *on PUT: the row is made only where there is none of that id, else 412 — a create that never writes over
If-None-Match: "<tag>"on GET or HEAD: 304, no body, while the row is the one tagged; on a write, 412 where it is
ETagon every GET of a row, and on a PATCH or PUT sent with a precondition: the row's tag as the write left it, for the next one. Cache-Control: no-transform beside it, so a proxy that compresses the answer leaves the tag strong
  • The look and the write are one step. The server reads the row's tag under the write lock that then makes the write, so no write lands between them: of clients sending a write under one tag at once, exactly one is made and every other is 412.
  • A tag is the row's content: a hash of the row as the token is shown it, the bytes the GET answers. It changes whenever the row does, and is the same on a replica and after a restart for the same row. A write that leaves the row as it was leaves its tag, so a write under it after that is made — it loses nothing.
  • A scoped token's tag is of what it is shown. A field a read rule withholds is not in its row, and not in its tag: a change to that field alone leaves the token's tag as it was, its writes under it go on, and the tag tells nothing of the field.
  • On no other route. If-Match or If-None-Match on a write to a filter, /all, POST /<name> or /_schema is refused (400), never passed over: a write sent as conditional is never made as one that is not. /query, /batch and /_call refuse If-Match whatever they run, and If-None-Match on a write; on a read it is the poll's.
  • A header sent on several lines is one list, as RFC 9110 has it: If-Match holds where any line names the row, and If-None-Match refuses where any line does.
  • A scoped token writes over the row it read with PATCH or DELETE under If-Match. PUT names the row's id, which a scoped token never writes — it could write over a row the token cannot see — so it is 403 whatever its preconditions: the server's token's alone. A row a token's rules hide from it is answered as one that is not there, the same 404 and the same 412.
  • With an Idempotency-Key a conditional write sent again after it was made is answered as the first time (its status and body, not its ETag), never 412; a refused one keeps no key.
  • /<name>/<id> is the row: an id is digits alone, and the route takes no query string (400) — the tag is the whole row's. A missing row, or one past its @ttl, is 404 to a GET, whatever its preconditions; without a precondition, a PATCH of one answers {"updated":0} and a DELETE {"deleted":0}, as the filter routes do. PUT writes the body as the row, a field it leaves out gone, and a body's id other than the path's is 400.
  • Behind Cloudflare, or any proxy that compresses: a compressed answer's strong ETag is made weak (W/"…"), which names no row for If-Match, so every conditional write would be 412. A row's answer says Cache-Control: no-transform, which Cloudflare does not compress; see the global entry.

Holding a write until it can write

Send Fennec-Wait: <ms> with a set or a del on /query or /batch, or a call of a statement whose body sets or deletes, and while it would write nothing the server holds it, answering the moment it writes — or at the end of the wait, 30 seconds at most, as it would have answered at once. A job queue's claim waits for a job that way (Waiting for a job).

curl -X POST http://127.0.0.1:8080/query -H 'Fennec-Wait: 30000' \
  -d '{"query":"del tasks where run_at <= now() order run_at limit 1 returning *"}'
  • What wakes it: a write to a collection it reads, and the time reaching a row's moment — a field compared with now(), a @ttl. A filter that reads the time any other way is refused (400), as is a request holding a put, or a call whose body inserts. A call whose body only reads is answered at once.
  • A derived row wakes it as any write does: a set held on a collection a bound statement writes is answered by the write whose binding made the row it waits for.
  • Wrote nothing means no row written, or a require not met — for a call, nothing its body wrote, whatever its last statement answered; any other refusal is answered at once.
  • With Fennec-After the header is that wait's, as below, and holds no write.

Marking a read

Send Fennec-Read: replica with a request that only reads, and a router standing in a region where the tenant has a read replica answers it there rather than from the tenant's home (Read replicas); with Fennec-After and Fennec-History, as an answer from home named them, it is answered from nothing older than that change of that history (Reading your own writes), a subscription and a /_changes page as much as a read: each waits for it before its head. Every server runs a marked request read-only on every route — home, a replica, a single file; a statement, REST, /batch, an MCP tool, a change-stream consumer's commit — so a write sent with the mark is refused with 403 and words that say why, never landed; a value but replica is a 400. A copy that has not caught up with its primary yet answers it 503.

curl -X POST https://ap.example.com/t/acme/query -H 'Fennec-Read: replica' \
  -H 'Fennec-After: 1043' -H 'Fennec-History: 2-6c1f0a9e44d7b2c8' \
  -d '{"query":"get orders where customer = $1","params":["c-7"]}'

Request bodies

A body comes with its Content-Length or Transfer-Encoding: chunked, as a client streaming it or a proxy that re-chunks it sends one: every route reads the chunks into the one body its length would have given, an Idempotency-Key digesting the same bytes either way, and fennec-shard sends it on to the tenant's node with its length. A connection kept alive reads its next request right after the last chunk. Both ways are held to the same ceiling, 64 MiB (--max-body), a chunk's size refused the moment it would pass it.

What a chunked body may hold, and what is refused
  • A size is 1 to 16 hex digits on a line of at most 1 KiB; a chunk extension after a ; is read past, and the trailer fields after the last chunk are read and dropped — a trailer is never taken as a header. Extensions and trailers together are at most 64 KiB (431).
  • A body past the ceiling is 413 as soon as a size says so, before a byte of that chunk is read; it is refused, never cut.
  • 400, the connection closed after it: a Content-Length beside a Transfer-Encoding, chunked named twice or not last, a transfer coding in an HTTP/1.0 request, a size of anything but hex digits, a line that ends in a bare LF or holds a bare CR, a header or trailer folded onto the line before or with whitespace before its colon, a header name that is not a token or a value holding a control character, two Content-Lengths that differ or one that is not digits alone. Only a space or a tab is trimmed around a value, so chunked followed by a non-breaking space is a coding of its own (501). Each is a request two servers could frame two ways — one in front and this one — so that bytes one sent as the next request would be read by the other as a body (request smuggling, RFC 9112 §6.3).
  • 501: a transfer coding other than chunked, gzip, chunked among them.

A body read whole is what a write needs anyway — a statement runs once all of it is in, and the router resends a request only with its body in hand — so a chunked one costs no more memory than its length would: its buffer grows as its bytes arrive, never by the size a chunk declares.

Compressed answers

An answer of 1 400 bytes or more — a page of rows, a subscription's seed, /_changes — goes as gzip to a client whose Accept-Encoding takes it, five to six times smaller. Browsers, Go, Node's fetch, Swift, OkHttp and Dart ask for it and unpack it on their own; nothing to set. A client on the server's own host or private network gets the answer as it is, since there compressing only adds time.

curl -s --compressed http://db.example.com/query \
  -d '{"query": "get docs limit 1000"}' -o /dev/null -w '%{size_download} bytes\n'
# 28576 bytes for 1 000 rows of some 150 bytes; 150103 without --compressed
FlagDefaultWhat it does
--http-gzip <bytes|off>1400The size from which an answer is compressed; off, never.
--http-gzip-localoffCompress for a client on this host or a private network too: behind a load balancer that does not compress, or over a slow private link.
What is compressed, for whom, and what it costs

Measured end to end, a page of 10 000 rows (1.5 MB) came in 246 ms as it is and 49 ms as gzip at 50 Mbit, 62 and 14 ms at 200 Mbit, and broke even at 1 Gbit; on loopback it took 11 ms rather than 5. So a client on loopback, a private address (RFC 1918, link-local, IPv6 unique local) is answered as it is; behind a router the node judges by the client the router names, not the router. A subscription's 100 000-row seed, 15.4 MB, came in 0.6 s rather than 2.6 at 50 Mbit.

  • JSON, NDJSON and text are compressed; an archive or a backup never is.
  • An answer carrying an ETag — a row by id, a polled read — goes as it is: its tag names those bytes, and a conditional write compares it strongly (Writing over the row you read).
  • Every answer that may be compressed says Vary: Accept-Encoding, so a cache keeps the two apart.
  • A subscription is one gzip stream, each event in it readable the moment it arrives; the server keeps nothing of the compression between events.
  • Secrets. A token is never in a body, so the BREACH attack's usual target is not there. Where one read mixes rows an attacker can write with rows they must not learn, and they may watch your clients' traffic, start the server with --http-gzip off.

The compressor is fennecdb's own, about 290 MB/s on an Apple M1: no library was added for it.

The data ceiling

With --max-memory, writes that would grow the data past the limit are refused with 507. Reads, deletes and compact still work.

What --max-memory refuses and allows

Inside fennec-server started with --max-memory, the listener holds its writes to that ceiling: above it, a statement that grows the data — a put, a patch, a create index, a call whose statement inserts or sets — is refused with 507, a batch stops there as at an error, and reads, deletes, a call that only reads or deletes and compact go on, since they are the way out. The rule and why it is there are under Server.

Refusals and their statuses

A refusal is a status and {"error": "..."}. The status says what to do about it; a token past its exp adds the code a program tells it by, "code": "token_expired", beside the words, which are a person's (Expiry; a later server may name other codes, and every SDK's error carries it as its errorCode); a /batch that stopped adds where (at) and what stayed applied (completed), a require that said why gives the words (reason, the statement's own, on a lone statement and a /batch alike), a statement bound to the write that refused it is named to the server's token (binding, the engine's words after the binding's; a scoped token is told the status and reason alone), a tenant's quota names itself (quota, and the Fennec-Quota header), and one to come back from says when (retry_after, the seconds of its Retry-After header: a page on another origin, or an app's replica, reads the body; a quota's 429 says it to the millisecond as well, retry_after_ms, which is the one to wait). A write whose outcome the server cannot know says so ("outcome": "unknown", a 500), with where it left the database in the body (seq, history) rather than in Fennec-Seq, which a client takes as its own position. Every SDK's error carries the rest; the outcome and its position are the Go, .NET, JavaScript and Python clients' (Go's and .NET's code outcome_unknown, JavaScript's and Python's outcome).

StatusMeansWhat to do
400a statement that does not parse or run, a bad parameter; a body framed two ways (Request bodies); If-Match or If-None-Match off a row's route (Writing over the row you read)fix the request
401no token, or a wrong one; "code": "token_expired" where its exp passeda fresh token from its issuer, at a 401 naming no code too; one minted again and refused the same waits for what minting does not change -- a key the server has not fetched yet, an nbf its clock has not reached (Expiry)
403outside the token's rules — a row, a field, a change no transition names, a returning row it may not read, the write put back whole, a PUT /<name>/<id> — a write to a replica or a read-only server, or one marked Fennec-Readwrite where it is taken
404a collection, field or tenant that is not there
409an id or a @unique value taken, a collection that exists; a /batch holding a compact that --call-rate stopped after statements of it landed — never a 429 or 503 then, which say nothing rana lost race for a value; for the batch, send the statements from at on, alone
410a /_changes cursor the server no longer reachesstart again from the since it names
412a require not met, its batch put back; reason where its else '…' gave one. A row's If-Match or If-None-Match that did not hold, nothing written (Writing over the row you read)read again, decide again; tell refusals apart by reason, not at
413a body past the ceiling, 64 MB, by its length or its chunkssend less at once
422an Idempotency-Key sent with another requesta new key for a new request
429a tenant's quota of streams, held, requests, writes or write_bytes; a scoped caller past --request-rate on any route or --call-rate, nothing of the request run (Requests a second)come back after retry_after_ms
500outcome unknown ("outcome": "unknown"): a write a tenant's node landed and answered after its lease from the router lapsed — its tenant may have been failed over without it, or still be there with it; a /batch that ran a statement at a time says how far it got, its seq the last landed statement'ssend it again with the same Idempotency-Key; without one, wait a lease and a tenth (--auto-failover × 1.1) after the answer — until the tenant settles the node answers reads with the write in them, one sent with Fennec-After too — then read it back, or send a read with Fennec-After and Fennec-History set to its seq and history, which a primary without it answers 504 (for a batch, a 504 does not say which earlier statements survived: read those back)
500an fsync that failed under --sync always: the write may or may not be on the disk, and the server takes no write until its file is opened againrestart the server, then read the write back, or send it again with the same Idempotency-Key
502through fennec-shard: the tenant's node took the request whole and its connection ended before an answer, or it began its answer and broke it off — it may have runread to learn whether it ran, or send it again with the same Idempotency-Key
503too many connections or subscriptions; a connection the server could make no thread for, at its thread limit; a tenant being moved or failed over; a node going down. One written as the connection was taken, before the request was read, says so in Fennec-Unserved (ceiling or no_thread): the request never ran. Through fennec-shard, a request the router never got to the tenant's node — refused, or not answered in time — says so in Fennec-Unsent: 1: it never ran eithercome back after Retry-After seconds; a request that never ran goes again as it is
504a Fennec-After change, sent with a read, a subscription or a /_changes page, that did not reach a replica in the wait, or one a primary's history does not hold — lost in a failover; seq and history say where it standsask again, or ask the primary; take the primary's position as yours
507past --max-memory, or a tenant's quota of bytes or rows; the write put back wholedelete, then write again: waiting does not help
HTTP/1.1 429 Too Many Requests
Fennec-Quota: writes
Retry-After: 1

{"error":"the tenant writes past its quota of 100 rows a second","quota":"writes","retry_after":1,"retry_after_ms":10}

HTTP/1.1 503 Service Unavailable
Retry-After: 1

{"error":"the tenant is being moved; retry shortly","retry_after":1}

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer

{"error":"the token has expired","code":"token_expired"}

HTTP/1.1 412 Precondition Failed

{"error":"unmet: no account to credit (`set accounts` wrote 0 rows, and requires 1)","completed":0,"at":1,"reason":"no account to credit"}

HTTP/1.1 412 Precondition Failed

{"error":"bound statement `voided`, after `set` on `orders`, refused this write: unmet: no ledger line (`get ledger` answered 0 rows, and requires 1)","completed":0,"at":1,"reason":"no ledger line","binding":"voided"}

HTTP/1.1 500 Internal Server Error

{"error":"the write landed on this node, but by the time it was answered ...","outcome":"unknown","seq":4182,"history":"2-6d1f0c2a9b3e4471"}

A quota is a tenant node's (fennec-server --dir): what each bounds is under Sharding: reference, how it is set under Sharding: tenants and why the statuses are these under Sharding: design. 507 is the storage the request needs and the tenant has not got — the request is fine, and a smaller one may fit, so not 413, which is about the body; 429 is a rate or a share the tenant comes back within.

Subscriptions

GET /<name>/changes is a server-sent events stream: first the rows matching your filter, then each change to them as it happens.

curl -N 'http://127.0.0.1:8080/articles/changes?year=gte.2024'
# event: seed
# data: {"seq":12,"rows":[...]}

A seed whose rows pass 1 MiB of JSON comes in parts, each an event: seed of the same seq. The first has no part, each later one carries it (1, 2, ...), and every part but the last says "more":true. A seed under 1 MiB is one event, with neither field.

# event: seed
# data: {"seq":42,"rows":[...],"more":true}
#
# event: seed
# data: {"seq":42,"part":1,"rows":[...],"more":true}
#
# event: seed
# data: {"seq":42,"part":2,"rows":[...]}

A part without part begins the seed, again where parts of one came before it: the server may begin a seed anew, and a client lets go of the parts it held. The server reads the rows a page at a time beside the writers and never holds a seed whole. A client shows nothing of the seed until its last part (a seed in parts).

  • Limited separately from ordinary requests: --http-max-streams, 64 by default, a database's, a stream giving back its place under --max-connections as it begins unless that ceiling is 0 -- on a tenant node each tenant's own, and each one of --max-connections too, which a node's tenants share (a tenant's share).
  • In gzip where the client asks for it and is across the network, the seed five to six times smaller, each event readable as it arrives, each part of a seed deflated alone as every event is (Compressed answers).
  • A row reaching its @ttl is told as a deletion at its time, as a write would be, not when the sweep deletes it a minute and its grace later.
  • An inner get in where (/board/changes?where=msg in (get notes select title)) is the list it is at each change. A write to notes is a write to what the stream reads: a note whose title names a message lets that message's rows in, sent as a change, and one deleted or renamed takes them out, deletions of the rows the stream was sent — no write to board needed. A note reaching its @ttl takes its message's rows out at its time, and a list that reads the time (now()) is answered again a second after its last answer ended. Under a scoped token the list holds the notes the token may read, and no other. Such a stream is seeded again when it resumes with since. Its list is answered as a query of it is, beside the writers where the query would be; the shape runs again only where the list moved, and a long list is looked up rather than walked at each change.
  • Sent after a write (Fennec-After, and Fennec-History as the write's answer named it), a stream waits for it before its head, as a read does: its seed holds the write, or it is answered 504 with where the server stands (Reading your own writes). One resumed with since waits the same way: since is where the stream left off, not a write it must see.
  • Its head says where the server stood as it opened: Fennec-Seq, the change its seed is at or after, and Fennec-History, the history that change and every event's seq are of, as a write's answer names it (none on a database that never had a replica). A read sent after an event's seq to another copy goes with both (Reading your own writes): a number alone names no write across a failover. FennecHttp.live on a client reading near sends its runs so.
  • In the browser, Sync builds on this stream.
Why a subscription does not poll

GET /<name>/changes is a server-sent events stream: a seed carrying the current shape, then incremental diffs. No driver needed.

A subscription does not poll. fennec-core has no waiting primitive at all — there are no threads in wasm — it only reports that the change counter has reached a point, and fennec-http ties that to a Condvar. A 50 ms polling loop would take 20 read locks per second per subscriber and still add 50 ms of latency.

Every subscription is a connection and a thread, so they are counted separately from ordinary requests (--http-max-streams, default 64, a database's: on a tenant node each tenant's). Sharing one ceiling would let 100 subscribers shut the server to plain requests, so a stream gives back its place under --max-connections once it has its own: a server holds that many connections and that many streams at most. At --http-max-streams 0 (no ceiling) a stream keeps its place, so that --max-connections still bounds its thread. On a tenant node a stream keeps its place as well: the node's --max-connections is the bound every tenant shares, the only one on all of their threads, of which each tenant's streams take a quarter at most unless its quota says otherwise. The client-side layer built on this stream is Sync.

A row past its @ttl leaves every read at once and the file at the sweep, a minute and its grace later; a stream of its collection is told of it at its time. It works out when the next row of the collection reaches its time -- a step of the field's ordered index, again after each write to the collection -- sleeps until then if no write comes first, and reads the rows that reached it since it last looked, the shape ANDed in, telling each as a deletion as the sweep's delete would be told: a scoped stream of the rows it was sent alone, a shape that holds nothing (what FennecHttp.live opens) that something changed. Heard at the sweep, a courier whose phone went quiet stayed on a dispatcher's map 73 s after it had gone from every read; at its time, it is told about 10 ms after it. The sweep's delete comes after, a deletion of what is gone already.

What a stream costs, measured on an M1 with streams of a shape that holds nothing (what FennecHttp.live opens): 45 to 57 KB of resident memory and a thread each, and every write wakes every stream, which reads what it changed: a write's p50 went from 0.26 ms with none to 0.94 with 60 and 3.1 with 500. A page thousands view should not hold one a viewer; it polls (below).

Under a scoped token, a stream of a shape that holds nothing (where=false) is told of the writes to rows the token may read, and of nothing else: the server follows the token's own filter, keeps the ids it selects and sends none, and a write to one of them, or one of them leaving the token's rows, is a change holding no rows. ANDed with the token's filter, the shape matched nothing and FennecHttp.live never ran again; told of every write, the stream would hand the token the moments of other users' writes.

Polling a read

Send If-None-Match with a /query read and the answer carries an ETag: the change the database stood at -- on a replica that took its primary's image, the images it took after a dot ("48211.1"). Sent back, the tag is answered 304, with no body and the query not run, while no write has touched a collection the read reads and no image was taken.

curl -si http://127.0.0.1:8080/query -H 'If-None-Match: "0"' \
  -d '{"query":"get inventory select available where sku = $1","params":["TENT-1"]}'
# HTTP/1.1 200 OK
# ETag: "48211"
curl -si http://127.0.0.1:8080/query -H 'If-None-Match: "48211"' -d '...the same...'
# HTTP/1.1 304 Not Modified
  • Nothing is held between polls: no stream, no thread, no wake-up at a write. FennecHttp.live(query, cb, { poll: 5000 }) polls so.
  • Untagged, and run each time: a read of a collection whose rows expire (@ttl), or one calling now() — answers that move with no write. A read holding an inner get is tagged, and the collection the inner get reads is among those a write to answers it again.
  • A scoped token's tag is its answer's ("c…", a digest of the rows): its query runs every time and is answered 304 when the rows are the ones it had. Tagged by the change counter, 304 against 200 -- and a 304's speed -- told it when anyone wrote to what it reads, other users' rows among them, and the tag how many writes the database had taken.
How a 304 is decided, and timed

Whether a collection was written since a tag is the change ring's answer (Database::changed_collections_since): a tag older than the ring reaches, or a collection dropped since, counts as a change and the query runs. A read without the header is answered as before, no tag worked out. Over one keep-alive connection a 304 took 54 us at the median, against 55 for a read by key and 95 for a page of 24 run; the round trip is most of either. A browser keeps its connection between polls, so a public page polls through the site's own server or a proxy, which keeps few connections to fennec-server however many viewers it has.

A tag is a change of the copy that answered. A read replica holding that change of its history (Fennec-After) judges it as home does, but only up to where it stands: behind home it answers 304 to a write home holds, so FennecHttp.live polls home on a client reading near (Read replicas).

Change data capture

To see every write exactly as it happened — to feed a search index, Kafka or a read model — start the server with --cdc and read GET /_changes: one JSON line per write.

fennec-server --file data.fennec --http 127.0.0.1:8080 --sync 250 --cdc

curl -i 'http://127.0.0.1:8080/_changes?since=0&limit=1000&wait=10000'
# Content-Type: application/x-ndjson
# Fennec-Next: 5
# Fennec-Seq: 5
#
# {"seq":1,"at":1790784252138,"collection":"a","op":"create"}
# {"seq":2,"at":1790784252158,"collection":"a","op":"put","id":1,"doc":{"id":1,"n":1,"t":"x"}}
# {"seq":3,"at":1790784252158,"collection":"a","op":"put","id":2,"doc":{"id":2,"n":2,"t":"y"}}
# {"seq":4,"at":1790784252173,"collection":"a","op":"put","id":1,"doc":{"id":1,"n":1,"t":"z"}}
# {"seq":5,"at":1790784252187,"collection":"a","op":"del","id":2}
  • Send Fennec-Next back as the next since and nothing is missed or seen twice.
  • Only writes already on disk are handed out, and none to the server's own collections, whose names start with _.
  • Fennec-Seq is the last write the database holds: when Fennec-Next has reached it, you have every write.
  • Sent with Fennec-After, a page waits until the server holds that change, as a read does, and its Fennec-Seq is never behind it; a write not yet on the server's disk comes on a later page.
How /_changes pages through the writes on disk

A subscription keeps a query's rows up to date, and a client that falls behind its ring of ids is sent the rows again. A service that must see every write — to index it elsewhere, send it on to Kafka, or keep a read model — reads GET /_changes instead: the writes on disk, documents and all, one JSON object a line, from any write the server still keeps.

  • seq is the change counter's number for the write, and Fennec-Next the last one in the answer: sent back as the next since, nothing is missed or had twice. Keep it where your consumer keeps its own state, and commit the two together.
  • Fennec-Seq on every answer is the last write the database holds, on disk or not yet, the writes the stream leaves out (a consumer's cursor, an idempotency key) among them. An answer whose Fennec-Next is that has every write there is: a worker that catches up before it serves knows it at once, where an empty page alone could not tell it from one whose writes are not on disk yet under --sync 250, and waited out pages to be sure. A Fennec-Next behind it has writes to come: read again with wait. A client that notes Fennec-Seq for Fennec-After reads a replica from there on.
  • A batch's writes are one record on disk and come together, numbered one by one; a cursor inside one goes on after the write it names.
  • Only what an fsync has covered is handed over, as a replica is fed: a write the server lost in a crash never reached a consumer.
  • since left out is the last write on disk: what is written from now on. limit is 1 000 unless given, 10 000 at most; wait is how long an answer with nothing in it waits for a write first, in milliseconds, 30 000 at most.
  • The server keeps as many writes as --replication-buffer holds (64 MiB unless given), written to disk or not yet. A cursor further back is answered 410 with the first since it does serve — which may be a write not on disk yet, whose read waits for it — never with writes missing from the middle; one past the last write — another database's cursor, or this one restored — 409. The feed starts at the change counter when the server starts.
  • op is put, del, create, alter or drop; a put carries the document as it was written, as JSON writes a row.
  • at is when the write was appended, in milliseconds since the epoch. On a replica, and a replica of one, it is when the primary appended it, by the primary's clock; a promoted replica times its own writes by its own clock, which may be behind. Order by seq.
  • It needs --http-token or no token at all: a scoped token's filter could not hold back the deletion of a row it never saw, and is refused (403).

--cdc keeps the feed a primary keeps for its replicas and feeds none; with --replication-token it is kept already, and a tenant node's tenants have theirs at /t/<tenant>/_changes. It needs --file and a --sync other than off. Keeping it cost nothing measurable: 16 400 single puts a second over HTTP either way, and 9 000 rows of 128 dimensions read back at 283 000 a second.

Consumers

A consumer with no storage of its own can let the server remember its place, like a Kafka consumer group: create it, read from it, then commit how far it got.

curl -X POST http://127.0.0.1:8080/_changes/consumers/search-index
curl -i 'http://127.0.0.1:8080/_changes?consumer=search-index&wait=10000'
# Fennec-Next: 42 -- index the lines, then:
curl -X PATCH http://127.0.0.1:8080/_changes/consumers/search-index -d '{"since": 42}'
  • At least once: a crash between reading and committing means those writes come again.
  • Safe to create at every start: a POST creates a consumer that is not there (201) and leaves one that is where it stands (200, with its since), so a relay that creates its consumer each time it starts goes on from where it stopped.
  • Moved only by a PATCH: forward to commit, or back to read again. A POST whose since is ahead of an existing consumer is a commit sent the old way, and is refused with 409 naming where the consumer stands.
How a stored consumer cursor works

A consumer that keeps no state of its own can have the server keep where it is, as a Kafka consumer group keeps its committed offset. Made with a POST — at the last write on disk unless the body names a since — it reads with ?consumer= from where it stands, and moves with a PATCH of since once it has done with what it read, or back to a since it wants to read from again.

A POST to a consumer that is there already changes nothing and answers 200 with where it stands; only a consumer it makes is 201. The since in its body is where a new consumer starts, as Kafka's auto.offset.reset applies only to a group with no committed offset, so a program can make its consumer with {"since": 0} every time it starts and still go on from its last commit. A since ahead of where an existing consumer stands is 409, {"error": …, "since": <where it stands>}: it is a commit sent as a POST, and answered 200 its client would read the same page forever. A program that must know it made the consumer reads the status. A PATCH of a consumer that is not there is 404 rather than making it: the POST is the one way to make one. Both answer with where the consumer stands afterwards and with Fennec-Seq, as a write does, so a read sent after it (Fennec-After), to a replica too, finds it there. A commit past nothing but other commits writes nothing and leaves the consumer where it was, which reads the same writes; its answer says so. A since past the last write the database holds is 409 for either.

So a consumer has each write at least once, and a write again after a crash between reading it and committing. The cursors are rows of a _consumers collection, written as any write is — on disk before the answer under --sync always, and on the replicas — and their own writes are left out of the stream, the cursor going past them. A replica reads from where the primary's consumer stands, refuses to make, move or delete one (403), and once promoted goes on from the same place. On a tenant node they are the tenant's writes: while it is being moved, or its node's lease is out, each is answered 503 to come back. A read with wait waits on past them too, so a consumer's own commit does not wake its next read, and a commit past nothing but cursors writes nothing: a consumer that commits after every answer, an empty one too, sits idle while nothing else is written. An unknown consumer is 404 rather than read from "now" each time, which would miss what is written between two reads. A consumer further behind than the server keeps is 410 with the first since it does keep, as a cursor is; a PATCH there goes on from it. The server keeps writes by their size, written to disk or not yet, so that since can be ahead of the last write on disk: a PATCH takes it, and the read from there waits for the disk. GET /_changes/consumers lists each consumer's since and how many writes it is behind.