Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,212 of 9,212 pages
About the help in other languages
All help pages

Headless Exponential: start here

What this is. The documentation of everything a program needs to use an Exponential installation as a headless content repository: the GraphQL API at /api/graphql, its keys and tokens, its cache tags, its event journal…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/headless/README.md

On this page

Headless Exponential: start here

What this is. The documentation of everything a program needs to use an Exponential installation as a headless content repository: the GraphQL API at /api/graphql, its keys and tokens, its cache tags, its event journal with webhooks and subscriptions, and the CORS, rate-limit and request-shield rules in front of it. The @exponentialcms TypeScript SDK is built on exactly these features, so these pages are also the reference behind every SDK package.

When to use it. Read this section when you build a front end, an app, a static site, a search index or an integration on Exponential content; when you operate an installation that serves such clients; or when you maintain the kernel code that answers them.

A first request (anonymous, read only; replace the host with your own site):

curl -s https://www.example.com/api/graphql \
  -H 'Content-Type: application/json' \
  -d '{"query":"{ siteaccess { name languages rootNodeId schemaHash } }"}'
{"data":{"siteaccess":{"name":"site","languages":["eng-US"],"rootNodeId":89,"schemaHash":"19deb36636de"}},
 "extensions":{"requestId":"78f2afed30f21b72","schemaHash":"19deb36636de"}}

If you get {"errors":[{"message":"The GraphQL API is switched off in this siteaccess." ... "code":"DISABLED"}]} with HTTP 404, switch it on first: Operations, "Switching the API on".

The pages

#PageWhat it answers
1Headless overviewthe architecture, how data flows, and which approach (plain fetch, the SDK, persisted queries, webhooks, subscriptions) fits which project
2GraphQL API referenceevery query, mutation, subscription, type, argument and error, with curl, fetch and SDK examples
2aDatatypes in GraphQLthe GraphQL shape of every datatype when read, and the string format of every datatype when written
3Authenticationanonymous access, personal API keys, public read keys, keys limited to siteaccesses, OAuth tokens, sessions; rotation; the roles and policies needed
4Cache tags and invalidationthe response cache, ETags, HTTP caching, CDN purging and the SDK's cache
5Events, webhooks and subscriptionsthe event journal, every event's payload, webhook signing and verification (Node, PHP), retries, ordering, idempotency, replay, the job queue
6CORS, rate limits and the request shieldcalling the API from browsers and programs without being refused
7Operationsswitching on, monitoring, logs, troubleshooting (a table of errors and fixes), performance tuning
8Compatibility and upgradeswhat stays stable, how things are deprecated, which PHP and Exponential versions are supported, how to upgrade safely
9Maintainer guidewhere the code lives; how to add a field, a datatype, a mutation or an event kind; the tests; the release checklist
10Cookbook30 complete recipes: listings, menus, search, images, forms, previews, multisite, languages, sitemaps, static rebuilds and more

Every page stands on its own: the facts a page needs are repeated there, and each page links to the page that goes deeper. The feature page The GraphQL API is the original description of the feature and stays valid; these pages reorganize and extend it per task.

Start here: a reading path for your role

Site builder (you set up an installation for a front-end team)

  1. Headless overview: what the API is and what it is not.
  2. Operations, "Switching the API on": exp:graphql:enable, the siteaccess, a read-only API.
  3. Authentication: which key or token each client gets, and which role its user needs.
  4. CORS, rate limits and the request shield: the browser origins and the API path in the shield.
  5. Events, webhooks and subscriptions, "Setting up a webhook": tell the front end when content changes.
  6. Operations, "Checklist before go-live".

Frontend developer (you build on the API)

  1. Headless overview, "Choosing an approach".
  2. GraphQL API reference, from "Your first query" down; keep Datatypes in GraphQL open beside it.
  3. Cache tags and invalidation: tag your cache, purge by events.
  4. Cookbook: copy the recipe closest to your page.
  5. Authentication, "Which credential for which client": never ship a writing key to a browser.

Operations (you run the servers)

  1. Operations: monitoring, the files under var/, logs, the error table, tuning.
  2. CORS, rate limits and the request shield.
  3. Events, webhooks and subscriptions, "Operating webhooks".
  4. Compatibility and upgrades, "Upgrading safely".

Maintainer (you change the kernel code)

  1. Maintainer guide.
  2. Compatibility and upgrades: the contract you must not break.
  3. GraphQL API reference, "Errors": the stable error codes.
  4. Events, webhooks and subscriptions, "The event record": the journal format, version 1.

Glossary

The same words mean the same thing on every page of this section.

