Skip to content

Agents API

Manage agents and their configuration.

Endpoints

MethodEndpointDescription
GET/api/agentsList all agents
POST/api/agentsCreate new agent
GET/api/agents/{id}Get agent details
PUT/api/agents/{id}Update agent
DELETE/api/agents/{id}Delete agent

List Agents

bash
GET /api/agents

Response

json
{
  "agents": [
    {
      "id": "agent-123",
      "name": "support-bot",
      "description": "Customer support agent",
      "status": "active",
      "owner_email": "admin@example.com",
      "created_at": "2024-12-01T00:00:00Z",
      "updated_at": "2024-12-15T10:00:00Z"
    }
  ]
}

Create Agent

bash
POST /api/agents
Content-Type: application/json

Request Body

json
{
  "name": "support-bot",
  "description": "Customer support automation"
}

Response

json
{
  "id": "agent-123",
  "name": "support-bot",
  "description": "Customer support automation",
  "status": "active",
  "created_at": "2024-12-15T10:00:00Z"
}

Validation

FieldRules
nameRequired, unique, alphanumeric with hyphens
descriptionOptional, max 500 characters

Get Agent

bash
GET /api/agents/{id}

Response

json
{
  "id": "agent-123",
  "name": "support-bot",
  "description": "Customer support automation",
  "status": "active",
  "owner_email": "admin@example.com",
  "created_at": "2024-12-01T00:00:00Z",
  "updated_at": "2024-12-15T10:00:00Z",
  "settings": {
    "llm_provider": "workers-ai",
    "llm_model": "@cf/meta/llama-3.1-8b-instruct",
    "llm_temperature": 0.7
  },
  "stats": {
    "workflows": 5,
    "schedules": 10,
    "contacts": 100,
    "messages": 1500
  }
}

Update Agent

bash
PUT /api/agents/{id}
Content-Type: application/json

Request Body

json
{
  "name": "support-bot-v2",
  "description": "Updated description",
  "status": "active"
}

Response

json
{
  "id": "agent-123",
  "name": "support-bot-v2",
  "description": "Updated description",
  "status": "active",
  "updated_at": "2024-12-15T11:00:00Z"
}

Delete Agent

bash
DELETE /api/agents/{id}

Response

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

Notes

  • Cannot delete the default agent
  • Deletes all associated data (workflows, schedules, etc.)
  • Requires owner role

Agent Status

StatusDescription
activeAgent is running
pausedAgent is paused
disabledAgent is disabled

Get Accessible Agents

For authenticated users:

bash
GET /api/auth/agents

Response

json
{
  "agents": [
    {
      "id": "agent-123",
      "name": "support-bot",
      "role": "owner"
    },
    {
      "id": "agent-456",
      "name": "data-processor",
      "role": "admin"
    }
  ]
}

Manage Admins

List Admins

bash
GET /api/agents/{id}/admins

Add Admin

bash
POST /api/agents/{id}/admins
Content-Type: application/json

{
  "email": "user@example.com",
  "role": "admin"
}

Remove Admin

bash
DELETE /api/agents/{id}/admins/{adminId}

Errors

CodeDescription
400Invalid agent data
403Not authorized
404Agent not found
409Agent name already exists

Examples

Create and Configure Agent

bash
# Create agent
curl -X POST https://your-domain.com/api/agents \
  -H "Content-Type: application/json" \
  -d '{"name": "my-agent", "description": "My agent"}'

# Configure settings
curl -X PUT https://your-domain.com/api/agents/my-agent/settings \
  -H "Content-Type: application/json" \
  -d '{
    "llm_provider": "openai",
    "llm_model": "gpt-4",
    "llm_temperature": 0.5
  }'

List Active Agents

bash
curl "https://your-domain.com/api/agents?status=active"

Released under the MIT License.