API reference

REST APIs for the AnythingGraph open-source stack. Use the Data Injection API to ingest records, the Data Cache API for data capsules and SPARQL, and the Data layer for entities, rows, and graph relationships.

Prefer the official SDKs (Python, Node.js, Go) for typed clients. This page documents raw HTTP endpoints.

The platform lets you:

  • Model data — entities, rows, schema links, and row-level relationships
  • Ingest playbooks — install packs, map fields, post webhook payloads
  • Export & query RDF — Turtle export, cache load, SPARQL with ReBAC
  • Train connectors — landing zone review and field-mapping corrections

Base URLs

Default local URLs when running ./start-all.sh:

Data Injection API http://127.0.0.1:8183
Data Cache API http://127.0.0.1:8181
Data layer http://127.0.0.1:8182

All requests use Content-Type: application/json unless the response is Turtle (text/turtle).

Authentication & ReBAC

Local OSS deployments do not require API keys. Services bind to localhost by default.

For playbooks with enforced relationship access, pass ReBAC context on data-layer row and relationship reads:

HeaderQuery (alt.)Description
X-Ontox-Subject-Id subject_id Subject identifier (e.g. employee email)
X-Ontox-Playbook-Id playbook_id Installed playbook id
SPARQL & playbook caches. /sparql/query requires a real playbook_id. The global slot __global__ is rejected for governed agent queries.

Data Injection API

Base: http://127.0.0.1:8183. Structured ingest with connector context for playbook-scoped payloads.

GET/health

Health

curl -s http://127.0.0.1:8183/health
POST/ingest

Ingest

Body: { "context": IngestContext, "payload": ... }. Returns row and relationship create results plus landing zone count.

curl -s -X POST http://127.0.0.1:8183/ingest \
  -H 'Content-Type: application/json' \
  -d '{
    "context": {
      "playbook_id": "organizational-graph",
      "source_label": "hr-export",
      "entity_name": "employee",
      "field_mappings": []
    },
    "payload": {
      "records": [
        { "full_name": "Sam Lee", "email": "sam@acme.example" }
      ]
    }
  }'
GET/landing-zone

List landing zone

curl -s http://127.0.0.1:8183/landing-zone
POST/landing-zone/:record_id/approve

Approve landing zone record

curl -s -X POST http://127.0.0.1:8183/landing-zone/12/approve \
  -H 'Content-Type: application/json' \
  -d '{
    "entity_name": "employee",
    "corrected_values": { "full_name": "Sam Lee" },
    "field_mappings": [
      { "from_field": "name", "to_field": "full_name", "entity_name": "employee" }
    ]
  }'
DELETE/landing-zone/:record_id

Delete landing zone record

curl -s -X DELETE http://127.0.0.1:8183/landing-zone/12

Data Cache API

Base: http://127.0.0.1:8181. In-memory Turtle cache and SPARQL. Omit playbook_id for __global__ (load only).

GET/health

Health

curl -s http://127.0.0.1:8181/health
POST/cache/load

Load cache

FieldTypeDescription
turtlestringTurtle RDF text
replacebooleantrue overwrite; false append
playbook_idstringCache slot (optional → __global__)
curl -s -X POST http://127.0.0.1:8181/cache/load \
  -H 'Content-Type: application/json' \
  -d '{
    "turtle": "@prefix ex: <http://example.com/> . ex:a ex:knows ex:b .",
    "replace": true,
    "playbook_id": "organizational-graph"
  }'
GET/cache/get?playbook_id=

Get cached Turtle

curl -s 'http://127.0.0.1:8181/cache/get?playbook_id=organizational-graph'
GET/cache/meta?playbook_id=

Cache metadata

Returns version, turtle_bytes, updated_at_ms.

curl -s 'http://127.0.0.1:8181/cache/meta?playbook_id=organizational-graph'
GET/cache/list

List all caches

curl -s http://127.0.0.1:8181/cache/list
POST/cache/clear

Clear cache

Pass playbook_id for one slot, or "clear_all": true for all.

curl -s -X POST http://127.0.0.1:8181/cache/clear \
  -H 'Content-Type: application/json' \
  -d '{"playbook_id": "organizational-graph"}'
POST/sparql/query

SPARQL query

SELECT queries only. Optional subject_id applies ReBAC filtering.

curl -s -X POST http://127.0.0.1:8181/sparql/query \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "SELECT ?row ?name WHERE { ?row a <http://example.com/context#Employee> ; <http://example.com/context#fullName> ?name }",
    "playbook_id": "organizational-graph",
    "subject_id": "sam@acme.example"
  }'
