october

The client API

What a schema generates, and how a browser app uses it. The examples use the shared lists schema from schema.md, pushed to a tenant called shop. Every response shown is real, trimmed where long.

URLs

Every tenant is served under its own prefix:

https://<server>/t/<slug>/

All paths below are relative to that prefix. With the tenant shop on https://october.sombra.so, the GraphQL endpoint is https://october.sombra.so/t/shop/graphql.

There is no other place a tenant's API is served. The root has none — not for the app that build installs (its "site" tenant: an ordinary tenant with its own slug, /t/demo/ on the public demo, and a server may install none at all): the root serves october's own pages, docs, CLI and admin API, plus GET /health for an uptime check, which is october's own ({"status":"ok"}, naming no tenant, db or metric). The admin API (/admin/..., for the CLI) takes an admin token, not a tenant's user token; GET /admin/auth/methods says how to get one on that server (the admin API).

The docs are at /docs/, rendered, and each page is also its raw Markdown at /docs/<file>: /docs/README.md, /docs/schema.md, /docs/api.md, /docs/client.md, /docs/cli.md. Their links to each other are relative (schema.md#permissions), so they work there too. GET /llms.txt lists them, one line each, for a coding agent to start from.

Method Path What
POST /graphql GraphQL queries and mutations (JSON body)
GET /schema.graphql the GraphQL SDL, with constraints and rules as directives
GET /schema.json a JSON Schema per entity, for its create input
POST /live live queries (JSON body as /graphql), answered as a Server-Sent Events stream
POST /runtime/auth/send_magic_code send a sign-in code to an email
POST /runtime/auth/verify_magic_code exchange email + code for a pair of tokens
POST /runtime/auth/refresh trade a refresh token for a new pair
POST /runtime/signout end a sign-in: every token of it
GET /runtime/config {"demo": true|false}
GET /health {"status":"ok","basis-t":1011}: this tenant's, with the basis-t it reads

An unknown tenant gives 404 {"type":"unknown-tenant","message":"No tenant nope"}; an unknown path under a tenant gives 404 {"type":"not-found"}.

A tenant nobody has used for a while is closed on the server and opens again on its next request, which takes about a tenth of a second longer; nothing else changes. A server at its limit of open tenants, all of them in use, answers a tenant it would have to open with 503 {"type":"tenant-capacity",...} and Retry-After: retry after that many seconds.

The non-GraphQL endpoints answer JSON. Their errors are {"type": "...", "message": "..."} with an HTTP status, or, for invalid input, 400 {"type":"validation-failed","errors":{...},"etype":"..."}. A body that isn't valid JSON gives 400 {"type":"invalid-json",...}.

Calling from the browser (CORS)

A page may call a tenant's API from its own origin and from the origins allowed for that tenant. Allow an origin with the CLI (see cli.md):

october origins shop --add http://localhost:5173

An origin is scheme://host[:port], http or https, with no path. It must match what the browser sends exactly: http://localhost:5173 and http://127.0.0.1:5173 are different origins. * isn't accepted. A change applies at once, with no restart.

Besides the tenant's own list, every tenant allows the server's own address and any the server allows everywhere (OCTOBER_ALLOWED_ORIGINS, where you run the server yourself).

For an allowed origin, every path in the table above answers CORS:

  • A preflight (OPTIONS with Access-Control-Request-Method) gets 204 with Access-Control-Allow-Origin: <your origin>, Access-Control-Allow-Methods: GET, POST, Access-Control-Allow-Headers: Authorization, Content-Type, Idempotency-Key and Access-Control-Max-Age: 600.
  • Every answer, errors included, carries Access-Control-Allow-Origin: <your origin> (never *), Vary: Origin and Access-Control-Expose-Headers: Retry-After.

There is no Access-Control-Allow-Credentials. october doesn't use cookies: the token goes in the Authorization header. So call fetch without credentials: 'include' (the default is fine). A request that asks for credentials is blocked by the browser.

$ curl -i -X OPTIONS https://october.sombra.so/t/shop/graphql \
    -H 'Origin: http://localhost:5173' -H 'Access-Control-Request-Method: POST' \
    -H 'Access-Control-Request-Headers: authorization, content-type'
HTTP/1.1 204 No Content
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Headers: Authorization, Content-Type, Idempotency-Key
Access-Control-Max-Age: 600
Vary: Origin
Access-Control-Allow-Origin: http://localhost:5173
Access-Control-Expose-Headers: Retry-After

From an origin that isn't allowed:

  • A preflight gets 403 with no CORS headers, so the browser never sends the request. A GET runs, but has no Access-Control-Allow-Origin, so the browser hides the answer from the page (TypeError: Failed to fetch).

  • A POST is refused whatever the browser does:

    HTTP/1.1 403 Forbidden
    {"type":"cross-origin","message":"Cross-origin requests are not allowed"}
    

    october checks the Origin header (or, without one, Referer) against the same list CORS uses.

Non-browser clients (curl, scripts, servers) send no Origin, so they can call the API from anywhere.

A reverse proxy that serves your files and october on one origin also works, and needs no CORS: add the public origin with october origins (or, on a server you run, to OCTOBER_ALLOWED_ORIGINS), and the proxy must not buffer /live (october sends X-Accel-Buffering: no for nginx). october doesn't host your files: the pages it serves itself are fixed.

This was checked in headless Chrome: a page on http://localhost:8912, allowed on the tenant, sent a code, read /schema.json, ran a query and a mutation with a token, and got two pushes on a live query. The same page on http://127.0.0.1:8912, not allowed, got TypeError: Failed to fetch.

Sign in

The JS client does this for you. This section is the HTTP underneath.

Sign-in is by a one-time code sent to an email address. There are no passwords.

1. Send a code

POST /runtime/auth/send_magic_code
{"email": "ada@example.com"}
{"sent": true}

The email is trimmed and lower-cased. Errors:

Status Body
400 {"type":"validation-failed","errors":{"email":["should be a valid email"]},"etype":"$users"}
400 {"type":"validation-failed","errors":{"email":["missing required key"]},"etype":"$users"}
429 {"type":"rate-limited","limit":"resend","retryAfterMs":21000,"message":"A code was sent recently; wait before requesting another"} (one code per email per 30 seconds)
429 {"type":"rate-limited","limit":"email","retryAfterMs":...,"message":"Too many sign-in codes were sent to this address. Try again in 42 minutes."} (5 codes an hour per address, emailed or not, outside demo mode: see Send limits)
429 {"type":"rate-limited","limit":"tenant-day","cap":100,"retryAfterMs":...,"message":"This app has sent all the sign-in emails it may send today. Try again in 7 hours."} (a daily cap)
502 {"type":"email-failed","message":"The sign-in email couldn't be sent: the mail provider refused it. ..."}
503 {"type":"email-failed","message":"The sign-in email couldn't be sent: the mail provider didn't answer in time. ..."}

Every 429 has a Retry-After header, in seconds. Show the message to the user.

A code is valid for 10 minutes, and only once.

Demo mode. Demo mode is a setting of each tenant, off unless its admin turns it on (october demo SLUG on, see cli.md). When your tenant is in demo mode, the response also contains the code, and your app can sign the user in at once:

{"sent": true, "demo_code": "978255"}

GET /runtime/config tells you which mode the tenant is in: {"demo": true}. Show that in your UI.

Warning: in demo mode anyone can sign in as any email. Nothing checks that the caller owns the address. Don't use a demo tenant for real data, and don't write rules that trust an email (an admin list by address): keep roles in your data (see schema.md).

Sign-in email

A new tenant sends real sign-in email from the start, on a server with a mailer, within the daily limits. On the hosted service, sign-in email is on for new apps. It is not a setting a tenant admin changes: the server may turn a tenant's email off (for example after too many bounces or spam complaints), and a tenant created before email was on by default may have it off. On a server with no mailer, email is never on. Where it is off, send_magic_code still makes a code but sends it nowhere, and the answer says so ("delivered": false, with a message), so your UI can tell the user instead of saying "check your email":

{"sent": true, "delivered": false, "message": "This tenant doesn't email sign-in codes, so this one wasn't emailed. ..."}

Where the code goes then depends on the server, not on the tenant:

  • A server with a real mailer (SES configured, as on a hosted server) never writes a code to its log: anyone who reads the log could sign in with it. It logs only that a code was made for that address, on that tenant, and not sent. Users of a tenant with email off can't sign in until its email is on again; use demo mode while you build.
  • A server with no mailer (development: clojure -M:run, october dev; or a self-hosted server without email) writes the code to its log (Magic code for ...), because that is the only way anyone can sign in there. Treat that log as a secret. october dev also shows the codes at /dev/mail.

When email is on, the answer is {"sent": true} and the user gets a short plain email from the server's sender address:

  • subject "Your sign-in code for SLUG" (the tenant's slug);
  • the six-digit code, large;
  • when it expires (10 minutes);
  • a line saying to ignore the email if they didn't ask to sign in.

There are no images and no links in it. Demo mode takes precedence: a tenant in demo mode never sends email, even with email on, because the code is in the answer anyway.

Send limits. Anyone can ask for a code for any address, so codes are limited, besides the one code per address per 30 seconds. The limit per address counts every code outside demo mode, emailed or not; the others count emailed codes only:

Limit Default limit in the 429
one address, on one tenant 5 an hour email
one client address (IP), on all tenants 10 an hour client
one tenant 200 a day tenant
the whole server 1000 a day server

The windows slide: room comes back as old sends age out, and Retry-After says when. A refused request sends nothing and counts nothing. Every address counts the same whether or not it belongs to a user, so the limits tell nobody who has signed up. The server can change the numbers, for the whole server or for one tenant (a signup page used from one office network may need more than 10 an hour from one client address); on the hosted service, the service sets them. A tenant's own numbers never go above the server-wide limit.

Daily caps

On top of those windows, real email has caps per day (UTC), which hold across all of the server's instances:

Cap Default limit in the 429
one tenant 100 a day tenant-day
a tenant in its first 7 days 20 a day new-tenant-day
every tenant one tenant admin created, together 200 a day account-day
the whole server 1000 a day server-day

Over a cap, send_magic_code answers 429 with that limit, the cap, and Retry-After until the next UTC midnight; no code is made or sent, and nothing is counted. Show the message to the user: it says the app can't send more sign-in emails today, never anything about the address. Sign-in for users who already have a token is not affected. The caps count every real email of the tenant: sign-in codes, and the notifications the server sends for it. The caps are the server's, not your token's (on the hosted service, paid plans will raise them later); a tenant given a cap of its own is out of its creator's account-day cap. The first time a day a cap refuses your tenant's email, its events say so (email-cap-reached).

Suppressed addresses

An address whose email bounced for good, or whose owner reported an email from this server as spam, is never mailed again, by any tenant. send_magic_code answers as if it sent the code ({"sent": true}), so no app learns what happened to an address on another app, and sends nothing. Your tenant's admins see each one in the tenant's events (email-suppressed, with the address your app asked for), along with your own emails' bounces and spam reports (email-bounced, email-complaint). If a user says no code arrives, ask for another address.

A tenant whose emails bounce or are reported as spam too often (more than 5 % of its emails bounce, or 0.1 % are reported as spam, over a week) has its real email turned off by the server, and its events say email-auto-disabled. Its send_magic_code then answers delivered: false, as for a tenant whose email was never on, until the server turns it on again. When the server stops all of its email at once, the answer is the same delivered: false.

If the email can't be sent, the answer is 502 (the mail provider refused it) or 503 (it didn't answer in time). The code is withdrawn, so the user can ask again at once, without the 30-second wait.

2. Verify the code

POST /runtime/auth/verify_magic_code
{"email": "ada@example.com", "code": "978255"}
{"user": {"id": "67c7970d-d9b8-4c0f-a7f7-6543a754336e", "email": "ada@example.com"},
 "access_token": "5b0e1c9f7a3d4e8b9c2f6a1d0e7b3c4a8f9d2e1b6c5a4f3e2d1c0b9a8f7e6d5c",
 "refresh_token": "c061522ba3eb61806373acfd5481a9ccc8fbcc5f9c75f66c547ca9239d076337",
 "token_type": "Bearer",
 "expires_in": 900,
 "refresh_expires_in": 2592000}

The first sign-in of an email creates its user. A wrong, expired or used code gives 400 {"type":"invalid-code","message":"Invalid or expired code"}. After 5 wrong codes, the email's outstanding codes are revoked and the user must request a new one.

Guesses per address are capped. One address may try at most 10 codes a day (UTC) on one tenant, across all the codes it was sent; a successful sign-in doesn't count. A try counts once for each code the address holds at that moment, since it is checked against each. Past the cap, every code for that address is refused with the same invalid-code answer as a wrong one, the right code too, until 00:00 UTC. Nothing in the answer says the cap was reached: that would tell someone guessing when to stop. A user who sees "Invalid or expired code" for a code they just received can sign in again after midnight UTC. Tokens they already hold keep working. With 6-digit codes this keeps the chance of guessing into one account below 1 in 100,000 a day.

3. Use the access token

A sign-in is a pair of tokens:

  • the access token goes as a bearer token on POST /graphql and POST /live. It lasts expires_in seconds (15 minutes).
  • the refresh token is used only to get a new pair (step 4). The sign-in it belongs to lasts refresh_expires_in seconds (30 days) at most, however often it is refreshed; then the user signs in again.
Authorization: Bearer 5b0e1c9f7a3d...
  • No Authorization header: the request runs as anonymous. me is null, reads show what anonymous callers may see, and writes that need a user fail with UNAUTHENTICATED.

  • A bearer token that doesn't name a live sign-in is refused, never read as anonymous: HTTP 401, in both shapes, so a REST caller and a GraphQL client each find what they look for:

    {"type": "token-expired", "reason": "token-expired",
     "message": "The access token has expired: refresh it",
     "errors": [{"message": "The access token has expired: refresh it",
                 "extensions": {"code": "UNAUTHENTICATED", "reason": "token-expired"}}]}
    

    token-expired: the access token is past its 15 minutes. Refresh (step 4) and send the request again. invalid-token: the sign-in has ended (signed out, revoked, past its 30 days, or the token is unknown, or it is a refresh token): sign in again. The response also carries WWW-Authenticate: Bearer error="invalid_token".

  • Users belong to one tenant. The same email in another tenant is a different user with a different id.

  • Long-lived tokens are not for apps' users. A server that talks to october on its own behalf will use a service token.

4. Refresh

POST /runtime/auth/refresh
{"refresh_token": "c061522ba3eb..."}

The answer is a new pair, in the same shape as step 2's. The refresh token you sent is now spent: keep the new one. Refresh when the access token is about to expire, or on a token-expired 401.

  • A refresh token works once. Sent again within 30 seconds of its use, while the pair it got hasn't been used itself, it answers with that same pair: the same client asking twice (an answer lost on the network, two tabs at once). Any other second use is taken as a stolen token: the answer is 401 {"type":"invalid-token","reason":"reused"}, and the whole sign-in ends, every token of it, its live streams included.
  • Other refusals are 401 invalid-token with reason revoked (signed out), expired (past its 30 days) or unknown. Sign in again.
  • An access token from before a refresh keeps working until it expires.
  • A token issued before october had refresh (a single refresh_token in user) no longer works: it gets 401 invalid-token, and the user signs in again.

5. Sign out

POST /runtime/signout
Authorization: Bearer 5b0e1c9f7a3d...

or with the refresh token in the body: {"refresh_token": "c061522ba3eb..."}. The answer is always {"ok": true}. Every token of that sign-in stops working at once (an expired access token is enough to sign out), and live streams opened with it are closed.

In the browser

The client does all of this, refreshes included. By hand:

const API = 'https://october.sombra.so/t/shop';   // an allowed origin, see above; '/t/shop' behind a same-origin proxy

async function post(path, body, token) {
  const headers = {'content-type': 'application/json'};
  if (token) headers.authorization = 'Bearer ' + token;
  const res = await fetch(API + path, {method: 'POST', headers, body: JSON.stringify(body)});
  return res.json();
}

const sent = await post('/runtime/auth/send_magic_code', {email});
// In demo mode use sent.demo_code; otherwise ask the user for the code.
const pair = await post('/runtime/auth/verify_magic_code', {email, code});
localStorage.setItem('session', JSON.stringify(pair));

// the access token, refreshed when it says it expired
async function call(path, body) {
  let pair = JSON.parse(localStorage.getItem('session') || 'null');
  let res = await post(path, body, pair?.access_token);
  if (res.type === 'token-expired') {
    pair = await post('/runtime/auth/refresh', {refresh_token: pair.refresh_token});
    if (!pair.access_token) { localStorage.removeItem('session'); throw new Error('signed out'); }
    localStorage.setItem('session', JSON.stringify(pair));
    res = await post(path, body, pair.access_token);
  }
  return res;
}

Two tabs refreshing at once is safe (the second gets the same pair), but a real app refreshes once for all its requests at a time.

GraphQL basics

POST /graphql
Content-Type: application/json
Authorization: Bearer <access token>      (optional)

{"query": "...", "variables": {...}, "operationName": "..."}
async function gql(query, variables) {
  const res = await call('/graphql', {query, variables});
  if (res.errors) console.warn(res.errors, res.extensions.cost);
  return res;
}
  • The answer is HTTP 200 for every GraphQL result, errors included. Read errors.
  • Every answer has extensions.cost (see Query cost).
  • A body without a query string gives HTTP 400 {"errors":[{"message":"Body must be JSON with a query string"}],...}.
  • Introspection (__schema, __type) works, so GraphQL tools can read the schema. GET /schema.graphql gives the same schema as SDL text.

Scalars:

GraphQL JSON
UUID string
Instant ISO-8601 string in UTC. october always writes milliseconds ("2026-10-20T09:00:00.000Z"), so string order is time order; as input, any ISO-8601 instant ("2026-10-20T09:00:00Z")
Long number, or a decimal string when the value is beyond ±(2^53 − 1)
JSON any JSON value
Float, Boolean, String as usual

Names

From etype and label to GraphQL:

Schema GraphQL
etype :lists type List (singular, capitalised; :graphql/type overrides)
etype :task-lists type TaskList: kebab-case to PascalCase, the last word singular
etype :$users type User
label :owner-note field ownerNote
list root lists(...): the etype in camelCase (:task-lists gives taskLists)
by-id root list(id: UUID!): the type name, first letter lower-case (:task-lists gives taskList(id:)); <root>ById if that equals the list root (newsById)
connection ListConnection { items: [List!]!, pageInfo: PageInfo! }
enum ListColor { GREY RED GREEN BLUE }
order ListOrder { field: ListOrderField!, direction: OrderDirection = ASC }
inputs ListCreateInput, ListUpdateInput
mutations createList, updateList, deleteList, deleteLists; for :task-lists, createTaskList ... deleteTaskLists

A multi-word etype gets every name from its type: :stage-changes gives StageChange, StageChangeConnection, StageChangeCreateInput, StageChangeOrder, an enum attr :to gives StageChangeTo, the roots stageChanges(first:) and stageChange(id:), and the mutations createStageChange, deleteStageChanges(ids:). Two etypes that give the same type name (:stage-changes and :stageChanges) are refused when you plan the schema; set :graphql/type on one of them.

Every type has:

  • id: UUID!
  • createdAt: Instant!: when the entity was created.
  • createdBy: User: who created it; null for entities the system wrote, when a :view rule hides the author (see schema.md), and when the caller may not see that user.

me: User is the signed-in user, or null.

Users are closed by default: a signed-in caller sees only themself in users and user(id:), and a signed-out caller sees none. Every User-typed field (an author, createdBy, members) is null or left out for users the caller can't see, so a required ref to $users is nullable in the SDL (author: User). The schema can show more users with its own $users :view rule (see schema.md).

Queries: roots, connections, pagination, filters, order

Each entity gets a list root and a by-id root:

lists(first: Int!, after: String, orderBy: ListOrder,
      color: ListColor, ownerId: UUID, title: String): ListConnection!
list(id: UUID!, asOf: Long): List
  • first is required. It is capped at 100: a larger value returns at most 100. A negative value is BAD_USER_INPUT "first must be zero or more".
  • The by-id root returns null when the entity doesn't exist or the caller may not view it. asOf reads it as it was at a past revision: see Reading the past.
  • Lists contain only entities the caller may view.

Nested lists

Reverse refs and many-refs are connections with the same arguments:

{ lists(first: 10, orderBy: {field: TITLE, direction: ASC}) {
    items {
      id title color ownerNote
      owner { displayName }
      items(first: 2) { items { text } pageInfo { hasNextPage endCursor } }
    }
    pageInfo { hasNextPage endCursor }
} }
{"data": {"lists": {"items": [
  {"id": "0b6d1c1e-8a9f-4a51-9d55-6a3f4f0f0001", "title": "Groceries", "color": "GREEN",
   "ownerNote": null, "owner": {"displayName": "Ada Lovelace"},
   "items": {"items": [{"text": "Milk"}, {"text": "Eggs"}],
             "pageInfo": {"hasNextPage": true, "endCursor": "AkB0e4kPXKpTN4rseiv6..."}}},
  {"id": "0b6d1c1e-8a9f-4a51-9d55-6a3f4f0f0002", "title": "Trip", "color": null,
   "ownerNote": null, "owner": {"displayName": null},
   "items": {"items": [{"text": "Passports"}, {"text": "Sunscreen"}],
             "pageInfo": {"hasNextPage": false, "endCursor": "AkDQjSFPvBTYvqO5H71a..."}}}],
  "pageInfo": {"hasNextPage": false, "endCursor": "AkDtMGw9mjESI3pBhZ-O..."}}},
 "extensions": {"cost": {"requested": 211, "actual": 37, "budget": 20000, "remaining": 19963}}}

Pagination

Pass the last endCursor as after to get the next page. Stop when hasNextPage is false.

query Page($list: UUID!, $after: String) {
  items(first: 2, after: $after, listId: $list) {
    items { text }
    pageInfo { hasNextPage endCursor }
  }
}

Three calls on a list with five items give Milk, Eggs, then Bread, Apples, then Coffee with hasNextPage: false.

  • Cursors are opaque, URL-safe strings of about 70 characters. They are encrypted: don't parse them, and never construct one. Pass back only what endCursor gave you, to the same tenant, root (or field), orderBy and direction. Anything else, including a cursor that has been edited, gives BAD_USER_INPUT "Invalid cursor".
  • A cursor stays valid when the item it came from is deleted.
  • A page can hold fewer than first items while hasNextPage is true. A list reads entities in its order and keeps the ones you may see that match its filters. It checks at most 1,000 entities per page. When that many were checked and the page isn't full, you get what was found, hasNextPage: true, and an endCursor at the last entity checked, so the next page continues after it. This happens when a rule or filter keeps few of the entities in the list's order (say you may see 3 of 50,000). It can even be an empty page with hasNextPage: true. Keep following endCursor until hasNextPage is false; don't treat a short page as the end.
  • A cursor can become invalid when the server's cursor key is rotated. Then start again from the first page (no after).

Filters

List roots and connection fields take equality filters:

Filter For
<field>: <value> every indexed data attribute: :indexed? or :unique?, not :json, not long text (see Indexes)
<field>: <ENUM> every enum attribute
<ref>Id: UUID every one-target ref (listId, ownerId)

Attributes with a :view rule are never filters. Filters combine with AND. A <ref>Id naming an entity the caller can't view matches nothing.

{ items(first: 10, rank: 2, orderBy: {field: CREATED_AT, direction: DESC}) { items { text rank } } }
{"data": {"items": {"items": [{"text": "Coffee", "rank": 2}, {"text": "Apples", "rank": 2},
                              {"text": "Bread", "rank": 2}, {"text": "Eggs", "rank": 2}]}}}

Order

orderBy: {field, direction}. The fields are CREATED_AT plus every required indexed data attribute (TITLE for lists). The default is CREATED_AT ASC, oldest first, unless the schema sets another with :order (see Other entity keys); the orderBy argument's description then says which. Ties are broken by id. An optional attribute can't be an order field.

Counts and group-by (aggregates)

Each entity has an aggregate root next to its list, <list>Aggregate, taking the list's filters:

{
  tasksAggregate {
    count
    capped                                  # true: the counts stop at the cap
    scanned                                 # entities checked
    groupBy(field: STATUS) { key count }    # per value of a field
    groupByDay { day count }                # per day of creation, UTC
  }
}

Ann sees her three tasks and one of Bob's two (an urgent one, which everyone may see):

{"data": {"tasksAggregate": {"count": 4, "capped": false, "scanned": 5,
  "groupBy": [{"key": "TODO", "count": 1}, {"key": "DOING", "count": 1}, {"key": "DONE", "count": 2}],
  "groupByDay": [{"day": "2026-10-19", "count": 4}]}}}

Filters are the list's: tasksAggregate(status: DONE) { count }.

  • The same entities as the list: what you may view (the :view rule, checked the same way, in chunks), matching the filters. A count never includes what the list wouldn't show you.
  • groupBy(field:) takes an enum field, a boolean field or an indexed field (<Type>GroupField), never one with its own :view rule: a group's key and count would show the hidden values. Keys are as the field shows them (enum values as the enum spells them), null for unset; enum values come in declaration order, null last; only values that occur are listed.
  • groupByDay: the count per day the entities were created, UTC (YYYY-MM-DD), oldest first.
  • Bounded: one aggregate checks at most 5000 entities (the server's :max-aggregate-scan), oldest first. Past that, capped is true and the counts are of those 5000 only: narrow it with filters.
  • Cost: estimated at the cap (so the bucket must hold it), then counted as what it scanned: tasksAggregate { count } over 5 entities is requested 5002 and actual 7 (two fields and five entities). Several aggregate fields in one query each count their cap, so ask for one aggregate and select every count you need inside it.

History

Every entity type has the revisions of each entity, newest first, and how many there are:

history(first: Int!, after: String, field: [ListHistoryField!]): RevisionConnection!
revisionCount(field: [ListHistoryField!]): Int!

type Revision { basisT: Long!  at: Instant!  by: User  changes: [FieldChange!]! }
type FieldChange { field: String!  before: JSON  after: JSON
                   added: [UUID!]  removed: [UUID!]  hidden: Boolean! }
  • A revision is one transaction that changed the entity. The one that created it is the oldest, so "edited N times" is revisionCount - 1.
  • basisT identifies the revision (the transaction's position in the database); at is when it committed; by the user who made it, null for system writes. Pass basisT as asOf to read the entity as it was then (below).
  • changes lists the fields it changed, by their name on the type. Values are as the field shows them: enum values as the enum spells them ("GREEN"), refs as the target's id. Many-refs list the ids added and removed (before and after are null).
  • field: keeps only the revisions that changed one of those fields (the enum lists the type's fields: TITLE, OWNER, MEMBERS, ...). The revisions it keeps are whole: they list every field they changed. revisionCount takes the same argument.
  • Pagination and its cursors work as for lists. A cursor belongs to one entity's history.
  • revisionCount counts among the entity's newest 1,000 revisions (with field:, the newest 1,000 that changed those fields). Past that it stops counting, as a page stops checking.

Ada owns a list; she renamed it, added a private note, shared it with Bob, then changed its color:

query ($id: UUID!) {
  list(id: $id) {
    title revisionCount
    history(first: 10) {
      items { basisT at by { displayName } changes { field before after added removed hidden } }
      pageInfo { hasNextPage endCursor }
    }
  }
}

As Ada:

{"data": {"list": {"title": "Weekly groceries", "revisionCount": 4, "history": {"items": [
  {"basisT": 1032, "at": "2026-10-19T01:47:21.581Z", "by": {"displayName": "Ada Lovelace"},
   "changes": [{"field": "color", "before": "GREEN", "after": "BLUE", "added": null, "removed": null, "hidden": false}]},
  {"basisT": 1031, "at": "2026-10-19T01:47:21.576Z", "by": {"displayName": "Ada Lovelace"},
   "changes": [{"field": "members", "before": null, "after": null,
                "added": ["920cce27-fc60-4f43-9a51-e55215d4337a"], "removed": [], "hidden": false}]},
  {"basisT": 1030, "at": "2026-10-19T01:47:21.568Z", "by": {"displayName": "Ada Lovelace"},
   "changes": [{"field": "ownerNote", "before": null, "after": "budget 60", "added": null, "removed": null, "hidden": false},
               {"field": "title", "before": "Groceries", "after": "Weekly groceries", "added": null, "removed": null, "hidden": false}]},
  {"basisT": 1028, "at": "2026-10-19T01:47:21.563Z", "by": {"displayName": "Ada Lovelace"},
   "changes": [{"field": "color", "before": null, "after": "GREEN", "added": null, "removed": null, "hidden": false},
               {"field": "owner", "before": null, "after": "556200b0-84e5-4d1e-987b-948fa7ab21cc", "added": null, "removed": null, "hidden": false},
               {"field": "title", "before": null, "after": "Groceries", "added": null, "removed": null, "hidden": false}]}],
  "pageInfo": {"hasNextPage": false, "endCursor": null}}}},
 "extensions": {"cost": {"requested": 394, "budget": 20000, "remaining": 19900, "actual": 80}}}

As Bob, the same query gives "revisionCount": 2 and only the two newest revisions: he could see the list only from the moment he was added to it, and ownerNote is the owner's alone.

A deal's stage moves

Who moved a deal between stages, and when, needs no table of its own: a stage enum and history(field: STAGE) answer it. With this schema (one team per tenant, so every signed-in user is a teammate):

{:entities
 {:$users {:attrs       {:display-name {:type :string :optional? true :min 1 :max 40}}
           :permissions {:view [(authenticated? ?user)]}}
  :deals  {:attrs       {:title {:type :string :min 1 :max 160}
                         :stage {:type :enum :values [:lead :qualified :proposal :won :lost]}
                         :value {:type :double :optional? true :min 0}
                         :owner {:type :ref :to :$users :required? true :default :auth/user
                                 :immutable? false}}
           :permissions {:view   [(authenticated? ?user)]
                         :create [(authenticated? ?user)]
                         :update [(authenticated? ?user)]}}}}

Ada created the deal as a lead and set its value; Bob qualified it, Ada moved it to proposal (raising the value), Bob marked it won:

query StageMoves($id: UUID!) {
  deal(id: $id) {
    title stage
    edits: revisionCount
    moves: revisionCount(field: STAGE)
    history(first: 10, field: STAGE) {
      items { basisT at by { displayName } changes { field before after } }
    }
  }
}
{"data": {"deal": {"title": "Acme renewal", "stage": "WON", "edits": 5, "moves": 4, "history": {"items": [
  {"basisT": 1033, "at": "2026-10-19T01:47:46.386Z", "by": {"displayName": "Bob"},
   "changes": [{"field": "stage", "before": "PROPOSAL", "after": "WON"}]},
  {"basisT": 1032, "at": "2026-10-19T01:47:46.381Z", "by": {"displayName": "Ada"},
   "changes": [{"field": "stage", "before": "QUALIFIED", "after": "PROPOSAL"},
               {"field": "value", "before": 12000.0, "after": 15000.0}]},
  {"basisT": 1031, "at": "2026-10-19T01:47:46.378Z", "by": {"displayName": "Bob"},
   "changes": [{"field": "stage", "before": "LEAD", "after": "QUALIFIED"}]},
  {"basisT": 1028, "at": "2026-10-19T01:47:46.370Z", "by": {"displayName": "Ada"},
   "changes": [{"field": "owner", "before": null, "after": "bf193dbd-356c-4004-a9ba-7674cf5ee1f0"},
               {"field": "stage", "before": null, "after": "LEAD"},
               {"field": "title", "before": null, "after": "Acme renewal"}]}]}}},
 "extensions": {"cost": {"requested": 186, "budget": 20000, "remaining": 19924, "actual": 60}}}

moves counts the creating revision, which set the first stage. The revision where Ada first set the value is left out, since it didn't touch the stage; the one at 1032 is kept whole.

Who sees what in history

A past value is shown only when you may view it now and at the time:

  • You reach history through the entity, so it must exist and you must be allowed to view it now. Deleted entities have no history through the API.
  • A revision is shown only if you could view the entity at that revision. The value before a change is shown only if you could view it just before, too; otherwise before is null and hidden is true. (Bob's oldest revision above is the one that added him; it showed nothing from before, since members was empty.)
  • A field with its own :view rule: its changes are shown only when the rule holds for you now and held at the revision. Otherwise the change is left out.
  • A ref target you can't view now, or one deleted since, is withheld: null (or missing from added/removed) with hidden: true, so you still see that the field changed.
  • by is null unless you may view that user, and every rule that hides the entity's author (a :default :auth/user ref with a :view rule) holds now and held then, as for createdBy.
  • A revision with nothing left to show is skipped, except the one that created the entity. revisionCount counts exactly the revisions history shows, so it can differ per caller: 4 for Ada, 2 for Bob.
  • history pages like a list: it checks at most 1,000 revisions per page, so after more than 1,000 skipped revisions in a row a page can be short or empty with hasNextPage: true (follow endCursor). That tells you an entity you can see has had many changes you can't, never what they were or who made them.

Reading the past (asOf)

Every by-id root takes asOf, a basisT (a revision's, or a live push's): the entity as it was right after that transaction.

query ($id: UUID!, $t: Long) {
  deal(id: $id, asOf: $t) { stage value owner { displayName } edits: revisionCount }
}

With "t": 1031:

{"data": {"deal": {"stage": "QUALIFIED", "value": 12000.0, "owner": {"displayName": "Ada"}, "edits": 3}},
 "extensions": {"cost": {"requested": 6, "budget": 20000, "remaining": 19994, "actual": 9}}}
  • Everything nested in it is read at the same point: its fields, refs, lists, createdBy, even its history and revisionCount (the revisions up to then).
  • The same rule as history: the entity, and every entity reached from it, must exist now and you must be allowed to view it now and then; a field with a :view rule shows only if the rule holds now and held then. Otherwise it is null (or left out of a list), as if it didn't exist. Bob reading Ada's list asOf 1030, before she shared it, gets {"list": null}; at 1031 he gets it, with ownerNote: null. A list nested in an asOf read can return a short page with hasNextPage: true; follow endCursor as usual.
  • Before the entity existed, the answer is null. A basisT later than the latest transaction, or not positive, is BAD_USER_INPUT:
{"data": {"deal": null},
 "errors": [{"message": "asOf 99999 is in the future: the latest basisT is 1033",
             "path": ["deal"], "extensions": {"code": "BAD_USER_INPUT"}}]}
  • Only by-id roots take asOf: list roots don't (yet).

Mutations

Each entity gets a mutation per action that its permissions declare. An action without a rule has no mutation.

createList(input: ListCreateInput!): List
updateList(id: UUID!, input: ListUpdateInput!): List
deleteList(id: UUID!): DeletePayload                  # { id }
deleteLists(ids: [UUID!]!): DeleteBatchPayload        # { ids }, all or nothing
addListMembers(id: UUID!, memberIds: [UUID!]!): List  # one pair per many-ref
removeListMembers(id: UUID!, memberIds: [UUID!]!): List

add/remove check the :update rule. updateUser exists only when the schema adds attributes to $users, and a user may update only themself.

A request that committed a write answers extensions.basisT: the database version (Datomic t) of its newest commit. A live query whose basisT is at or past it shows the write (see Live queries).

Several mutations in one request

Each mutation field is its own transaction. The fields of a mutation { ... } run one after another, in order, and each commits on its own. When a later field fails, the earlier ones stay committed: nothing is rolled back. october doesn't offer one transaction for a whole request; to change several entities of one type all or nothing, use a batch (delete<Plural>).

That is why every mutation field's result is nullable (List, not List!): a failing field is null with its error in errors (its path names the field), and the other fields keep their data.

mutation {
  a: createList(input: {title: "Groceries"}) { id title }
  b: createList(input: {title: ""}) { id title }
}
{"data": {"a": {"id": "0b6d1c1e-8a9f-4a51-9d55-6a3f4f0f0003", "title": "Groceries"}, "b": null},
 "errors": [{"message": "Validation failed", "path": ["b"],
             "extensions": {"code": "VALIDATION_FAILED", "errors": {"title": ["should be at least 1 character"]}}}]}

Groceries is created. Check each field you sent, not just whether errors is empty: a field is either its result or null with an error. A field that succeeds is never null.

Retrying safely (Idempotency-Key)

The JS client does this for you. This section is the HTTP underneath.

A request that times out may still have committed: you can't tell from the client. Send an Idempotency-Key header with every request that writes, and send the same key again when you retry it:

POST /t/<slug>/graphql
Authorization: Bearer <token>
Content-Type: application/json
Idempotency-Key: 6f1c9a52-3d2e-4b8e-9a0f-1c2d3e4f5a6b

Each mutation field the first request committed answers the retry with what it committed (the same id for a create), and isn't made again; a field that didn't commit runs now. Two requests with one key at the same time make one write.

  • A key is 1 to 255 printable ASCII characters (no spaces); use a fresh random one (a UUID) for each write you mean, and the same one only for a retry of it. Anything else is 400.
  • A key is yours: it names your writes (signed in), or your address's (anonymous), never another caller's, so reusing someone's key can't return their write.
  • It names each mutation field of the request by its name, alias, place and arguments: retry the request as it was. The same key sent with other arguments names other writes, and makes them.
  • Keys don't expire. Without one, every request is a new write.

Inputs

Schema attribute Input field
data or enum :owner-note ownerNote
one-target ref :list listId: UUID
many-ref :members memberIds: [UUID!] (create only; then use add/remove)
reverse fields not writable

Required attributes without a default are non-null in the create input. The update input has the same fields minus the many-refs and minus every immutable attribute (@immutable in the SDL): a required one-target ref, such as ownerId here, unless the schema says :immutable? false (see schema.md). Those are set on create only. ListUpdateInput is {color, ownerNote, title}.

input ListCreateInput {
  id: UUID
  color: ListColor
  memberIds: [UUID!]
  ownerId: UUID
  ownerNote: String
  title: String!
}

GET /schema.json gives the same input as JSON Schema, for client-side validation:

"lists": {
  "type": "object",
  "properties": {
    "color":     {"type": "string", "enum": ["GREY", "RED", "GREEN", "BLUE"]},
    "id":        {"type": "string", "format": "uuid"},
    "memberIds": {"type": "array", "items": {"type": "string", "format": "uuid"}, "uniqueItems": true},
    "ownerId":   {"type": "string", "format": "uuid"},
    "ownerNote": {"type": "string", "maxLength": 500},
    "title":     {"type": "string", "minLength": 1, "maxLength": 100}
  },
  "required": ["title"],
  "additionalProperties": false
}

Create

id is optional. Send your own UUID (crypto.randomUUID()) to show the new entity in your UI before the server answers.

mutation ($input: ListCreateInput!) {
  createList(input: $input) { id title color owner { id displayName } createdAt }
}
{"input": {"id": "0b6d1c1e-8a9f-4a51-9d55-6a3f4f0f0001", "title": "  Groceries ", "color": "GREEN"}}
{"data": {"createList": {"id": "0b6d1c1e-8a9f-4a51-9d55-6a3f4f0f0001", "title": "Groceries",
  "color": "GREEN", "owner": {"id": "67c7970d-...", "displayName": "Ada Lovelace"},
  "createdAt": "2026-10-18T10:50:44.058Z"}},
 "extensions": {"cost": {"requested": 18, "actual": 18, "budget": 20000, "remaining": 19982}}}

ownerId was left out, so the owner is the caller (:default :auth/user). It is pinned too: an ownerId naming anyone but the caller is VALIDATION_FAILED {"ownerId": ["can only be the signed-in user"]} (see schema.md). The title was trimmed. An id that already exists gives VALIDATION_FAILED {"id": ["already exists"]}.

A write you can't read back answers null. A mutation's result is held to the entity's :view rule like any read. When a create, update, add or remove commits but you can't view the result (the entity has no :view rule, or its rule doesn't let you), the field is null, and extensions.warnings says why, with code NOT_VIEWABLE:

{"data": {"createFeedback": null},
 "extensions": {"warnings": [{"message": "The write succeeded, but you can't view this Feedback, so the result is null: Feedback has no :view rule, and a missing rule means no access",
                              "path": ["createFeedback"], "extensions": {"code": "NOT_VIEWABLE", "type": "Feedback"}}],
                "cost": {...}}}

Refs take ids. Every target must exist and be visible to the caller, otherwise the result is NOT_FOUND with the input field:

{"message": "List not found", "extensions": {"code": "NOT_FOUND", "field": "listId"}}

A JSON field takes any JSON value as is:

mutation ($input: ItemCreateInput!) { createItem(input: $input) { id text rank due meta } }
{"input": {"listId": "0b6d1c1e-...-0001", "text": "Milk", "rank": 1,
           "due": "2026-10-20T09:00:00Z", "meta": {"qty": 2, "tags": ["dairy"]}}}
{"data": {"createItem": {"id": "91503d63-...", "text": "Milk", "rank": 1,
  "due": "2026-10-20T09:00:00.000Z", "meta": {"qty": 2, "tags": ["dairy"]}}}}

Update

The input is partial: only the fields you send change. null clears an optional field.

mutation ($id: UUID!) { updateItem(id: $id, input: {done: true, due: null}) { text done due rank } }
{"data": {"updateItem": {"text": "Milk", "done": true, "due": null, "rank": 1}}}

Changing an immutable field is ruled out by the types: the field isn't in the update input, so a request that sends it fails GraphQL validation ("Field not defined for input object.", with extensions.field-name listId) and nothing is written.

Clearing a required field fails:

{"code": "VALIDATION_FAILED", "errors": {"text": ["is required and can't be cleared"]}}

Add and remove (many-refs)

mutation ($id: UUID!, $ids: [UUID!]!) {
  addListMembers(id: $id, memberIds: $ids) { id members(first: 10) { items { displayName } } }
}
{"data": {"addListMembers": {"id": "0b6d1c1e-...-0002",
  "members": {"items": [{"displayName": "Ada Lovelace"}, {"displayName": null}]}}}}

Delete

mutation ($id: UUID!) { deleteItem(id: $id) { id } }
{"data": {"deleteItem": {"id": "91503d63-6dd4-4aef-a9f2-6f26253ac4ee"}}}

Deleting it again gives NOT_FOUND "Item not found". Components are deleted with their owner, and refs to the deleted entity are removed.

An entity that something still requires can't be deleted. If the delete would leave another entity without a required ref (an item without its list), it fails and says what blocks it:

{"message": "List has 3 Items that require it; delete them first", "path": ["deleteList"],
 "extensions": {"code": "VALIDATION_FAILED",
                "blockedBy": [{"type": "Item", "field": "list", "count": 3, "deletable": true}]}}

blockedBy has one entry per required ref, with the referring type, its field and how many of them you can see. Entities you can't see are never counted or named: when some exist, the message says so ("..., and entities you can't see require it too; delete them first") and hiddenBlockers is true. When a component the delete would remove is the one still required, the entry has target (the component's type) and the message says "its Image has ...". Delete the blockers first (a batch delete takes them in one call), or model the children as a :component? ref on the parent.

deletable says whether you may delete every one of the counted blockers. When some of them have no :delete rule, or their rule refuses you, "delete them first" would be no help, so the message says so instead:

{"message": "Deal has 3 StageChanges that require it, and they can't be deleted, so neither can this Deal",
 "extensions": {"code": "VALIDATION_FAILED",
                "blockedBy": [{"type": "StageChange", "field": "deal", "count": 3, "deletable": false}]}}

("..., and 1 of them can't be deleted, ..." when only some can't). Only blockers you can see are judged: a hidden one never changes deletable or the wording.

Batch delete

Every entity with delete<T> also gets a batch delete, named after the plural (deleteItems; delete<T>Batch when the plural and the type name are the same):

mutation ($ids: [UUID!]!) { deleteItems(ids: $ids) { ids } }
{"data": {"deleteItems": {"ids": ["91503d63-...", "5c0e2a7d-..."]}}}
  • All or nothing. The batch runs in one transaction. Each id goes through the same checks as delete<T>: it must exist and be visible, pass the :delete rule (as must every component it removes), and not be required by anything left behind. If any id fails, nothing is deleted.

  • Every failure is reported, not only the first, in extensions.failed, in the order of ids. Each entry is the error delete<T> would give for that id, with the id:

    {"message": "3 of 90 couldn't be deleted, so none were", "path": ["deleteItems"],
     "extensions": {"code": "BATCH_FAILED",
                    "failed": [{"id": "5c0e2a7d-...", "code": "NOT_FOUND", "message": "Item not found"},
                               {"id": "0d1f9b3c-...", "code": "FORBIDDEN", "message": "Not allowed"},
                               {"id": "7a2e6f10-...", "code": "VALIDATION_FAILED",
                                "message": "Item has 1 Tag that requires it; delete it first",
                                "blockedBy": [{"type": "Tag", "field": "item", "count": 1, "deletable": true}]}]}}
    

    A missing id and one you can't see are both NOT_FOUND. Remove or fix the failing ids and send the batch again.

  • Duplicate ids are fine; each is deleted once, and ids in the answer lists each once.

  • At most 100 ids per batch. More gives BAD_USER_INPUT with extensions.limit "maxBatchSize" and max.

  • Cost: 10 per distinct id for the writes, on top of the selection. deleteItems(ids: [a, b, c]) { ids } counts 1 + 30 + 1 = 32.

  • CONFLICT and UNAUTHENTICATED are for the whole batch, as for a single delete.

What may I do? (can and viewer)

Every type has a can field, and the root has viewer, answered from the same rules the mutations check, on the data as it is now, so a client can show or hide a button, or tell "you may not" from "there is nothing":

{
  viewer {
    user { id }                 # null signed out (the same as me)
    can { createNote }          # one field per create mutation
  }
  notes(first: 20) { items { title can { update delete } } }
}
{"data": {"viewer": {"user": {"id": "d41b..."}, "can": {"createNote": null}},
          "notes": {"items": [{"title": "Groceries", "can": {"update": true, "delete": true}}]}}}
  • can { update delete } on an entity: its :update or :delete rule holds for you now (false when the type has no such mutation). A true is the rule as the data stands: an update is checked again after the change, so a write that would step outside the rule is still refused, and a delete can be refused by what still requires the entity.
  • update<Field> (on <T>Can, for each field with its own :update rule or :transitions): the entity's update and the field's own rule.
  • null means "it depends on the write": a rule with before (or :transitions) compares the entity before and after a write, so only the write decides it.
  • viewer.can.create<T>: true when the :create rule holds whatever you write (:create true, or a rule over you alone such as [(authenticated? ?user)] or [(has-role? ?user :operator)]); false when no write could pass it (no rule, signed out, or its part about you fails); null when that part holds and the rest reads the new entity ((author? ?e ?user)), so it depends on what you write.
  • viewer.can.grantRole(role:, scopeId:): whether the role's :grant rule holds for you (on that scope); viewer.roles the roles you hold ([RoleGrant!]!, see Roles). Both exist when the schema declares roles.
  • Signed out, you are held to the same anonymous variants as the mutations (see schema.md).
  • can is checked per page, like the view rules: one query per action for a page of entities. Each field counts in the query's cost like any other field. A live query selecting can re-runs when what those rules read changes.
  • An entity that declares a field named can keeps it, and has no built-in can.

Roles

A role is the app's own word for a permission group: october reserves nothing inside a tenant's schema, so a role may be called operator, admin or anything else the app means by it. See schema.md.

When the schema declares roles (see schema.md), the API has a RoleName enum (each role in UPPER_SNAKE_CASE), grants as RoleGrant, and:

roleGrants(role: RoleName!, scopeId: UUID): [RoleGrant!]!
grantRole(role: RoleName!, userId: UUID, email: String, scopeId: UUID): RoleGrant
revokeRole(id: UUID!): DeletePayload

type RoleGrant {
  id: UUID!
  role: RoleName!
  user: User          # a grant to a user (null when you can't see them)
  email: String       # a grant by email: held by whoever signs in with it
  scope: RoleScope    # { id type }, for a role held on one entity
  grantedBy: User     # null for a tenant admin's grant
  grantedAt: Instant!
}
  • grantRole takes userId or email, and scopeId (the entity's id) for a scoped role. It is checked against the role's :grant rule: FORBIDDEN when it doesn't hold, UNAUTHENTICATED signed out, NOT_FOUND (with extensions.field) for a scope or user you can't see, BAD_USER_INPUT for a missing or extra scope, an unknown or retired role, or both or neither of userId and email. Granting what is granted returns the existing grant.
  • In demo mode a grant by email is FORBIDDEN with extensions.reason: "demo": anyone can sign in as any email there.
  • revokeRole is allowed to whoever may grant the role on that scope, and to the holder of a grant by id. Anyone else gets NOT_FOUND.
  • roleGrants answers every grant of the role (on scopeId) when you may grant it there, else only your own; signed out, none. Your own grants of every role are viewer { roles }.
mutation { grantRole(role: EDITOR, userId: "8f0c...", scopeId: "2a91...") { id scope { id type } } }
{"data": {"grantRole": {"id": "c3e1...", "scope": {"id": "2a91...", "type": "Team"}}}}

A rule with has-role? or has-role-on? reads the grants, so a live query re-runs when a grant changes, and a write racing a revoke is retried and then refused.

Erasing a user

A user can erase themself, and a tenant's admin can erase any of its users (october erase SLUG EMAIL, see cli.md).

mutation { eraseMe(code: "123456") }   # true

When the schema gives users an :erase rule (see schema.md), eraseUser(id: UUID!) erases another user the same way, for whoever passes it (NOT_FOUND for a user you can't see, FORBIDDEN when the rule fails), and User.can { erase } says whether you may.

eraseMe needs a fresh sign-in code: send one to your own email with send_magic_code first, then pass it. A token alone isn't enough, since a token that leaked would then be enough to erase the account for good. Signed out it is UNAUTHENTICATED; a wrong or used code is BAD_USER_INPUT.

Erasing a user, in one transaction:

  • ends their sessions (refresh tokens revoked, live streams closed) and removes their sign-in codes;
  • removes their email and every field the app adds to users, and their role grants;
  • removes the entities that declare :on-erase :excise on a ref to them (see schema.md);
  • keeps everything else they created. The user stays as a tombstone that has only its id, so every ref to it stays valid and the transactions they made still name it, but nobody can see it: their posts' author, createdBy and a revision's by read null.

Then the email, the profile fields, their sign-in codes, their grants by email and the erased entities are excised: Datomic removes them from history too. Excision runs with the database's next indexing job, which the erase asks for: on a real transactor about a second later. Until then the current data no longer has them, but history still does (history shows a user's email only to that user, who can't sign in any more). Signing up again with the same email makes a new user.

Errors

GraphQL errors carry extensions.code:

Code Meaning Retry?
VALIDATION_FAILED Input breaks the schema. extensions.errors maps input field names to messages. after fixing the input
FORBIDDEN The caller may see the entity but the rule for this action denies it. no
NOT_FOUND The entity, or a ref target (extensions.field), doesn't exist or isn't visible to the caller. no
UNAUTHENTICATED The action needs a signed-in user. With HTTP 401, the bearer token was refused: extensions.reason is token-expired (refresh, then retry) or invalid-token (sign in again); see Use the access token. after a refresh or sign-in
CONFLICT Concurrent writes kept changing what this write depends on. yes
RATE_LIMITED The caller's rate-limit points are used up. extensions.retryAfterMs says when to retry. after the wait
BAD_USER_INPUT A bad argument (first, a cursor, too many ids in a batch) or a query over the cost limits. after changing the query
BATCH_FAILED Some ids of a batch delete failed, so nothing was deleted. extensions.failed lists each one with its own code and message. after removing or fixing those ids
RULE_ERROR A permission rule of the schema failed to run on the data it met (extensions.reason has Datomic's reason). Plan refuses rules Datomic can't run at all, so this is rare; fix the rule and push again. no
INTERNAL An unexpected server error. No details are given. maybe

Examples:

{"message": "Validation failed", "path": ["createList"],
 "extensions": {"code": "VALIDATION_FAILED",
                "errors": {"ownerNote": ["should be at most 500 characters"],
                           "title": ["should be at least 1 character"]}}}

{"message": "Not allowed", "path": ["createList"], "extensions": {"code": "FORBIDDEN"}}

{"message": "Authentication required", "path": ["createList"], "extensions": {"code": "UNAUTHENTICATED"}}

{"message": "List not found", "path": ["updateList"], "extensions": {"code": "NOT_FOUND"}}

{"message": "List has 3 Items that require it; delete them first", "path": ["deleteList"],
 "extensions": {"code": "VALIDATION_FAILED",
                "blockedBy": [{"type": "Item", "field": "list", "count": 3, "deletable": true}]}}

extensions.type appears when the failure is on another entity than the one you wrote. Messages like "already taken" (a :unique? value) and "already exists" (a create id) are per-field validation errors.

A failed mutation returns "data": null because its result type is non-null.

Errors without a code. GraphQL's own checks run before october's and have no extensions.code, only a message: an unknown field, a missing required argument, a value that isn't in an enum, a malformed UUID.

{"message": "Provided argument value `PURPLE' is not member of enum type.",
 "extensions": {"field-name": "createList", "argument": "createList.input", "value": "PURPLE",
                "allowed-values": ["RED", "BLUE", "GREEN", "GREY"], "enum-type": "ListColor"}}

{"message": "Exception applying arguments to field `items': Not all non-nullable arguments have supplied values.",
 "extensions": {"field-name": "items", "missing-arguments": ["first"]}}

Treat an error with no code as a bug in your query.

Query cost and rate limits

A query's cost is a measure of the work it asks the server to do: the fields it resolves and the entities it reads. It is not a price: nothing is billed. october uses it for two limits that keep any one query, or any one client, from running away with the server: a limit per query (how deep, how big), checked before the query runs, and a rate limit per caller, a bucket of points that refills over time.

Every response, refused or not, carries the cost:

"extensions": {"cost": {"requested": 31, "actual": 10, "budget": 20000, "remaining": 19990}}
  • requested: this request's estimated cost, computed before it runs.
  • actual: what it cost when it ran, with the real list sizes, plus 1 for every entity a list checked and skipped (see below); 0 when nothing ran (a refusal). It can be more than requested.
  • budget: the size of your rate-limit bucket, in points.
  • remaining: what is left after this request, refund included.

How cost is counted. Each field counts 1 for every time it can be resolved: a field inside a connection with first: 10 counts 10 times, and nested connections multiply. { lists(first: 10) { items { title ownerNote } } } is estimated at 1 + 10 × 3 = 31. Each mutation adds 10 for the write: createItem(input: ...) { id text } counts 1 + 10 + 2 = 13. A batch delete adds 10 per distinct id. __typename counts nothing; each __schema or __type counts 10.

The actual work is what counts. The estimate is taken from your bucket before the query runs (so the bucket must hold it), and after it runs the difference goes back: the same count with each connection's real number of items in place of its first, and nothing for a field under a null or skipped with @skip/@include. If the list above has 3 items, the query counts 1 + 3 × 3 = 10, and 21 points go back. A mutation counts its selection's actual work plus 10 per write, even when the write fails. So ask for the page size you need, but don't shrink first below it to keep points: an empty or short page counts little.

Entities a list checks and skips count too. A list reads entities in its order and checks each against its filters and the rules (see Pagination); every one it skips adds 1 to actual. The estimate assumes nothing is skipped, so a list where you may see 3 of the first 1,000 entities counts about 1,000 more than its estimate. The excess is taken from your bucket after the query ran, and can leave it below zero (down to minus its size): your next request then waits until the bucket has refilled. To keep lists light, filter on what narrows them (a <ref>Id or an indexed field) rather than relying on a rule to drop most entities.

History counts like a list: history(first: 10) multiplies what is nested in it by 10, and each revision's changes by the number of fields the type has (the most one revision can change). The actual work is the revisions and changes returned, plus 1 for each revision checked against a rule and skipped; revisionCount counts 1 plus 1 for each revision it checks against a rule (none when the type's :view is true and no field has a :view rule).

Limits per query (refused before anything runs, with BAD_USER_INPUT):

Limit Default extensions.limit
nesting depth 10 maxDepth
cost 10000 maxCost
{"errors": [{"message": "Query too large: estimated at more than the maximum of 10000 fields (each list's first multiplies what is nested in it)",
             "extensions": {"code": "BAD_USER_INPUT", "limit": "maxCost", "max": 10000}}],
 "extensions": {"cost": {"requested": 10301, "budget": 20000, "remaining": 20000,
                         "limit": "maxCost", "max": 10000}}}

To fit, use smaller first values and fewer nested connections, and paginate.

Rate limit. Each caller has a bucket of 20000 points that refills at 1000 points per second. A signed-in user's bucket is per user; an anonymous caller's is per IP address. Every query, mutation and live re-run takes its estimated cost from the bucket first, and gives back what it didn't use. When the bucket can't cover the estimate, nothing runs:

{"errors": [{"message": "Rate limited: too many queries for now (the caller's rate-limit points are used up); retry in 4681 ms",
             "extensions": {"code": "RATE_LIMITED", "retryAfterMs": 4681}}]}

Wait retryAfterMs, then retry. Use remaining to slow down before you hit the limit.

Live queries

The JS client does this for you. This section is the HTTP underneath.

A live query is a GraphQL query that the server runs again whenever data it reads changes, and pushes to you when the result is different.

Opening a stream

POST /live with the same JSON body as POST /graphql. The answer is a Server-Sent Events stream (text/event-stream) that stays open:

POST /live
Content-Type: application/json
Authorization: Bearer <access token>

{"query": "query ($board: UUID!) { threads(first: 10, boardId: $board) { items { title } } }",
 "variables": {"board": "4c1d..."}}
  • Authorization is optional. Without it the stream is anonymous, and sees what anonymous callers may view: in the demo forum, its threads, which are public, and their authors, which its $users rule shows to everyone. With the shared-lists schema an anonymous stream sees nothing: lists need a member, and users are closed.
  • With it, the stream runs as the signed-in user. A bearer that names no live session is a 401 (token-expired or invalid-token, as on POST /graphql), never an anonymous stream: refresh, then open it again.
  • A stream belongs to the sign-in whose access token opened it, not to that access token: it stays open across refreshes, and ends when the sign-in does (sign-out, a reused refresh token, its 30 days).
  • The query and its variables travel in the body, so they never appear in a URL or an access log, and have no URL length limit.

EventSource can only send a GET, so it can't open a live query. Read the stream with fetch instead (this is what the client does):

async function subscribe(query, variables, onResult, token) {
  const headers = {'content-type': 'application/json', accept: 'text/event-stream'};
  if (token) headers.authorization = 'Bearer ' + token;
  const res = await fetch(API + '/live', {method: 'POST', headers, body: JSON.stringify({query, variables})});
  if (!res.ok) throw new Error(JSON.stringify(await res.json()));   // see Limits and errors
  const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();
  let buf = '';
  for (;;) {
    const {value, done} = await reader.read();
    if (done) return;                        // the server closed it: open it again
    buf += value;
    let i;
    while ((i = buf.indexOf('\n\n')) >= 0) {  // one event per blank line
      const frame = buf.slice(0, i);
      buf = buf.slice(i + 2);
      const event = /^event: (.*)$/m.exec(frame)?.[1];
      const data = frame.split('\n').filter((l) => l.startsWith('data: ')).map((l) => l.slice(6)).join('\n');
      if (event === 'result') onResult(JSON.parse(data));
    }
  }
}

A real client also reconnects with backoff when the stream ends or goes quiet (no heartbeat for 45 seconds), and refreshes the access token on a 401.

Each stream holds an HTTP connection open. Serve october over HTTP/2 when you run it yourself (a reverse proxy such as nginx or Caddy in front of it): over HTTP/1.1 a browser opens at most 6 connections to one origin, shared by all its tabs, so six live queries leave no connection for queries, writes or other streams, and the page seems to hang. The hosted service serves HTTP/2.

Events

Each push is an event: result whose data is JSON:

event: result
data: {"data":{"list":{"title":"Weekend","items":{"items":[]}}},"errors":null,"basisT":1026,"mine":false,"cost":{"requested":153,"actual":4,"budget":20000,"remaining":19996}}

event: result
data: {"data":{"list":{"title":"Weekend","items":{"items":[{"text":"Firewood","done":null}]}}},"errors":null,"basisT":1028,"mine":false,"cost":{...}}

event: result
data: {"data":{"list":{"title":"Weekend","items":{"items":[{"text":"Firewood","done":null},{"text":"Matches","done":null}]}}},"errors":null,"basisT":1030,"mine":true,"cost":{...}}

This stream was Ada's, watching her list. Bo added "Firewood" (mine: false); then Ada added "Matches" (mine: true).

Field Meaning
data, errors the query's result, as from POST /graphql
basisT the database version the result was computed at; it only grows
mine true when every change in this push was made by the subscriber; false for others' changes, for anonymous subscribers, and for the first result
cost this run's cost (the work it did, see Query cost)

A signed-in subscriber also gets event: basis with data: {"basisT": 1032} when one of its own writes reached the stream without changing its result (it doesn't read what changed, or the change doesn't show). Every mutation answers the basis it committed at as extensions.basisT, so a client can wait until its streams show basisT at or past it before it reads its own write: the client does that in mutate.

  • The first event comes at once with the current result.
  • A new event comes only when data or errors change. A write that doesn't change your result (Ada editing the list's ownerNote, which the query doesn't select) sends nothing.
  • Use mine to skip echoes of the user's own writes, or to highlight other people's changes.
  • A blank line is sent every 15 seconds to keep the connection open.
  • Every re-run counts against the subscriber's bucket, like a new query: the estimate first, then back down to its actual cost (the push's cost says both). Subscribing counts for the first result. A query that is light to run once can still empty the bucket when the data it reads changes often: each change it wakes up for is a run. A re-run the bucket can't cover is postponed, not lost: it runs, with every change folded in, once the bucket has refilled.

Limits and errors

Mutations can't be live (/live is for queries). The checks, in order:

Status Cause
401 the bearer names no live session: token-expired (refresh, then open it again) or invalid-token (sign in again), as on POST /graphql
400 no query, bad variables, a parse error, a mutation, or over the depth or cost limit. Body: {"errors":[...],"extensions":{"cost":...}}; october's own messages have code BAD_REQUEST.
429 {"type":"too-many-subscriptions",...,"extensions":{"cost":...}}: at most 8 open streams per user, counting all their tabs and devices (or per IP address for anonymous streams). Retrying doesn't help until one closes.
429 RATE_LIMITED, with a Retry-After header in seconds

Every one of these bodies but the 401 carries extensions.cost as POST /graphql does: {requested, budget, remaining} (no actual: nothing ran), plus limit and max when a limit refused the query. A refusal takes nothing from the bucket, so remaining is what your bucket holds now: the signed-in user's, or, without a bearer, your address's. requested is 0 when the query never parsed.

{"errors": [{"message": "Cannot query field `nope' on type `Query'.", "locations": [{"line": 1, "column": 3}]}],
 "extensions": {"cost": {"requested": 0, "budget": 20000, "remaining": 19789}}}

A 400 (or any other 4xx but 401 and 429) is about the request itself: sending it again gets the same answer.

The server closes a stream when the user signs out, when the client is too slow to read, and when a new schema is pushed to the tenant (on the next request after the push). Open it again when it ends.

Known issues

  • Codes are emailed only where the tenant's sign-in email is on. It is on for new tenants on a server with a mailer, the hosted service included. Elsewhere, outside demo mode, the code isn't emailed (the answer says "delivered": false; a server with no mailer writes it to its log). Build against a tenant in demo mode there.

  • No history for deleted entities, and no asOf on lists. History and asOf reach an entity only while it exists; list roots read the present only.