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.com

Authentication

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:

ToolPathBest for
Swagger UI/docsTrying requests interactively in the browser.
ReDoc/redocClean, readable reference for the whole API.
OpenAPI JSON/openapi.jsonThe 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

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/usage

Error Handling

Errors follow standard HTTP status codes:

CodeMeaning
200Success
400Bad Request
401Unauthorized
422Validation Error
500Server Error

Reference Pages