Skip to content

Agents API

Create, read, update, and delete agents.

List Agents

http
GET /api/v1/agents

Query Parameters

ParameterTypeDescription
limitnumberMax results (default: 20, max: 100)
offsetnumberPagination offset
tagsstringComma-separated tags to filter
statusstringFilter by status (active, draft, archived)

Response

json
{
  "data": [
    {
      "id": "agent_123",
      "name": "Customer Support",
      "content": "You are a helpful...",
      "llmModel": "gpt-4o",
      "description": "Main support chatbot",
      "tags": ["support", "production"],
      "status": "active",
      "createdAt": "2025-01-15T10:00:00Z",
      "updatedAt": "2025-01-20T14:30:00Z"
    }
  ],
  "pagination": {
    "total": 15,
    "limit": 20,
    "offset": 0
  }
}

Get Agent

http
GET /api/v1/agents/:id

Response

json
{
  "id": "agent_123",
  "name": "Customer Support",
  "content": "You are a helpful customer support agent...",
  "llmModel": "gpt-4o",
  "description": "Main support chatbot",
  "tags": ["support", "production"],
  "status": "active",
  "createdAt": "2025-01-15T10:00:00Z",
  "updatedAt": "2025-01-20T14:30:00Z"
}

Create Agent

http
POST /api/v1/agents

Request Body

json
{
  "name": "Customer Support",
  "content": "You are a helpful customer support agent...",
  "llmModel": "gpt-4o",
  "description": "Main support chatbot",
  "tags": ["support", "production"]
}

Required Fields

FieldTypeDescription
namestringDisplay name
contentstringSystem prompt
llmModelstringTarget model (gpt-4o, claude-3.5-sonnet, etc.)

Optional Fields

FieldTypeDescription
descriptionstringWhat this agent does
tagsstring[]Organization tags
temperaturenumberModel temperature (0-2)
maxTokensnumberMax response tokens

Response

json
{
  "id": "agent_456",
  "name": "Customer Support",
  "content": "You are a helpful customer support agent...",
  "llmModel": "gpt-4o",
  "status": "active",
  "createdAt": "2025-01-20T14:30:00Z",
  "updatedAt": "2025-01-20T14:30:00Z"
}

Status: 201 Created

Update Agent

http
PATCH /api/v1/agents/:id

Request Body

json
{
  "content": "Updated system prompt...",
  "tags": ["support", "v2"]
}

All fields are optional. Only provided fields are updated.

Response

json
{
  "id": "agent_123",
  "name": "Customer Support",
  "content": "Updated system prompt...",
  "updatedAt": "2025-01-20T15:00:00Z"
}

Delete Agent

http
DELETE /api/v1/agents/:id

Response

json
{
  "success": true,
  "message": "Agent deleted"
}

Status: 200 OK

Get Agent Status

http
GET /api/v1/agents/:id/status

Get agent details including optimization state and performance metrics.

Response

json
{
  "id": "agent_123",
  "name": "Customer Support",
  "status": "active",
  "optimizationState": "idle",
  "metrics": {
    "conversationCount": 1247,
    "taskCompletionRate": 87.3,
    "avgSentiment": 0.72
  },
  "lastOptimized": "2025-01-18T10:00:00Z"
}

Get Agent Insights

http
GET /api/v1/agents/:id/insights

Get aggregated performance insights for an agent based on conversation data.

Query Parameters

ParameterTypeDefaultDescription
daysnumber30Number of days to look back (7, 30, 90, or all)

Response

json
{
  "agentId": "agent_123",
  "period": {
    "days": 30,
    "from": "2024-12-21T00:00:00Z",
    "to": "2025-01-20T23:59:59Z"
  },
  "summary": {
    "totalConversations": 1247,
    "completedConversations": 1089,
    "abandonedConversations": 158,
    "completionRate": 87.3
  },
  "metrics": {
    "taskCompletion": {
      "rate": 82.5,
      "trend": "+3.2%"
    },
    "sentiment": {
      "average": 0.72,
      "distribution": {
        "positive": 68,
        "neutral": 24,
        "negative": 8
      }
    },
    "avgResponseTime": 1.2,
    "avgConversationLength": 6.4
  },
  "topIssues": [
    {
      "issue": "Unclear refund policy explanation",
      "frequency": 23,
      "impact": "high"
    }
  ],
  "recommendations": [
    "Consider adding specific refund timelines to reduce follow-up questions"
  ]
}

Error Responses

Not Found

json
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Agent not found"
  }
}

Status: 404 Not Found

Validation Error

json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body",
    "details": {
      "llmModel": "Must be a valid model name"
    }
  }
}

Status: 400 Bad Request