Learn how to integrate FlowGent's powerful AI agents into your applications using our REST API.
Welcome to the FlowGent API documentation. This API allows you to integrate FlowGent's powerful AI agent capabilities into your own applications.
https://flowgent.ai/api/public/
With the FlowGent API, you can:
Authentication with the FlowGent API is done using API keys. Your API key should be included in the Authorization
header of all requests.
You can create API keys in the FlowGent Settings. API keys are sensitive credentials and should be kept secure.
Authorization: YOUR_API_KEY
Never expose your API keys in client-side code or commit them to version control. Consider using environment variables or a secure secrets management system.
curl -X GET \ -H "Content-Type: application/json" \ -H "Authorization: YOUR_API_KEY" \ https://flowgent.ai/api/public/agent
/api/public/agent/:agent_id/chat
Send messages to an agent and get a response. This endpoint supports both synchronous and asynchronous processing through an optional callback URL.
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
Parameter | Type | Description |
---|---|---|
agent_id | string | The agent&aposs unique identifier |
The messages field can be provided in three different formats:
{ "messages": "Hello, I have a question about my order", "thread_id": "thread_123456", // Optional "callback_url": "https://your-domain.com/webhook" // Optional }
{ "messages": { "role": "user", "content": "Hello, I have a question about my order" }, "thread_id": "thread_123456", // Optional "callback_url": "https://your-domain.com/webhook" // Optional }
{ "messages": [ { "role": "user", "content": "Hello, I have a question about my order" } ], "thread_id": "thread_123456", // Optional "callback_url": "https://your-domain.com/webhook" // Optional }
Parameter | Type | Required | Description |
---|---|---|---|
messages | string | object | array | Yes | Can be a string, a message object, or an array of message objects |
thread_id | string | No | Optional thread ID for continuing a conversation |
callback_url | string | No | URL to receive the response asynchronously |
This endpoint may return HTTP 200 status even when there are errors in the execution. Always check the response body forstatusCode
and the results of any tool executions.
{ "statusCode": 200, "body": { "agent_id": "agent_123abc", "conversation_history": [ { "role": "user", "content": "Hello, I have a question about my order" }, { "role": "assistant", "content": "I'd be happy to help with your order. Could you please provide your order number?" } ], "metadata": { "id": "meta_xyz789", "model": "gpt-4", "timestamp": "2024-03-21T14:30:00Z", "tool_calls": {}, "execution_time": 2500, "used_credits": 1, "thread_id": "thread_123456" } } }
{ "statusCode": 402, "body": { "agent_id": "agent_123abc", "message": "No credits available", "error": "No credits available" } }
{ "statusCode": 503, "body": { "agent_id": "agent_123abc", "message": "Service temporarily unavailable", "error": "AI provider is currently experiencing high traffic" } }
{ "statusCode": 500, "body": { "error": "An unexpected error occurred while processing your request" } }
When using the callback_url parameter, you'll receive an immediate acknowledgement:
{ "message": "Request accepted and being processed asynchronously", "status": "processing" }
/api/public/agent/:agent_id/usage
Get credit usage statistics for an agent. By default, returns data for the last 7 days (ending yesterday). You can optionally specify a custom date range using query parameters.
Note: Usage tracking is only active from May 28, 2025 onwards. Data before this date will show 0 credits used.
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
Parameter | Type | Description |
---|---|---|
agent_id | string | The agent's unique identifier |
Optional parameters to specify a custom date range. If not provided, defaults to the last 7 days ending yesterday.
Parameter | Type | Required | Description |
---|---|---|---|
start_date | string | No* | Start date for the query range in YYYY-MM-DD format |
end_date | string | No* | End date for the query range in YYYY-MM-DD format |
* If only start_date is provided, yesterday will be used as end_date. If only end_date is provided, an error will be returned. The date range cannot exceed 31 days, and the end_date cannot be today or in the future (data is only available up to yesterday).
// Default (last 7 days) GET /api/public/agent/66a72b17-cb03-4397-ab2a-1eef13847737/usage // Custom date range (both dates) GET /api/public/agent/66a72b17-cb03-4397-ab2a-1eef13847737/usage?start_date=2025-05-20&end_date=2025-05-26 // Start date only (end_date will be yesterday) GET /api/public/agent/66a72b17-cb03-4397-ab2a-1eef13847737/usage?start_date=2025-05-20
{ "agent_id": "66a72b17-cb03-4397-ab2a-1eef13847737", "time_range": { "start": "2025-05-20T00:00:00.000Z", "end": "2025-05-26T23:59:59.999Z" }, "usage": { "total_credits_used": 3, "daily_breakdown": [ { "date": "2025-05-26", "credits_used": 1 }, { "date": "2025-05-25", "credits_used": 0 }, { "date": "2025-05-24", "credits_used": 2 }, { "date": "2025-05-23", "credits_used": 0 }, { "date": "2025-05-22", "credits_used": 0 }, { "date": "2025-05-21", "credits_used": 0 }, { "date": "2025-05-20", "credits_used": 0 } ] }, "note": "Endpoint active from 28 May 2025 onwards" }
Field | Type | Description |
---|---|---|
agent_id | string | The agent's unique identifier |
time_range | object | Start and end timestamps for the queried period |
usage.total_credits_used | number | Total credits consumed in the time period |
usage.daily_breakdown | array | Daily credit usage breakdown, sorted by date (newest first) |
daily_breakdown[].date | string | Date in YYYY-MM-DD format |
daily_breakdown[].credits_used | number | Credits consumed on this specific date |
note | string | Optional note about data availability (appears when querying dates before May 28, 2025) |
// Missing API Key (401) { "error": "API key is required", "message": "Please provide an API key in the Authorization header" } // Invalid API Key (401) { "error": "Invalid API key", "message": "The provided API key is not valid" } // Access Denied (403) { "error": "Access denied", "message": "This agent does not belong to your organisation" } // Invalid Agent ID (400) { "error": "agent_id is required and must be a non-empty string" } // Missing Start Date When End Date Provided (400) { "error": "Invalid date range", "message": "start_date is required when end_date is provided (format: YYYY-MM-DD)" } // Invalid Date Format (400) { "error": "Invalid date format", "message": "Dates must be in YYYY-MM-DD format" } // Invalid Dates (400) { "error": "Invalid dates", "message": "Provided dates are not valid" } // Start Date After End Date (400) { "error": "Invalid date range", "message": "start_date must not be after end_date" } // End Date Too Recent (400) { "error": "Invalid end date", "message": "end_date cannot be today or in the future. Data is only available up to yesterday." } // Date Range Too Large (400) { "error": "Date range too large", "message": "Date range cannot exceed 31 days" } // Internal Server Error (500) { "error": "Internal server error" }
/api/public/agent/:agent_id/waba
Send WhatsApp templates using your agent through the WhatsApp Business API.
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
Parameter | Type | Description |
---|---|---|
agent_id | string | The agent's unique identifier |
{ "recipient_phone_number": "31612345678", "template_name": "order_update", "language": "en_US", "customer_name": "John Doe", "parameters": [ { "type": "header", "parameters": [ { "type": "image", "image": { "link": "https://whatsapp_image_template" } } ] }, { "type": "body", "parameters": [ { "type": "text", "text": "ABC123" }, { "type": "text", "text": "Shipped" } ] } ] }
Parameter | Type | Required | Description |
---|---|---|---|
recipient_phone_number | string | Yes | Recipient's phone number with country code |
template_name | string | Yes | Name of the WhatsApp template to use |
language | string | Yes | Language code (e.g., en_US, en, nl_NL) |
customer_name | string | No | Name of the customer (for new customers) |
parameters | array | No | Template parameters for dynamic content |
For detailed information about formatting template parameters, please refer to the WhatsApp Cloud API documentation.
{ "messaging_product": "whatsapp", "contacts": [{ "input": "PHONE_NUMBER", "wa_id": "WHATSAPP_ID" }], "messages": [{ "id": "wamid.ID" }] }
{ "error": "Invalid API key", "message": "The provided API key is not valid" } { "error": "Missing required fields", "message": "recipient_phone_number and template_name are required" } { "error": "WhatsApp connection not found", "message": "No WhatsApp connection found for this agent" } { "error": "Internal server error" }
/api/public/knowledge
Create a new knowledge item and link it to the provided agent(s).
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
{ "content": "string", "name": "string", "agent_ids": ["uuid"] | "uuid", "description_to_index_on": "string" // Optional }
Parameter | Type | Required | Description |
---|---|---|---|
content | string | Yes | The knowledge content to store and index (max 4000 characters) |
name | string | No | Display name for the knowledge item |
agent_ids | array | string | Yes | Agent IDs to link this knowledge to (single string or array) |
description_to_index_on | string | No | Custom description to embed instead of content |
curl -X POST "https://flowgent.ai/api/public/knowledge" \ -H "Authorization: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content": "Our premium support includes 24/7 chat, phone support, and dedicated account management.", "name": "Premium Support Information", "agent_ids": ["agent-uuid-1"], "description_to_index_on": "Premium support features and benefits" }'
{ "id": "item-uuid-123", "name": "Premium Support Information", "created_at": "2023-12-29T10:00:00Z", "updated_at": "2023-12-29T10:00:00Z", "source": "api", "linked_agents": ["agent-uuid-1"] }
// Missing API Key (401) { "error": "API key is required", "message": "Please provide an API key in the Authorization header" } // Invalid API Key (401) { "error": "Invalid API key", "message": "The provided API key is not valid" } // Missing Content (400) { "error": "content is required and must be a non-empty string" } // Missing Agent IDs (400) { "error": "agent_ids is required and must be a non-empty string or array" } // Content Too Long (400) { "error": "Content exceeds character limit", "message": "The content field must be 4000 characters or less." } // Invalid Agent ID (403) { "error": "Access denied", "message": "One or more agents do not belong to your organisation" } // Usage Limit Reached (402) { "error": "Usage limit reached", "message": "You have reached the maximum number of items in one of your knowledge bases. Please upgrade your plan to add more items.", "minimalPlan": "..." } // Internal Server Error (500) { "error": "Internal server error" }
/api/public/knowledge
Retrieve a paginated list of knowledge items created via API for your organization. Optionally filter by a specific agent.
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
Parameter | Type | Required | Description |
---|---|---|---|
agent_id | string | No | Filter by specific agent |
page | integer | No | Page number (default: 1) |
limit | integer | No | Items per page (default: 20, max: 100) |
curl -X GET "https://flowgent.ai/api/public/knowledge?page=1&limit=10" \ -H "Authorization: YOUR_API_KEY"
{ "knowledge_items": [ { "id": "item-uuid-123", "name": "Premium Support Information", "created_at": "2023-12-29T10:00:00Z", "updated_at": "2023-12-29T10:00:00Z", "source": "api", "linked_agents": ["agent-uuid-1"] } ], "pagination": { "current_page": 1, "limit": 10, "total_count": 1, "total_pages": 1, "has_next_page": false, "has_previous_page": false } }
// Missing API Key (401) { "error": "API key is required", "message": "Please provide an API key in the Authorization header" } // Invalid API Key (401) { "error": "Invalid API key", "message": "The provided API key is not valid" } // Invalid Agent ID (403) { "error": "Access denied", "message": "Agent does not belong to your organisation" } // Invalid Pagination (400) { "error": "Invalid pagination parameters", "message": "Page must be a positive integer and limit must be between 1 and 100" } // Internal Server Error (500) { "error": "Internal server error" }
/api/public/knowledge/:id
Retrieve a specific knowledge item by ID.
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
Parameter | Type | Description |
---|---|---|
id | string | The knowledge item's unique identifier |
curl -X GET "https://flowgent.ai/api/public/knowledge/item-uuid-123" \ -H "Authorization: YOUR_API_KEY"
{ "id": "item-uuid-123", "name": "Premium Support Information", "content": "Our premium support includes 24/7 chat, phone support, and dedicated account management.", "created_at": "2023-12-29T10:00:00Z", "updated_at": "2023-12-29T10:00:00Z", "source": "api", "linked_agents": ["agent-uuid-1"] }
// Missing API Key (401) { "error": "API key is required", "message": "Please provide an API key in the Authorization header" } // Invalid API Key (401) { "error": "Invalid API key", "message": "The provided API key is not valid" } // Knowledge Item Not Found (404) { "error": "Knowledge item not found or access denied" } // Internal Server Error (500) { "error": "Internal server error" }
/api/public/knowledge/:id
Update an existing knowledge item. You can update the name, content, agent links, or description for embedding.
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
Parameter | Type | Description |
---|---|---|
id | string | The knowledge item's unique identifier |
All fields are optional. Only provide the fields you want to update:
{ "name": "string", "content": "string", "agent_ids": ["uuid"] | "uuid", "description_to_index_on": "string" }
Parameter | Type | Required | Description |
---|---|---|---|
name | string | No | Update the display name |
content | string | No | Update the content (max 4000 characters, triggers re-embedding) |
agent_ids | array | string | No | Update agent associations |
description_to_index_on | string | No | Update custom description for embedding |
curl -X PATCH "https://flowgent.ai/api/public/knowledge/item-uuid-123" \ -H "Authorization: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Updated Premium Support Information", "content": "Our premium support now includes 24/7 chat, phone support, dedicated account management, and priority bug fixes.", "agent_ids": ["agent-uuid-1", "agent-uuid-2"] }'
{ "id": "item-uuid-123", "name": "Updated Premium Support Information", "created_at": "2023-12-29T10:00:00Z", "updated_at": "2023-12-29T10:00:00Z", "source": "api", "linked_agents": ["agent-uuid-1", "agent-uuid-2"] }
// Missing API Key (401) { "error": "API key is required", "message": "Please provide an API key in the Authorization header" } // Invalid API Key (401) { "error": "Invalid API key", "message": "The provided API key is not valid" } // Knowledge Item Not Found (404) { "error": "Knowledge item not found or access denied" } // Invalid Agent ID (403) { "error": "Access denied", "message": "One or more agents do not belong to your organisation" } // Content Too Long (400) { "error": "Content exceeds character limit", "message": "The content field must be 4000 characters or less." } // Invalid JSON Body (400) { "error": "Invalid JSON body", "message": "Unexpected token } in JSON at position 123" } // Validation Error (400) { "error": "Validation failed", "message": "If provided, \"name\" must be a non-empty string." } // Internal Server Error (500) { "error": "Internal server error" }
If you update the content of a knowledge item, it will overwrite the existing content. So make sure to include all the content you want to keep.
If you update the content, it will trigger a re-embedding of the knowledge item. If you want to use the description_to_index_on, provide it again.
/api/public/knowledge/:id
Permanently delete a knowledge item and all associated data. Only items belonging to your organization can be deleted. This action cannot be undone.
Requires an API key in the Authorization header.
Authorization: YOUR_API_KEY
Parameter | Type | Description |
---|---|---|
id | string | The knowledge item's unique identifier |
curl -X DELETE "https://flowgent.ai/api/public/knowledge/item-uuid-123" \ -H "Authorization: YOUR_API_KEY"
{ "message": "Knowledge item deleted successfully" }
// Missing API Key (401) { "error": "API key is required", "message": "Please provide an API key in the Authorization header" } // Invalid API Key (401) { "error": "Invalid API key", "message": "The provided API key is not valid" } // Knowledge Item Not Found (404) { "error": "Knowledge item not found or access denied" } // Internal Server Error (500) { "error": "Internal server error" }
This action permanently deletes the knowledge item for all connected agents and cannot be undone.