The Ontology API is in beta. Paths, fields and error codes may still change before v1 is declared stable. After that, changes within v1 will be additive only: new operations, optional fields, response fields, enum values and error codes. Write your client to ignore fields and values it does not recognize.
- the record types, fields and relations it declares, and the records themselves
- facts, and the figures computed from them
- scenarios, declared actions and imports
- a change feed
- the ontology’s own definition
In the API itself, the ontology goes by its technical name, object model. Paths begin with
/v1/object-model, scopes with object_model:, and the Object-Model-Version header carries the ontology’s version. A few other members keep older names too, such as entity_types for record types and worlds for scenarios: see the API’s names.Base URL
GET /schema. A display name is never accepted in place of an id.
Quickstart
1
Create a scoped API key
Ontology routes need an API key issued with ontology scopes. See Authentication and scopes.
2
Read the schema
3
Create a record
Every write needs an
Idempotency-Key: one key per logical write, sent again unchanged on every retry. See Idempotency.4
Query records
Requests
- Bodies are JSON, with field names in
snake_caseexactly as each endpoint lists them. An unknown field or query parameter is refused with400 invalid_requestrather than ignored. - A body may not contradict its path. A body naming a different type, record, action or job than the URL is refused with
400 path_conflict, andpathpoints at the offending member. So is a query parameter that tries to replace a value the path sets. - Bodies are limited to 8 MiB.
If-Matchon a record update names the record’srevisionyou read. If the record has changed since, nothing in the update is applied, neither field changes nor list or link edits:412 revision_mismatch, withdetails.current_revision.If-Matchtakes the number bare or quoted (If-Match: 1842orIf-Match: "1842"). The body can carry the same value (expected_revision,expected_version); when both are sent, the header wins.If-MatchonPOST /model/configurenames the ontology version you read. If the ontology has moved on since, the change is refused with412 version_mismatch, anddetails.current_versionholds the current version.
Responses
Each endpoint page lists only the statuses that endpoint can return.
Errors
Every error has the same body:
Codes the API itself returns:
Refusals from the ontology itself (
422, 409, 412, and many 404s) carry their own stable codes, such as not_found, revision_mismatch, version_mismatch, unknown_field, not_an_option, wrong_shape, required, operator_mismatch, instance_mismatch, cursor_resync and cursor_filter_mismatch. Each endpoint page lists them, and Field types explains the ones a record’s values can get.
Headers
Pagination
List and query endpoints takelimit and cursor, and answer with next_cursor. Send next_cursor back as cursor to get the next page; there are no more pages when it comes back empty. Cursors are opaque. Do not build or edit them.
How a records listing pages depends on the query:
- An unsorted listing pages by record id. This covers
GET /records/{type_id}, and any query without sorts, aggregates or a group, including"select": "ids". A write between pages never moves another record across a page boundary, so a record that exists throughout the listing is always listed.total_countis on the first page only. - A sorted or summarizing query, or a search, pages by offset, and its pages are live: a write between pages can shift records across a page boundary. Use an unsorted listing when you need every record exactly once, for example to fill a mirror.
GET /facts and POST /facts/query) page by offset and limit per quantity instead. The change feed has its own cursor. See Syncing with the change feed.
Rate limits
Each operation has a cost class, which sets how many requests a key may make per minute. An organization’s keys together may make four times that. Figure computations are also limited to 8 running at once per organization.
A request over a limit gets
429 rate_limited with Retry-After. A request that runs past its wait gets 504 timeout.
OpenAPI
The endpoint pages in this tab come from the API’s OpenAPI 3.1 document. Fetch it with any API key to generate a client:The generic endpoint
POST /v1/object-model/{object_model_id}/request is the older endpoint these routes replace. It is deprecated: existing scripts and keys without scopes can still use it, and every answer to such a key carries a Deprecation header. New integrations should use the routes in this tab with a scoped key.