Skip to main content

API Reference

The Xagent API provides programmatic access to all platform capabilities.

Base URL

Self-hosted: http://localhost:8000
Production: https://your-domain.com

Authentication

Most API endpoints require authentication using a Bearer token:
curl http://localhost:8000/api/agents \
  -H "Authorization: Bearer YOUR_TOKEN"

Interactive Documentation

For interactive API documentation with request/response examples, visit:
  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

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",
    "instruction": "You are a helpful research assistant."
  }'

Submit a Task

curl -X POST http://localhost:8000/api/chat/tasks \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent-id",
    "query": "Research recent AI trends"
  }'

Rate Limits

API calls may be rate limited. Check response headers for limit information:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200

Error Handling

Errors follow standard HTTP status codes:
  • 200 - Success
  • 400 - Bad Request
  • 401 - Unauthorized
  • 422 - Validation Error
  • 500 - Server Error