POST/rebac/allowed-rows

ReBAC allowed rows

Row ids a subject may read. Omit entity_name for all entities in playbook rules.

curl -s -X POST http://127.0.0.1:8181/rebac/allowed-rows \
  -H 'Content-Type: application/json' \
  -d '{
    "playbook_id": "crm-relationship-access",
    "subject_id": "alex.ae",
    "entity_name": "crm_account"
  }'

Data layer

Base: http://127.0.0.1:8182. Entity, row, and relationship storage with Turtle export.

GET/health

Health

curl -s http://127.0.0.1:8182/health
GET/entities

List entities

curl -s http://127.0.0.1:8182/entities
GET/entities/:entity_id

Get entity

curl -s http://127.0.0.1:8182/entities/1
POST/entities

Create entity

curl -s -X POST http://127.0.0.1:8182/entities \
  -H 'Content-Type: application/json' \
  -d '{"name":"person","fields":[{"field_name":"email","field_type":"TEXT"}]}'
PUT/entities/:entity_id

Update entity

curl -s -X PUT http://127.0.0.1:8182/entities/1 \
  -H 'Content-Type: application/json' \
  -d '{"display_name":"Person"}'
DELETE/entities/:entity_id

Delete entity

curl -s -X DELETE http://127.0.0.1:8182/entities/1
GET/entities/:entity_id/data

List entity rows

Supports X-Ontox-Subject-Id, X-Ontox-Playbook-Id, or query params.

curl -s 'http://127.0.0.1:8182/entities/1/data?subject_id=alex.ae&playbook_id=crm-relationship-access'
POST/entities/:entity_id/data

Create entity row

curl -s -X POST http://127.0.0.1:8182/entities/1/data \
  -H 'Content-Type: application/json' \
  -d '{"values":{"email":"a@example.com"}}'
PUT/entities/:entity_id/data/:row_id

Update entity row

curl -s -X PUT http://127.0.0.1:8182/entities/1/data/5 \
  -H 'Content-Type: application/json' \
  -d '{"values":{"email":"b@example.com"}}'
DELETE/entities/:entity_id/data/:row_id

Delete entity row

curl -s -X DELETE http://127.0.0.1:8182/entities/1/data/5
GET/entity-relationships

List schema relationships

curl -s http://127.0.0.1:8182/entity-relationships
GET/entity-relationships/:entity_relationship_id

Get schema relationship

Fetch one schema relationship by id.

curl -s http://127.0.0.1:8182/entity-relationships/3
POST/entity-relationships

Create schema relationship

curl -s -X POST http://127.0.0.1:8182/entity-relationships \
  -H 'Content-Type: application/json' \
  -d '{"relationship_name":"works_at","subject_entity_id":1,"object_entity_id":2}'
PUT/entity-relationships/:entity_relationship_id

Update schema relationship

curl -s -X PUT http://127.0.0.1:8182/entity-relationships/3 \
  -H 'Content-Type: application/json' \
  -d '{"relationship_name":"employed_by"}'
DELETE/entity-relationships/:entity_relationship_id

Delete schema relationship

curl -s -X DELETE http://127.0.0.1:8182/entity-relationships/3
GET/relationships

List row relationships

curl -s http://127.0.0.1:8182/relationships
POST/relationships

Create row relationship

curl -s -X POST http://127.0.0.1:8182/relationships \
  -H 'Content-Type: application/json' \
  -d '{"relationship_name":"works_at","subject_entity_id":1,"object_entity_id":2,"subject_row_id":1,"object_row_id":1}'
PUT/relationships/:relationship_id

Update row relationship

curl -s -X PUT http://127.0.0.1:8182/relationships/10 \
  -H 'Content-Type: application/json' \
  -d '{"object_row_id":2}'
DELETE/relationships/:relationship_id

Delete row relationship

curl -s -X DELETE http://127.0.0.1:8182/relationships/10
POST/rdf/turtle

Export Turtle

Returns text/turtle. Use /rdf/turtle without a trailing slash.

curl -s -X POST http://127.0.0.1:8182/rdf/turtle \
  -H 'Content-Type: application/json' \
  -d '{"entity_ids":"*"}'

curl -s -X POST http://127.0.0.1:8182/rdf/turtle \
  -H 'Content-Type: application/json' \
  -d '{"entity_names":["corporation"]}'
GET/policy/roles

List policy roles

Read-only built-in OSS roles. Response: { ok, edition, roles }.

curl -s http://127.0.0.1:8182/policy/roles