REST API
Everything the console can do, over HTTP. Most people don’t need this — point a coding agent at the MCP + skills and describe the task. Call it directly when you’re building your own backend.
Base URL https://api.agent4.io/v1. Every tenant endpoint authenticates with your API key:
X-API-Key: tk_… # or: Authorization: Bearer tk_…
Generate a key in the console under Settings → Security — the plaintext is shown once, at creation. Machine-readable spec: openapi.json.
Agents
/agents/{name}Create or replace an agent (full PUT semantics — send every field you want to keep).
curl -X POST https://api.agent4.io/v1/agents/advisor -H "X-API-Key: $KEY" \
-H 'Content-Type: application/json' \
-d '{"soul":"You are a loan advisor","tools":["web_search"],"published":true}'/agentsList your agents.
/agents/{name}Get one agent's full configuration.
Knowledge bases
/knowledge-basesCreate a knowledge base.
curl -X POST https://api.agent4.io/v1/knowledge-bases -H "X-API-Key: $KEY" -H 'Content-Type: application/json' \
-d '{"name":"Company policy","instructions":"Authoritative current policy."}'/knowledge-bases/{name}/documents/uploadUpload a file (pdf/docx/…) or a zip of a folder — subfolders are walked and imported.
curl -X POST "https://api.agent4.io/v1/knowledge-bases/Company%20policy/documents/upload" \ -H "X-API-Key: $KEY" -F "file=@/path/to/policy.pdf"
/knowledge-bases/{name}/searchSearch the base — verify a real question retrieves before you rely on it.
curl -X POST "https://api.agent4.io/v1/knowledge-bases/Company%20policy/search" -H "X-API-Key: $KEY" \
-H 'Content-Type: application/json' -d '{"query":"late fee"}'Your MCP servers & tools
Bring your own tools: register a remote MCP server, then attach its tools to an agent.
/mcp-serversRegister a remote MCP server (transport: streamable_http | sse; stdio is rejected).
curl -X POST https://api.agent4.io/v1/mcp-servers -H "X-API-Key: $KEY" -H 'Content-Type: application/json' \
-d '{"name":"my-tools","transport":"streamable_http","config":{"url":"https://tools.example.com/mcp"}}'/mcp-serversList the MCP servers registered on your tenant.
Storylines
Multi-step, stateful flows. See the cookbook recipe for the graph shape.
/storylinesCreate a Storyline draft (a graph of nodes with conditional exits).
/storylines/{id}/validateValidate the graph — required before publishing.
/storylines/{id}/publishFreeze an immutable version and go live.
Usage & end users
/manage/usage?group=agentUsage metadata (token counts, event counts) — never conversation content.
curl "https://api.agent4.io/v1/manage/usage?group=agent" -H "X-API-Key: $KEY"
/manage/usersList your end users (email / login method).
Building with a coding agent instead? The Cookbook has the same operations as ready-to-run recipes over MCP — no manual HTTP.