Skip to main content

Agents API

Create, configure, and execute AI agents programmatically. All endpoints require authentication via API key or OAuth token.

Base path: /api/v1/agents

Endpoints

List Agents

GET /api/v1/agents

Returns all agents in the authenticated tenant. Supports pagination and filtering.

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerResults per page (default: 20, max: 100)
appIdstringFilter by workspace
teamIdstringFilter by team
statusstringFilter by status: available, paused, registered

Response:

{
"agents": [
{
"id": "agent_abc123",
"name": "Lead Qualifier",
"role": "Sales Development",
"model": "claude-sonnet-4-6",
"status": "available",
"teamId": "team_xyz",
"appId": "app_456",
"createdAt": "2026-04-01T10:00:00Z"
}
],
"total": 12,
"page": 1,
"limit": 20
}

Create Agent

POST /api/v1/agents
FieldTypeRequiredDescription
namestringYesAgent display name
appIdstringYesTarget workspace ID
rolestringNoAgent's organizational role
descriptionstringNoWhat the agent does
modelstringNoLLM model ID (default: claude-sonnet-4-6)
systemPromptstringNoCore behavior instructions
contextPromptstringNoCompany/customer context

Response (201):

{
"id": "agent_new123",
"name": "Lead Qualifier",
"role": "Sales Development",
"model": "claude-sonnet-4-6",
"status": "available",
"appId": "app_456",
"createdAt": "2026-04-12T14:30:00Z"
}

Get Agent

GET /api/v1/agents/:id

Returns full agent details including system prompt, tools, and configuration.

Update Agent

POST /api/v1/agents/:id

Update any agent field. Only provided fields are changed.

FieldTypeDescription
namestringDisplay name
rolestringOrganizational role
modelstringLLM model ID
systemPromptstringCore instructions
contextPromptstringCompany context
statusstringavailable or paused

Delete Agent

DELETE /api/v1/agents/:id

Permanently removes the agent. Conversations and audit logs are preserved.

Execute Agent

POST /api/v1/agents/:id/execute

Send a message and receive a response. The agent uses its full tool set, memory, and conversation context.

FieldTypeRequiredDescription
messagestringYesUser message
conversationIdstringNoResume existing conversation
enableToolsbooleanNoAllow tool use (default: true)
maxTokensintegerNoMax response tokens
streambooleanNoEnable streaming (default: false)

Response:

{
"output": "Based on the lead's profile, they match our ICP criteria...",
"conversationId": "conv_789",
"cost": 0.0034,
"tokenUsage": {
"inputTokens": 1250,
"outputTokens": 340
},
"toolCalls": [
{
"name": "hubspot_search",
"input": { "query": "company:Acme" },
"result": { "contacts": 3 }
}
],
"duration": 2340
}

Chat (Streaming)

POST /api/v1/agents/:id/chat

Same as execute but always streams the response via Server-Sent Events.

Pause / Resume Agent

POST /api/v1/agents/:id/pause
POST /api/v1/agents/:id/resume

Paused agents reject new executions. Existing conversations are preserved.

Execution History

GET /api/v1/agents/:id/runs

Returns paginated execution history with cost, duration, and tool calls.

ParameterTypeDescription
pageintegerPage number
limitintegerResults per page (max: 100)

Duplicate Agent

POST /api/v1/agents/:id/duplicate

Creates a copy of the agent with a new ID. System prompt, tools, and configuration are cloned.

Common Patterns

Create and Execute in One Flow

# 1. Create the agent
curl -X POST https://app.meetloyd.com/api/v1/agents \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "FAQ Assistant",
"appId": "app_456",
"model": "claude-sonnet-4-6",
"systemPrompt": "You are a helpful FAQ assistant for Acme Corp."
}'

# 2. Execute it
curl -X POST https://app.meetloyd.com/api/v1/agents/agent_new123/execute \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "message": "What is your return policy?" }'

Multi-Turn Conversation

Pass the conversationId from the first response to maintain context:

# First message
RESPONSE=$(curl -s -X POST .../agents/agent_123/execute \
-d '{ "message": "Research Acme Corp" }')

CONV_ID=$(echo $RESPONSE | jq -r '.conversationId')

# Follow-up (same conversation)
curl -X POST .../agents/agent_123/execute \
-d "{ \"message\": \"What about their competitors?\", \"conversationId\": \"$CONV_ID\" }"