> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vectorshift.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Ontology API

> Read and write your organization's records, facts and figures over REST

> [!NOTE]
>
> 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.

> [!NOTE]
>
> 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](https://docs.vectorshift.ai/ontology/working-with-your-schema.md#the-apis-names).

## Base URL

```
https://api.vectorshift.ai/v1/object-model
```

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`](https://docs.vectorshift.ai/ontology/schema/get). 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](https://docs.vectorshift.ai/ontology/authentication.md).

**2. Read the schema**

```bash theme={"languages":{}}
curl https://api.vectorshift.ai/v1/object-model/schema \
  -H "Authorization: Bearer $VECTORSHIFT_API_KEY"
```

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](https://docs.vectorshift.ai/ontology/working-with-your-schema.md) explains how to read it, and [Field types](https://docs.vectorshift.ai/ontology/field-types.md) 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](https://docs.vectorshift.ai/ontology/idempotency.md).

```bash theme={"languages":{}}
curl -X POST https://api.vectorshift.ai/v1/object-model/records/company \
  -H "Authorization: Bearer $VECTORSHIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: create-acme-2026-11-16" \
  -d '{"values": {"name": "Acme"}}'
```

```json theme={"languages":{}}
{"written_id": "6650…", "disposition": "created", "records": [{"id": "6650…", "type_id": "company", "values": {"name": "Acme"}}]}
```

**4. Query records**

```bash theme={"languages":{}}
curl -X POST https://api.vectorshift.ai/v1/object-model/records/deal/query \
  -H "Authorization: Bearer $VECTORSHIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": {"op": "all", "conditions": [
      {"op": "eq", "field": "stage", "value": "diligence"},
      {"op": "gt", "field": "size", "value": 5000000}
    ]},
    "sorts": [{"field": "size", "descending": true}],
    "limit": 20
  }'
