Agent API Reference
The AgenticFlow Agents API provides comprehensive programmatic access to agent creation, management, and execution capabilities. Build, deploy, and orchestrate AI agents at scale with full enterprise-grade API functionality.
π― API Overview
The Agents API enables:
π§ Agent Lifecycle Management - Create, configure, update, and deploy agents
π¬ Conversation Management - Handle multi-turn conversations with memory
π Execution Control - Monitor, control, and optimize agent performance
π Integration Management - Configure tools, knowledge, and external connections
π Analytics & Monitoring - Track usage, performance, and business metrics
Base URL: https://api.agenticflow.ai/v1
Authentication: Bearer token (API key required)
Rate Limits: 1000 requests/minute (enterprise limits available)
π Authentication
API Key Setup
# Set your API key as environment variable
export AGENTICFLOW_API_KEY="af_live_your_api_key_here"
# Include in request headers
curl -H "Authorization: Bearer af_live_your_api_key_here" \
https://api.agenticflow.ai/v1/agents
Authentication Headers
{
"headers": {
"Authorization": "Bearer af_live_your_api_key_here",
"Content-Type": "application/json",
"User-Agent": "YourApp/1.0.0"
}
}
API Key Types:
Development Keys (
af_test_*
) - Sandbox environment, no chargesProduction Keys (
af_live_*
) - Live environment, usage charges applyWorkspace Keys (
af_ws_*
) - Workspace-specific access and limits
π€ Agent Management
Create Agent
Create a new AI agent with complete configuration.
Endpoint: POST /agents
const agent = await fetch('https://api.agenticflow.ai/v1/agents', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: "Customer Support Specialist",
description: "AI agent specialized in customer service and support",
model: "claude-3-5-sonnet-20241022",
system_prompt: "You are a helpful customer support agent. Always be polite, professional, and solution-focused.",
configuration: {
temperature: 0.3,
max_tokens: 2000,
response_format: "text"
},
knowledge_base_ids: ["kb_customer_policies", "kb_product_docs"],
tool_ids: ["tool_crm_lookup", "tool_order_status"],
tags: ["customer_service", "production"],
is_active: true
})
});
const response = await agent.json();
Request Body:
{
"name": "string (required)",
"description": "string (optional)",
"model": "string (required)",
"system_prompt": "string (optional)",
"configuration": {
"temperature": "number (0-1)",
"max_tokens": "number (1-4000)",
"response_format": "text|json_object",
"timeout": "number (seconds)"
},
"knowledge_base_ids": ["string"],
"tool_ids": ["string"],
"workflow_ids": ["string"],
"tags": ["string"],
"is_active": "boolean",
"metadata": "object"
}
Response:
{
"id": "agent_clx8k2n4m0001js0h3q5j4k8r",
"name": "Customer Support Specialist",
"description": "AI agent specialized in customer service and support",
"model": "claude-3-5-sonnet-20241022",
"system_prompt": "You are a helpful customer support agent...",
"configuration": {
"temperature": 0.3,
"max_tokens": 2000,
"response_format": "text"
},
"knowledge_base_ids": ["kb_customer_policies", "kb_product_docs"],
"tool_ids": ["tool_crm_lookup", "tool_order_status"],
"tags": ["customer_service", "production"],
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z",
"workspace_id": "ws_main_workspace"
}
List Agents
Retrieve all agents with filtering and pagination.
Endpoint: GET /agents
const agents = await fetch('https://api.agenticflow.ai/v1/agents?' + new URLSearchParams({
limit: '50',
offset: '0',
tags: 'customer_service,production',
is_active: 'true',
sort: 'created_at_desc'
}), {
headers: {
'Authorization': 'Bearer af_live_your_api_key'
}
});
const response = await agents.json();
Query Parameters:
limit
(integer, 1-100): Number of agents to return (default: 50)offset
(integer): Number of agents to skip (default: 0)tags
(string): Comma-separated list of tags to filter byis_active
(boolean): Filter by active statussearch
(string): Search in agent names and descriptionsmodel
(string): Filter by AI modelsort
(string): Sort order (created_at_asc
,created_at_desc
,name_asc
,name_desc
)
Response:
{
"data": [
{
"id": "agent_clx8k2n4m0001js0h3q5j4k8r",
"name": "Customer Support Specialist",
"description": "AI agent specialized in customer service and support",
"model": "claude-3-5-sonnet-20241022",
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"tags": ["customer_service", "production"]
}
],
"pagination": {
"total": 127,
"limit": 50,
"offset": 0,
"has_more": true
}
}
Get Agent
Retrieve detailed information about a specific agent.
Endpoint: GET /agents/{agent_id}
const agent = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r', {
headers: {
'Authorization': 'Bearer af_live_your_api_key'
}
});
const response = await agent.json();
Response (full agent object with all configuration details)
Update Agent
Modify an existing agent's configuration.
Endpoint: PUT /agents/{agent_id}
const updatedAgent = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r', {
method: 'PUT',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
system_prompt: "Updated system prompt with new instructions...",
configuration: {
temperature: 0.5,
max_tokens: 3000
},
tool_ids: ["tool_crm_lookup", "tool_order_status", "tool_knowledge_search"]
})
});
Request Body: Same as create agent, all fields optional (only provided fields will be updated)
Delete Agent
Permanently delete an agent (irreversible action).
Endpoint: DELETE /agents/{agent_id}
const deletion = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer af_live_your_api_key'
}
});
// Returns 204 No Content on success
π¬ Conversation Management
Start Conversation
Begin a new conversation with an agent.
Endpoint: POST /agents/{agent_id}/conversations
const conversation = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/conversations', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: "Hello! I need help with my recent order #12345. It seems to be delayed.",
context: {
user_id: "user_12345",
session_id: "session_abc123",
metadata: {
order_id: "12345",
customer_tier: "premium"
}
},
options: {
stream: false,
include_tool_calls: true,
max_turns: 10
}
})
});
const response = await conversation.json();
Request Body:
{
"message": "string (required)",
"context": {
"user_id": "string (optional)",
"session_id": "string (optional)",
"metadata": "object (optional)"
},
"options": {
"stream": "boolean (default: false)",
"include_tool_calls": "boolean (default: true)",
"max_turns": "number (default: 100)",
"temperature_override": "number (optional)"
}
}
Response:
{
"conversation_id": "conv_clx8k2n4m0001js0h3q5j4k8r",
"message": {
"id": "msg_clx8k2n4m0002js0h3q5j4k8s",
"role": "assistant",
"content": "I'd be happy to help you check on your order #12345. Let me look up the current status for you.",
"tool_calls": [
{
"id": "call_order_status_12345",
"function": "order_status",
"arguments": {
"order_id": "12345"
},
"result": {
"status": "in_transit",
"expected_delivery": "2024-01-18",
"tracking_number": "1Z999AA123456789"
}
}
],
"created_at": "2024-01-15T10:35:22Z"
},
"usage": {
"prompt_tokens": 245,
"completion_tokens": 87,
"total_tokens": 332,
"cost": 0.00234
}
}
Continue Conversation
Add a message to an existing conversation.
Endpoint: POST /conversations/{conversation_id}/messages
const message = await fetch('https://api.agenticflow.ai/v1/conversations/conv_clx8k2n4m0001js0h3q5j4k8r/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: "That's great! Can you also check if I can expedite the shipping?",
options: {
include_context: true,
temperature_override: 0.2
}
})
});
Get Conversation History
Retrieve the complete conversation thread.
Endpoint: GET /conversations/{conversation_id}
const conversation = await fetch('https://api.agenticflow.ai/v1/conversations/conv_clx8k2n4m0001js0h3q5j4k8r', {
headers: {
'Authorization': 'Bearer af_live_your_api_key'
}
});
const response = await conversation.json();
Response:
{
"id": "conv_clx8k2n4m0001js0h3q5j4k8r",
"agent_id": "agent_clx8k2n4m0001js0h3q5j4k8r",
"messages": [
{
"id": "msg_1",
"role": "user",
"content": "Hello! I need help with my recent order #12345...",
"created_at": "2024-01-15T10:35:00Z"
},
{
"id": "msg_2",
"role": "assistant",
"content": "I'd be happy to help you check on your order...",
"tool_calls": [...],
"created_at": "2024-01-15T10:35:22Z"
}
],
"context": {
"user_id": "user_12345",
"session_id": "session_abc123"
},
"created_at": "2024-01-15T10:35:00Z",
"updated_at": "2024-01-15T10:36:45Z"
}
Streaming Conversations
Real-time streaming responses for live conversations.
const response = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/conversations', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: "Explain quantum computing in simple terms",
options: {
stream: true
}
})
});
// Handle Server-Sent Events
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { value, done } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
const data = JSON.parse(line.slice(6));
if (data.type === 'message_delta') {
process.stdout.write(data.content);
} else if (data.type === 'tool_call') {
console.log('\n[Tool Call]', data.function_name);
} else if (data.type === 'message_complete') {
console.log('\n[Usage]', data.usage);
}
}
}
}
Streaming Event Types:
message_start
- Conversation beginningmessage_delta
- Incremental content chunkstool_call_start
- Tool execution beginningtool_call_result
- Tool execution resultmessage_complete
- Response finished with metadata
π§ Agent Configuration
Update Agent Configuration
Modify agent settings without changing core properties.
Endpoint: PATCH /agents/{agent_id}/configuration
const config = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/configuration', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
temperature: 0.7,
max_tokens: 3000,
response_format: "json_object",
timeout: 30,
custom_settings: {
"persona": "friendly_expert",
"language_style": "professional_casual",
"response_length": "detailed"
}
})
});
Manage Agent Knowledge Base
Add or remove knowledge bases from an agent.
Endpoint: POST /agents/{agent_id}/knowledge
// Add knowledge bases
const knowledge = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/knowledge', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
knowledge_base_ids: ["kb_new_policies", "kb_troubleshooting"],
operation: "add"
})
});
// Remove knowledge bases
const removal = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/knowledge', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
knowledge_base_ids: ["kb_old_policies"],
operation: "remove"
})
});
Manage Agent Tools
Configure tools and integrations for an agent.
Endpoint: POST /agents/{agent_id}/tools
const tools = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/tools', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
tools: [
{
id: "tool_slack_notification",
configuration: {
channel: "#customer-alerts",
mention_team: true
}
},
{
id: "tool_crm_update",
configuration: {
auto_create_tickets": true,
priority_mapping": "customer_tier_based"
}
}
],
operation: "replace"
})
});
π Analytics and Monitoring
Agent Performance Metrics
Get detailed performance analytics for an agent.
Endpoint: GET /agents/{agent_id}/analytics
const analytics = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/analytics?' + new URLSearchParams({
start_date: '2024-01-01',
end_date: '2024-01-31',
granularity: 'daily',
metrics: 'conversations,tokens,cost,satisfaction'
}), {
headers: {
'Authorization': 'Bearer af_live_your_api_key'
}
});
const response = await analytics.json();
Query Parameters:
start_date
(string): Start date (YYYY-MM-DD)end_date
(string): End date (YYYY-MM-DD)granularity
(string):hourly
,daily
,weekly
,monthly
metrics
(string): Comma-separated metrics to include
Response:
{
"agent_id": "agent_clx8k2n4m0001js0h3q5j4k8r",
"period": {
"start_date": "2024-01-01",
"end_date": "2024-01-31"
},
"metrics": {
"conversations": {
"total": 1247,
"successful": 1198,
"failed": 49,
"average_length": 4.2,
"success_rate": 0.961
},
"tokens": {
"total_tokens": 892340,
"prompt_tokens": 534220,
"completion_tokens": 358120,
"average_per_conversation": 715
},
"cost": {
"total_cost": 23.45,
"average_per_conversation": 0.019,
"cost_breakdown": {
"model_usage": 21.30,
"tool_calls": 1.89,
"knowledge_base": 0.26
}
},
"satisfaction": {
"average_rating": 4.6,
"total_ratings": 892,
"rating_distribution": {
"5": 623,
"4": 189,
"3": 56,
"2": 18,
"1": 6
}
}
},
"time_series": [
{
"date": "2024-01-01",
"conversations": 42,
"tokens": 28934,
"cost": 0.78,
"average_satisfaction": 4.7
}
]
}
Usage Tracking
Track detailed usage metrics for billing and optimization.
Endpoint: GET /agents/{agent_id}/usage
const usage = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/usage?' + new URLSearchParams({
period: 'last_30_days',
breakdown: 'by_model,by_tool,by_user'
}), {
headers: {
'Authorization': 'Bearer af_live_your_api_key'
}
});
Real-Time Monitoring
Monitor agent health and performance in real-time.
Endpoint: GET /agents/{agent_id}/status
const status = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/status', {
headers: {
'Authorization': 'Bearer af_live_your_api_key'
}
});
const response = await status.json();
Response:
{
"agent_id": "agent_clx8k2n4m0001js0h3q5j4k8r",
"status": "active",
"health": "healthy",
"current_load": {
"active_conversations": 23,
"queued_requests": 2,
"average_response_time": "1.2s"
},
"performance": {
"success_rate_24h": 0.98,
"average_rating_24h": 4.7,
"error_rate_24h": 0.02
},
"resource_usage": {
"credits_used_today": 1247,
"quota_remaining": 8753,
"rate_limit_status": "normal"
},
"last_activity": "2024-01-15T10:45:23Z"
}
π Batch Operations
Bulk Agent Management
Manage multiple agents in a single API call.
Endpoint: POST /agents/batch
const batchOperation = await fetch('https://api.agenticflow.ai/v1/agents/batch', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
operation: "update",
agents: [
{
id: "agent_1",
changes: {
is_active: false,
tags: ["deprecated"]
}
},
{
id: "agent_2",
changes: {
system_prompt: "Updated prompt for agent 2",
configuration: {
temperature: 0.5
}
}
}
],
options: {
continue_on_error: true,
return_details: true
}
})
});
const response = await batchOperation.json();
Response:
{
"batch_id": "batch_clx8k2n4m0001js0h3q5j4k8r",
"status": "completed",
"results": [
{
"agent_id": "agent_1",
"status": "success",
"message": "Agent updated successfully"
},
{
"agent_id": "agent_2",
"status": "error",
"message": "Invalid temperature value",
"error_code": "INVALID_CONFIGURATION"
}
],
"summary": {
"total": 2,
"successful": 1,
"failed": 1
}
}
Bulk Conversation Processing
Process multiple conversations simultaneously.
Endpoint: POST /conversations/batch
const batchConversations = await fetch('https://api.agenticflow.ai/v1/conversations/batch', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
conversations: [
{
agent_id: "agent_clx8k2n4m0001js0h3q5j4k8r",
message: "Process this customer feedback: Customer loves the new features!",
context: { customer_id: "cust_123" }
},
{
agent_id: "agent_clx8k2n4m0001js0h3q5j4k8r",
message: "Analyze this support ticket: Website is loading slowly",
context: { ticket_id: "tick_456" }
}
],
options: {
parallel_processing: true,
max_concurrent: 10
}
})
});
βοΈ Advanced Features
Agent Templates
Create and manage reusable agent templates.
Endpoint: POST /agent-templates
const template = await fetch('https://api.agenticflow.ai/v1/agent-templates', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: "Customer Support Agent Template",
description: "Standard template for customer support agents",
category: "customer_service",
template: {
model: "claude-3-5-sonnet-20241022",
system_prompt: "You are a professional customer support agent...",
configuration: {
temperature: 0.3,
max_tokens: 2000
},
required_tools: ["tool_crm_lookup", "tool_order_status"],
recommended_knowledge: ["kb_customer_policies", "kb_faq"]
},
variables: {
"company_name": {
"type": "string",
"required": true,
"description": "Name of the company"
},
"support_email": {
"type": "string",
"required": false,
"description": "Support team email address"
}
}
})
});
Agent Deployment
Deploy agents to different environments.
Endpoint: POST /agents/{agent_id}/deploy
const deployment = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/deploy', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
environment: "production",
configuration: {
auto_scaling: true,
max_concurrent_conversations: 100,
health_check_interval: 30,
deployment_strategy: "blue_green"
},
notifications: {
deployment_complete: ["[email protected]"],
deployment_failed: ["[email protected]"]
}
})
});
A/B Testing
Set up A/B tests for agent optimization.
Endpoint: POST /agents/{agent_id}/experiments
const experiment = await fetch('https://api.agenticflow.ai/v1/agents/agent_clx8k2n4m0001js0h3q5j4k8r/experiments', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: "Temperature Optimization Test",
description: "Testing different temperature values for response quality",
variants: [
{
name: "control",
weight: 50,
configuration: {
temperature: 0.3
}
},
{
name: "warmer",
weight: 50,
configuration: {
temperature: 0.7
}
}
],
success_metrics: ["satisfaction_rating", "conversation_completion_rate"],
duration_days: 14,
minimum_sample_size: 1000
})
});
π SDK Examples
Python SDK
import agenticflow
# Initialize client
client = agenticflow.Client(api_key="af_live_your_api_key")
# Create agent
agent = client.agents.create(
name="Support Agent",
model="claude-3-5-sonnet-20241022",
system_prompt="You are a helpful support agent.",
knowledge_base_ids=["kb_support_docs"]
)
# Start conversation
conversation = agent.conversations.create(
message="How do I reset my password?"
)
print(f"Agent response: {conversation.message.content}")
# Continue conversation
follow_up = conversation.messages.create(
message="I tried that but it didn't work."
)
print(f"Follow-up response: {follow_up.content}")
Node.js SDK
const AgenticFlow = require('agenticflow');
// Initialize client
const client = new AgenticFlow({
apiKey: 'af_live_your_api_key'
});
async function main() {
// Create agent
const agent = await client.agents.create({
name: 'Support Agent',
model: 'claude-3-5-sonnet-20241022',
systemPrompt: 'You are a helpful support agent.',
knowledgeBaseIds: ['kb_support_docs']
});
// Start conversation with streaming
const conversation = await client.agents.conversations.create(agent.id, {
message: 'How do I reset my password?',
options: { stream: true }
});
// Handle streaming response
for await (const chunk of conversation) {
if (chunk.type === 'message_delta') {
process.stdout.write(chunk.content);
}
}
}
main().catch(console.error);
β Error Handling
Error Response Format
{
"error": {
"code": "INVALID_REQUEST",
"message": "The model 'invalid-model' is not supported",
"details": {
"field": "model",
"supported_models": ["gpt-4", "claude-3-5-sonnet", "gemini-pro"]
},
"request_id": "req_clx8k2n4m0001js0h3q5j4k8r"
}
}
Common Error Codes
INVALID_REQUEST
(400) - Malformed request or invalid parametersUNAUTHORIZED
(401) - Invalid or missing API keyFORBIDDEN
(403) - Insufficient permissionsNOT_FOUND
(404) - Resource not foundRATE_LIMITED
(429) - Too many requestsQUOTA_EXCEEDED
(429) - Credit or usage limit reachedINTERNAL_ERROR
(500) - Server errorSERVICE_UNAVAILABLE
(503) - Temporary service issue
Error Handling Best Practices
async function createAgentWithRetry(agentData, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await fetch('https://api.agenticflow.ai/v1/agents', {
method: 'POST',
headers: {
'Authorization': 'Bearer af_live_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify(agentData)
});
if (!response.ok) {
const error = await response.json();
// Don't retry client errors (4xx)
if (response.status >= 400 && response.status < 500) {
throw new Error(`Client Error: ${error.error.message}`);
}
// Retry server errors (5xx) and rate limits
if (attempt === maxRetries) {
throw new Error(`Max retries exceeded: ${error.error.message}`);
}
// Exponential backoff
await new Promise(resolve => setTimeout(resolve, Math.pow(2, attempt) * 1000));
continue;
}
return await response.json();
} catch (error) {
if (attempt === maxRetries) {
throw error;
}
}
}
}
π Next Steps & Resources
π Continue Learning
Workflows API - Automate complex business processes
Knowledge API - Manage knowledge bases and RAG systems
Integrations API - Connect to external services
π οΈ Development Tools
API Playground - Interactive API testing
Postman Collection - Pre-built API requests
OpenAPI Schema - Complete API specification
π¬ Developer Support
Developer Discord - Community support and discussions
API Status Page - Real-time API status and incidents
Developer Support - Technical assistance and guidance
π€ The Agents API provides complete programmatic control over AgenticFlow's sophisticated AI agent capabilities. From simple chatbots to complex enterprise automation systems, you have the power to build, deploy, and scale AI agents that transform how your business operates.
Build the future of AI automation, one API call at a time.
Last updated
Was this helpful?