Skip to content

HTTP API

The gateway is an HTTP server. Every surface is CORS-enabled, versioned, and accepts a x-cartoql-principal header for the requesting identity.

POST /graphql

Runs a GraphQL document.

curl -s -X POST http://localhost:4137/graphql \\
  -H 'content-type: application/json' \\
  -H 'x-cartoql-principal: alice' \\
  -d '{"query":"query { person(iri: $iri) { iri name worksFor { iri name } } }",
       "variables":{"iri":"https://cartoql.example/corpus/core/data#person-ada"}}'

Response

{
  "data": { "person": { "iri": "...", "name": "Ada Ionescu", "worksFor": { ... } } },
  "errors": []
}

On a rejection ( over-budget, validation error, denied ), errors carry typed CQL_* extension codes -- see Error Codes.

POST /explain

Compiles the document and previews its cost without executing:

curl -s -X POST http://localhost:4137/explain \\
  -H 'content-type: application/json' \\
  -d '{"query":"query { people(first: 5) { edges { node { name worksFor { name } } } }"}'
{
  "planId": "83608...",
  "cost": 7.3,
  "depth": 3,
  "nodeCount": 4,
  "withinBudget": true
}

GET /sdl

The compiled schema as SDL text. The console uses this to populate the schema rail, autocomplete, and graph dialog.

GET /health

{
  "status": "ok",
  "adapter": "reference (...)",
  "auth": "static",
  "schemaHash": "1653e...",
  "aclGraph": null
}

GET /metrics

Prometheus exposition. Toggle with --metrics off or the observability section of cartoql.json.

GET / (the console)

The rich console — a GraphiQL-class editor UI built from packages/ui and served statically at /. Served only when the gateway is given --ui packages/ui/dist; without it, GETs fall through to 404 with the build instruction. (The legacy inline GET /playground stub was retired.)