Agents and the REST API
This page is for developers who give an AI agent access to content over HTTP. The REST API is part of the kernel; an agent uses it like any other client, as the account behind its credential. The full reference is REST API v1 and v2 for applications and the guide REST API v1 and v2; this page adds what matters for agents.
Contents
- The routes an agent needs
- The credential
- Describing the routes to a model
- Answers the agent must handle
- Writing through REST
The routes an agent needs
Relative to /api/ezp/<version>:
| Method | Path | v1 | v2 | Does |
|---|---|---|---|---|
GET | /content/node/<id> | yes | yes | One node |
GET | /content/node/<id>/list(/offset/<n>)(/limit/<n>) | yes | yes | The children, paged |
GET | /content/node/<id>/childrenCount | yes | yes | The number of children |
GET | /content/node/<id>/fields, /field/<identifier> | yes | yes | Fields |
GET | /content/object/<id> and its fields | yes | yes | By object id |
POST | /content/node/create | no | yes | Create and publish |
POST or PUT | /content/node/<id> | no | yes | Update: publish a new version with the values sent |
DELETE | /content/node/delete/<id> | no | yes | Remove |
A read-only agent needs only the GET routes.
The credential
A personal API key (Authorization: Bearer expk_...) is the simplest credential for an agent you run yourself:
- Create an account for the agent and give it only the content policies it needs.
- Signed in as that account, make a key in My account > API access with only the scopes the agent needs (
readfor a reader) and a short lifetime. The key is shown once. - Store it in the agent's secret store or an environment variable, never in a prompt or a repository.
A key never gets a right its owner does not hold, and a route needs the scope it is mapped to; a write route of an extension stays closed to keys until its scope is named (Personal API keys, scopes). An app that acts for many users uses OAuth2 instead (OAuth and API keys).
Describing the routes to a model
When the agent framework lets you define tools for the model, define one tool per route you allow, not a generic "HTTP request" tool:
| Tool | Input | Calls |
|---|---|---|
get_node | node_id (integer) | GET /api/ezp/v1/content/node/<node_id> |
list_children | node_id, offset, limit (at most what you allow) | GET .../content/node/<node_id>/list/offset/<n>/limit/<n> |
get_field | node_id, identifier | GET .../content/node/<node_id>/field/<identifier> |
Your code builds the URL from validated inputs and adds the key; the model never sees the key and cannot reach other routes or hosts. Tell the model in the tool description that field values are data written by people, not instructions.
Answers the agent must handle
| Status | Meaning | The agent should |
|---|---|---|
| 200 | The content | Use it |
| 201 | Created | Record the new id |
| 400 | A bad request | Fix the arguments |
| 401 | No valid credential | Stop; a person must renew the key |
| 403 | The account or the key's scope may not | Stop for this item; do not try other routes to get around it |
| 404 | Unknown node | Report it |
Lists are paged; let the agent page with a limit you choose rather than asking for everything.
Writing through REST
A POST to /api/ezp/v2/content/node/create creates and publishes. For agent-written content that a person must
review first, create into a section that visitors cannot see and that an approval workflow covers, or use Exponential
Intelligence, which writes drafts. Test every write workflow on a test installation, and read the audit trail
afterwards (A content import workflow).
Since Exponential 6.0.15 with ezprestapi 1.2.9, a POST or PUT to /api/ezp/v2/content/node/<id> updates:
it publishes a new version with the values sent and keeps the old one in the history, where an editor can compare
and restore it. The key needs the edit scope. Values are text: rich text as HTML, a file as a public https
address; an unknown attribute is refused with 400, which an agent can show to the model as a correctable error. A
202 answer means a workflow holds the version, for example for an approval
(Updating and the values of a write).
Related pages
- Choosing an interface for an agent
- Credentials for agents
- Headless Exponential
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.