API Reference
The Xagent API provides programmatic access to all platform capabilities — agents, tasks, knowledge bases, models, tools, and more.
Base URL
Self-hosted: http://localhost:8000
Production: https://your-domain.comAuthentication
Most endpoints require a Bearer token:
curl http://localhost:8000/api/agents \
-H "Authorization: Bearer YOUR_TOKEN"Interactive Documentation
Every Xagent deployment ships live, auto-generated API explorers built from the server's OpenAPI spec:
| Tool | Path | Best for |
|---|---|---|
| Swagger UI | /docs | Trying requests interactively in the browser. |
| ReDoc | /redoc | Clean, readable reference for the whole API. |
| OpenAPI JSON | /openapi.json | The raw spec — import into Postman, codegen, etc. |
Live spec
On a running instance, open http://localhost:8000/docs for Swagger UI or http://localhost:8000/redoc for ReDoc. These always reflect the exact endpoints your version exposes.
Available APIs
User authentication and token management.
Agents →Create and manage AI agents.
SDK Tasks →Create and monitor SDK task executions.
Files →Upload and manage task files.
Knowledge Base →Manage document collections.
Memory →Agent memory and learning.
Models →Configure and use LLM models.
Tools →Available agent tools.
Skills →Agent skill management.
Templates →Agent templates.
MCP →MCP server management.
Text2SQL →Database query generation.
Quick Start
Login
curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "your-password"}'Create an Agent
curl -X POST http://localhost:8000/api/agents \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Research Assistant",
"description": "Helps with research tasks",
"instructions": "You are a helpful research assistant."
}'Submit a Task
This quickstart uses the application API (/api) with the JWT returned from login — see the Chat / Tasks API for the full endpoint reference. For stable, versioned programmatic integration, use the Workspace SDK (/v1) with a runtime key instead.
curl -X POST http://localhost:8000/api/chat/task/create \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Research recent AI trends",
"description": "Summarize the latest AI research trends",
"agent_id": 42
}'Quotas & Limits
Xagent does not apply per-second or per-minute rate limiting. Instead, each team has monthly usage quotas set by its plan — caps on agents, agent executions per month, and API calls per month.
When a quota is exceeded, the API responds with 402 Payment Required and a message naming the metric that was hit:
HTTP/1.1 402 Payment Required
{ "detail": "Quota exceeded: max_agents (5/5)" }Check current usage and remaining quota for your team at any time:
GET /api/billing/usageError Handling
Errors follow standard HTTP status codes:
| Code | Meaning |
|---|---|
200 | Success |
400 | Bad Request |
401 | Unauthorized |
422 | Validation Error |
500 | Server Error |
Reference Pages
- API Reference Overview → — API groups and prefixes
- Agents API →
- Workspace SDK →