RESTful API v1 - Complete endpoint documentation with examples
Base URLs, authentication, and rate limits you need before calling endpoints.
Production: https://api.example.com/v1
Staging: https://staging-api.example.com/v1
Local: http://localhost:8000/api/v1
# Get access token
curl -X POST https://api.example.com/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "secure_pass"}'
# Use token in requests
curl -X GET https://api.example.com/v1/crews \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"| Tier | Requests/Hour | Burst |
|---|---|---|
| Free | 1,000 | 100/min |
| Pro | 10,000 | 1,000/min |
| Enterprise | Unlimited | Custom |
Login, refresh, and logout flows to manage tokens.
Login with credentials
Request:
{
"email": "user@example.com",
"password": "secure_password"
}
Response: 200 OK
{
"access_token": "eyJ0eXAi...",
"token_type": "bearer",
"expires_in": 86400
}Refresh access token
Request:
{
"refresh_token": "eyJ0eXAi..."
}
Response: 200 OK
{
"access_token": "eyJ0eXAi...",
"expires_in": 86400
}Invalidate tokens
Response: 204 No ContentCreate and manage multi-agent crews and their configurations.
List all crews
Response: 200 OK
{
"crews": [
{
"id": "crew_abc123",
"name": "Customer Support Crew",
"status": "active",
"agents_count": 3,
"created_at": "2024-01-15T10:30:00Z"
}
],
"total": 15,
"page": 1
}Create new crew
Request:
{
"name": "Marketing Crew",
"description": "Content generation team",
"process": "hierarchical",
"agents": [
{
"role": "Content Writer",
"goal": "Create engaging content",
"model": "gpt-4"
}
]
}
Response: 201 Created
{
"id": "crew_xyz789",
"name": "Marketing Crew",
"status": "configuring"
}Get crew details
Response: 200 OK
{
"id": "crew_abc123",
"name": "Customer Support Crew",
"agents": [...],
"tasks": [...],
"configuration": {...}
}Update crew configuration
Request:
{
"name": "Updated Crew Name",
"process": "sequential"
}
Response: 200 OK
{
"id": "crew_abc123",
"updated": true
}Delete crew
Response: 204 No ContentCreate and list individual agents with roles, models, and tools.
List all agents
Response: 200 OK
{
"agents": [
{
"id": "agent_001",
"name": "Research Agent",
"crew_id": "crew_abc123",
"model": "gpt-4",
"status": "ready"
}
]
}Create new agent
Request:
{
"crew_id": "crew_abc123",
"role": "Data Analyst",
"goal": "Analyze metrics",
"backstory": "Expert analyst with 10 years experience",
"model": "claude-3-opus",
"tools": ["web_search", "calculator"]
}
Response: 201 Created
{
"id": "agent_002",
"status": "created"
}Start executions, get status, retrieve traces, and stop runs.
Start crew execution
Request:
{
"crew_id": "crew_abc123",
"inputs": {
"topic": "Q4 Marketing Strategy",
"deadline": "2024-12-31"
}
}
Response: 202 Accepted
{
"job_id": "job_qwerty123",
"status": "queued",
"estimated_duration": 300
}Get execution status
Response: 200 OK
{
"job_id": "job_qwerty123",
"status": "running",
"progress": 65,
"current_task": "Analyzing data",
"started_at": "2024-01-15T14:00:00Z"
}Get execution trace
Response: 200 OK
{
"traces": [
{
"timestamp": "2024-01-15T14:00:05Z",
"agent": "Research Agent",
"action": "web_search",
"result": "Found 15 relevant articles"
}
]
}Stop execution
Response: 200 OK
{
"job_id": "job_qwerty123",
"status": "stopped"
}Create and list tasks assigned to agents.
List tasks
Response: 200 OK
{
"tasks": [
{
"id": "task_001",
"description": "Generate report",
"agent_id": "agent_001",
"status": "completed"
}
]
}Create task
Request:
{
"agent_id": "agent_001",
"description": "Analyze competitor pricing",
"expected_output": "Markdown report",
"context": ["Previous analysis from Q3"]
}
Response: 201 Created
{
"id": "task_002",
"status": "created"
}Discover built-in tools and register custom tools.
List available tools
Response: 200 OK
{
"tools": [
{
"name": "web_search",
"description": "Search the web",
"category": "research"
},
{
"name": "file_reader",
"description": "Read files",
"category": "data"
}
]
}Register custom tool
Request:
{
"name": "salesforce_api",
"description": "Query Salesforce data",
"endpoint": "https://api.example.com/salesforce",
"auth_type": "bearer"
}
Response: 201 Created
{
"tool_id": "tool_custom_001",
"status": "registered"
}Fetch and clear short/long-term memory for a crew.
Get crew memory
Response: 200 OK
{
"short_term": [
{
"timestamp": "2024-01-15T10:00:00Z",
"content": "Customer prefers email communication"
}
],
"long_term": [
{
"category": "preferences",
"insights": ["Email preferred", "Weekly reports"]
}
]
}Clear memory
Request:
{
"type": "short_term" // or "long_term" or "all"
}
Response: 204 No ContentReal-time updates for task lifecycle, errors, and progress.
const ws = new WebSocket('wss://api.kasal.ai/v1/ws');
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'subscribe',
job_id: 'job_qwerty123'
}));
};// Task started
{
"type": "task_start",
"job_id": "job_qwerty123",
"task_id": "task_001",
"agent": "Research Agent"
}
// Task completed
{
"type": "task_complete",
"job_id": "job_qwerty123",
"task_id": "task_001",
"result": "Analysis complete"
}
// Error
{
"type": "error",
"job_id": "job_qwerty123",
"message": "Rate limit exceeded",
"code": "RATE_LIMIT"
}Standardized error responses and meanings.
| Code | Message | Description |
|---|---|---|
| 400 | Bad Request | Invalid parameters |
| 401 | Unauthorized | Invalid/expired token |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource doesn't exist |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Error | Server error |
| 503 | Service Unavailable | Maintenance mode |
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid crew configuration",
"details": {
"field": "agents",
"reason": "At least one agent required"
}
}
}Sandbox, Postman collection, and OpenAPI spec.
# Use sandbox for testing
curl -X POST https://sandbox-api.kasal.ai/v1/crews \
-H "Authorization: Bearer SANDBOX_TOKEN" \
-H "Content-Type: application/json" \
-d @crew.jsonBuild powerful integrations with Kasal API