```

Filters share one shape across record queries, search and figure selections. See [Record filters](https://docs.vectorshift.ai/ontology/record-filters.md).

## 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](https://docs.vectorshift.ai/ontology/records/update.md) 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`](https://docs.vectorshift.ai/ontology/definition/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

| Status | Meaning |
| - | - |
| `200` | Answered. The body is the operation's result. |
| `202` | Accepted and waiting for a person's decision. For an action or a definition change, follow its `decision_id` with [`GET /decisions/{decision_id}`](https://docs.vectorshift.ai/ontology/actions/decision). For a fact capture (`capture_pending`), send the same capture again with `action: evaluate`. |
| `400` | The request is malformed: bad JSON, an unknown field or parameter, a body that contradicts its path, or a missing `Idempotency-Key`. |
| `401` | The API key is missing, invalid or expired. |
| `403` | The key lacks the route's scope, the person lacks the permission, or a feature the request needs is not enabled for the organization. |
| `404` | No such object, or one this caller cannot see. Both get the same answer on purpose. Also returned when the organization has no ontology (`no_object_model`). |
| `409` | A conflict: a reused or in-flight `Idempotency-Key`, a change-feed cursor that needs a resync (`cursor_resync`), or a conflict the operation reports (a stale capture, a draft that conflicts on publish). |
| `412` | The `If-Match` version or revision is no longer current. |
| `422` | The request was understood and refused: the ontology's rules, a filter that does not fit the type, an action that stopped part way. |
| `429` | A rate limit. Retry after `Retry-After` seconds. |
| `503` | The request could not be recorded for idempotency, so it was not run (`idempotency_unavailable`). Retry after `Retry-After`. |
| `504` | No answer in time. A write may still complete, so retry it with the **same** `Idempotency-Key`. |

Each endpoint page lists only the statuses that endpoint can return.

### Errors

Every error has the same body:

```json theme={"languages":{}}
{
  "status": "failed",
  "code": "path_conflict",
  "error": "the path names type_id \"company\" but the body says \"deal\"; the path decides, so send the same value or none",
  "path": "/type_id",
  "request_id": "7f3a…"
}
```

| Field | Description |
| - | - |
| `status` | Always `"failed"`. |
| `code` | A stable, machine-readable code. Branch on this, not on `error`. |
| `error` | A human-readable message. Its wording may change. |
| `path` | A JSON Pointer into the request body at the member at fault, such as `/filter/conditions/1/value`, when there is one. |
| `details` | Extra facts about the refusal, such as `current_version` on a `412`. |
| `request_id` | The request's id. Include it when you contact support. |
| `result` | On a `409` or `422`, what the operation did before it stopped, if anything. For an action that stopped part way, this is its `instance_id` and the records and facts it created. |

Codes the API itself returns:

| Code | Status | Meaning |
| - | - | - |
| `invalid_request` | 400 | Malformed JSON, an unknown field or query parameter, or a malformed `Idempotency-Key`. |
| `path_conflict` | 400 | The body or a query parameter contradicts the path. |
| `unsupported_parameter` | 400 | A parameter this route does not take yet. |
| `conflicting_parameters` | 400 | Two parameters this route does not combine. |
| `idempotency_key_required` | 400 | A write without an `Idempotency-Key`. |
| `unauthenticated` | 401 | Missing, invalid or expired API key. |
| `scope_required` | 403 | The key does not carry the scope the route needs, or has no scopes at all. |
| `forbidden` | 403 | The key's person lacks the permission in the app. |
| `not_enabled` | 403 | A feature the request needs is not enabled for the organization. |
| `no_object_model` | 404 | The organization has no ontology yet. Create one with [`POST /v1/object-model`](https://docs.vectorshift.ai/ontology/definition/create). |
| `idempotency_key_reused` | 409 | The key was already used for a different request. |
| `request_in_progress` | 409 | A request with this key is still running. |
| `rate_limited` | 429 | A rate limit was reached. |
| `idempotency_unavailable` | 503 | The request could not be recorded, so it was not run. |
| `timeout` | 504 | No answer in time. |
| `internal` | 500 | An unexpected failure. |

Refusals from the ontology itself (`422`, `409`, `412`, and many `404`s) 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](https://docs.vectorshift.ai/ontology/field-types.md#refusals) explains the ones a record's values can get.

### Headers

| Header | When | Meaning |
| - | - | - |
| `X-Request-Id` | On every request that ran | The request's id, the same one as `request_id` in an error. |
| `Object-Model-Version` | On answers | The ontology version the request was served under. |
| `Idempotent-Replayed` | On a replayed answer | `true` when this is the recorded answer to an earlier request with the same `Idempotency-Key`. |
| `Retry-After` | On `429`, `409 request_in_progress` and `503` | Seconds to wait before retrying. |

## 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}`](https://docs.vectorshift.ai/ontology/records/list), and any [query](https://docs.vectorshift.ai/ontology/records/query.md) 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`](https://docs.vectorshift.ai/ontology/facts/list) and [`POST /facts/query`](https://docs.vectorshift.ai/ontology/facts/query)) page by `offset` and `limit` per quantity instead. The change feed has its own cursor. See [Syncing with the change feed](https://docs.vectorshift.ai/ontology/change-feed.md).

## 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.

| Class | Per key, per minute | Per organization, per minute | Waits up to | Operations |
| - | - | - | - | - |
| Light | 600 | 2,400 | 30 s | Schema, a single record, actions, decisions, scenarios, versions and drafts, job status |
| Query | 300 | 1,200 | 45 s | Record lists, queries and search, related records, activity, evidence, facts, the change feed |
| Compute | 120 | 480 | 45 s | Figure queries and explanations (also 8 at once per organization) |
| Write | 120 | 480 | 120 s | Record, fact, scenario, action and definition writes, and write-job calls |
| Bulk | 10 | 40 | 120 s | Action batches and imports |

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:

```bash theme={"languages":{}}
curl https://api.vectorshift.ai/v1/object-model/openapi.json \
  -H "Authorization: Bearer $VECTORSHIFT_API_KEY"
```

## 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.