Skip to main content
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 Ontology API gives programs access to your organization’s ontology:
  • 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
Every request runs as the person who created the API key, so it can see and change only what that person can in the app. Permissions, hidden fields and deletion policies apply exactly as they do there.
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

An organization has one ontology, so paths do not include an ontology id. Type, field, relation, action and import ids in paths and bodies are the ids your ontology declares. Get them from 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

The answer lists record types and their fields, relations, quantities, figures, actions and scenarios. It flags any field this key’s person cannot read. Every organization’s schema is different: Working with your schema explains how to read it, and Field types how to write each field’s value.
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

Filters share one shape across record queries, search and figure selections. See Record filters.

Requests

  • Bodies are JSON, with field names in snake_case exactly as each endpoint lists them. An unknown field or query parameter is refused with 400 invalid_request rather 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, and path points 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-Match on a record update names the record’s revision you read. If the record has changed since, nothing in the update is applied, neither field changes nor list or link edits: 412 revision_mismatch, with details.current_revision.
  • If-Match takes the number bare or quoted (If-Match: 1842 or If-Match: "1842"). The body can carry the same value (expected_revision, expected_version); when both are sent, the header wins.
  • If-Match on POST /model/configure names the ontology version you read. If the ontology has moved on since, the change is refused with 412 version_mismatch, and details.current_version holds 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 take limit 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_count is 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.
Raw fact reads (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.