TermMeaning
SiteaccessOne configured face of an installation (a host, a path prefix or a header chooses it): its languages, its root node, its settings. The API answers per siteaccess; a client picks one with the host, the path, or the header X-Siteaccess.
Content objectA piece of content (an article, an image), with versions and translations. Its id is Content.id in GraphQL (objectId in events).
Location (node)A place of a content object in the content tree. One object can have several locations; one is its main location. Its id is Location.id (nodeId in events and mutations). Node ids and object ids are different numbers.
Content classThe type of a content object (article, image), with attributes. Every class shown in the schema is a GraphQL type that implements the interface Content.
Attribute / fieldA part of a class (title, image). In GraphQL each attribute is a field of the class type; its datatype decides its GraphQL type.
DatatypeThe kind of value an attribute holds (ezstring, ezimage, ezxmltext ...). See Datatypes in GraphQL.
Translation / languageContent languages are codes like eng-GB, ger-DE. A query reads one translation; Content.language says which.
Remote idA stable, installation-independent string id of an object or a location, useful across environments.
URL aliasThe path of a location in a siteaccess (about/company); "" is the front page.
SectionA grouping of content used by policies (who may read what). Content.sectionId.
Object stateA state in a state group (review/approved) that policies can depend on.
Role / policy / limitationThe access rules: a role is a set of policies (content/read, content/edit ...), each with limitations (class, section, subtree, state). Every request runs as a user and its roles decide.
Anonymous userThe user a request without credentials runs as; the role Anonymous decides what it reads.
Personal API keyA key expk_<12 characters>_<40 characters> a user makes for programs; the request runs as that user, limited to the key's scopes.
ScopeWhat a key may be used for: graphql:read (queries, subscriptions), graphql:write (mutations), and the scopes of the other REST routes.
Public read keyA key with only graphql:read, limited to siteaccesses, owned by a user that only reads, with its own rate limit; meant to be shipped in a front end.
OAuth tokenA bearer token of the REST layer's OAuth server, for a signed-in person using an app.
Persisted queryA query stored on the server and called by a name or its SHA-256; the only kind of query the response cache keeps.
Automatic persisted query (APQ)Apollo's protocol: the client sends a SHA-256 and, when the server does not know it, the text with it, which stores it.
Response cacheThe server-side cache of answers of persisted queries, under var/cache/graphql/responses/, expired on every publish.
Cache tag (purge tag)A short name of something an answer shows (c57 the object 57, l59 the node 59 ...), sent in X-Exponential-Cache-Tags, so a client or a CDN can drop exactly the answers an event concerns.
Schema hashA 12-character hash of the schema of a siteaccess (X-GraphQL-Schema, extensions.schemaHash). It changes when a class, the naming or the extensions change: regenerate your types then.
Event journalThe files var/<site>/graphql/events/events-<generation>.jsonl: one JSON line per content change, read by webhooks and subscriptions.
Event / event kindOne line of the journal; its kind is publish, update, trash, delete, move, hide, reveal, mutation, clear, or a kind a package registers (newsletter.subscription.confirmed).
Position<generation>.<byte offset> in the journal: the id of an event in a subscription stream (Last-Event-ID) and the cursor of the webhooks.
Webhook / end pointA URL the installation POSTs signed events to, configured as [GraphQLWebhook_<name>] in graphql.ini.
DeliveryOne event sent to one end point, with its own id (X-Exponential-Delivery) kept over its retries.
OutboxThe files var/<site>/graphql/webhooks/outbox/ holding deliveries that wait to be sent (the default delivery).
expqueueThe job queue extension; with Delivery=queue each delivery is a job graphql.webhook with the queue's retries and dead letter.
SubscriptionA GraphQL subscription over Server-Sent Events (/api/graphql/subscribe) or a WebSocket through Velocity.
Preview tokenexp1.<payload>.<signature>: a short-lived permission to read one version (a draft) without signing in.
Request shieldThe extension exp_request_shield, a small web application firewall that decides every request before the kernel.
VelocityExponential's own application server (persistent PHP workers), an alternative to PHP-FPM; it also carries WebSockets.
Request id16 hexadecimal characters in X-Request-Id and extensions.requestId; quote it when you report a problem.

The general glossary of Exponential is glossary.md.

Where the code and the other documentation are

WhatWhere
The GraphQL kernel codekernel/classes/graphql/ (the classes expGraphQL*), kernel/classes/graphql/rest/ (the REST controller), kernel/classes/graphql/extensions/ (tags, layouts)
Settingssettings/graphql.ini, settings/rest.ini ([ApiKeySettings], [CorsSettings]), settings/expqueue.ini (the job type graphql.webhook)
Console commandsbin/php/expgraphql*.php, run as ./console exp:graphql:<name>
Teststests/tests/kernel/classes/graphql/
The feature pageThe GraphQL API
Personal API keysPersonal API keys (guide), api-keys.md (upgrade notes)
CORS of the REST layerCORS for the REST API
The request shieldThe request shield, Setting up the request shield
The SDKexponentialcms-client and the framework packages listed in the overview

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x