Workflows API
Create, manage, and execute automated multi-step workflows that orchestrate multiple AI agents to accomplish complex tasks.
Base URLβ
https://api.faosx.ai/v1/workflows
Workflow Objectβ
A workflow defines a sequence of steps executed by one or more agents.
interface Workflow {
id: string; // Unique identifier (e.g., "wfl_abc123")
workspace_id: string; // Parent workspace
name: string; // Display name
description?: string; // Optional description
status: WorkflowStatus; // draft, active, paused, archived
// Definition
trigger: Trigger; // How workflow starts
steps: Step[]; // Ordered workflow steps
// Configuration
settings: {
timeout_seconds: number; // Max execution time
retry_policy: RetryPolicy;
error_handling: ErrorHandling;
};
// Metadata
created_at: string;
updated_at: string;
last_executed_at: string;
// Statistics
stats: {
total_executions: number;
success_rate: number;
avg_duration_seconds: number;
};
}
type WorkflowStatus = "draft" | "active" | "paused" | "archived";
interface Step {
id: string;
name: string;
type: "agent_action" | "condition" | "parallel" | "wait" | "webhook";
agent_id?: string; // For agent_action steps
config: Record<string, any>; // Step-specific configuration
next_step_id?: string; // Sequential flow
on_error?: string; // Error handler step
}
interface Trigger {
type: "manual" | "webhook" | "schedule" | "event";
config: Record<string, any>;
}
Create Workflowβ
Create a new workflow.
POST /v1/workflows
Request Bodyβ
{
"name": "Customer Onboarding",
"description": "Automated customer onboarding workflow",
"status": "draft",
"trigger": {
"type": "webhook",
"config": {
"path": "/onboard-customer"
}
},
"steps": [
{
"id": "step_1",
"name": "Verify Customer Info",
"type": "agent_action",
"agent_id": "agt_verification",
"config": {
"action": "verify_identity",
"input_mapping": {
"customer_data": "{{trigger.payload}}"
}
},
"next_step_id": "step_2"
},
{
"id": "step_2",
"name": "Check Verification Result",
"type": "condition",
"config": {
"condition": "{{step_1.result.verified}} === true",
"if_true": "step_3",
"if_false": "step_error"
}
},
{
"id": "step_3",
"name": "Create Account",
"type": "agent_action",
"agent_id": "agt_operations",
"config": {
"action": "create_account",
"input_mapping": {
"customer_id": "{{step_1.result.customer_id}}"
}
},
"next_step_id": "step_4"
},
{
"id": "step_4",
"name": "Send Welcome Email",
"type": "agent_action",
"agent_id": "agt_communications",
"config": {
"action": "send_email",
"template": "welcome",
"input_mapping": {
"to": "{{trigger.payload.email}}",
"account_id": "{{step_3.result.account_id}}"
}
}
},
{
"id": "step_error",
"name": "Handle Verification Failure",
"type": "agent_action",
"agent_id": "agt_support",
"config": {
"action": "create_support_ticket",
"priority": "high"
}
}
],
"settings": {
"timeout_seconds": 300,
"retry_policy": {
"max_attempts": 3,
"backoff_multiplier": 2
},
"error_handling": "continue"
}
}
Responseβ
{
"data": {
"id": "wfl_abc123",
"workspace_id": "ws_xyz789",
"name": "Customer Onboarding",
"status": "draft",
"trigger": { ... },
"steps": [ ... ],
"settings": { ... },
"created_at": "2025-12-21T10:00:00Z",
"updated_at": "2025-12-21T10:00:00Z",
"last_executed_at": null,
"stats": {
"total_executions": 0,
"success_rate": 0,
"avg_duration_seconds": 0
}
}
}
Retrieve Workflowβ
Get details of a specific workflow.
GET /v1/workflows/{workflow_id}
Example Requestβ
curl https://api.faosx.ai/v1/workflows/wfl_abc123 \
-H "Authorization: Bearer sk_live_abc123..."
List Workflowsβ
List all workflows in your workspace.
GET /v1/workflows
Query Parametersβ
| Parameter | Type | Description |
|---|---|---|
status | string | Filter by status: draft, active, paused |
limit | integer | Results per page (default: 20, max: 100) |
starting_after | string | Cursor for pagination |
Example Requestβ
curl "https://api.faosx.ai/v1/workflows?status=active" \
-H "Authorization: Bearer sk_live_abc123..."
Update Workflowβ
Update an existing workflow.
PATCH /v1/workflows/{workflow_id}
Request Bodyβ
{
"status": "active",
"settings": {
"timeout_seconds": 600
}
}
Delete Workflowβ
Delete a workflow.
DELETE /v1/workflows/{workflow_id}
Execute Workflowβ
Manually trigger a workflow execution.
POST /v1/workflows/{workflow_id}/execute
Request Bodyβ
{
"input": {
"customer_id": "cus_abc123",
"email": "customer@example.com",
"name": "Jane Doe"
},
"wait_for_completion": false
}
Parametersβ
| Parameter | Type | Required | Description |
|---|---|---|---|
input | object | Yes | Input data for the workflow |
wait_for_completion | boolean | No | Wait for result (default: false) |
Synchronous Response (wait_for_completion: true)β
{
"data": {
"execution_id": "wex_abc123",
"workflow_id": "wfl_abc123",
"status": "completed",
"steps_completed": 4,
"steps_total": 4,
"result": {
"account_id": "acc_xyz789",
"welcome_email_sent": true
},
"duration_seconds": 12.4,
"created_at": "2025-12-21T10:30:00Z",
"completed_at": "2025-12-21T10:30:12.4Z"
}
}
Asynchronous Response (wait_for_completion: false)β
{
"data": {
"execution_id": "wex_abc123",
"workflow_id": "wfl_abc123",
"status": "running",
"created_at": "2025-12-21T10:30:00Z"
}
}
Get Execution Statusβ
Check the status of a workflow execution.
GET /v1/workflows/{workflow_id}/executions/{execution_id}
Responseβ
{
"data": {
"execution_id": "wex_abc123",
"workflow_id": "wfl_abc123",
"status": "running",
"current_step": "step_3",
"steps_completed": 2,
"steps_total": 4,
"step_results": [
{
"step_id": "step_1",
"status": "completed",
"result": {
"verified": true,
"customer_id": "cus_abc123"
},
"duration_ms": 342
},
{
"step_id": "step_2",
"status": "completed",
"result": {
"condition_met": true
},
"duration_ms": 5
},
{
"step_id": "step_3",
"status": "running",
"started_at": "2025-12-21T10:30:05Z"
}
],
"created_at": "2025-12-21T10:30:00Z"
}
}
Execution Statusesβ
| Status | Description |
|---|---|
running | Workflow is executing |
awaiting_approval | Paused for human approval |
completed | Successfully finished |
failed | Execution failed |
cancelled | Manually cancelled |
timeout | Exceeded timeout limit |
List Executionsβ
List all executions for a workflow.
GET /v1/workflows/{workflow_id}/executions
Query Parametersβ
| Parameter | Type | Description |
|---|---|---|
status | string | Filter by status |
limit | integer | Results per page (default: 20) |
Cancel Executionβ
Cancel a running workflow execution.
POST /v1/workflows/{workflow_id}/executions/{execution_id}/cancel
Responseβ
{
"data": {
"execution_id": "wex_abc123",
"status": "cancelled",
"cancelled_at": "2025-12-21T10:35:00Z"
}
}
Workflow Templatesβ
FAOS provides pre-built workflow templates for common use cases.
List Templatesβ
GET /v1/workflows/templates
Responseβ
{
"data": [
{
"id": "tmpl_customer_onboarding",
"name": "Customer Onboarding",
"description": "Automated customer onboarding with verification",
"industry": "fintech",
"steps_count": 5,
"avg_duration_seconds": 15
},
{
"id": "tmpl_support_escalation",
"name": "Support Ticket Escalation",
"description": "Multi-tier support escalation workflow",
"industry": "all",
"steps_count": 4,
"avg_duration_seconds": 30
}
]
}
Create from Templateβ
POST /v1/workflows/from-template
Request Bodyβ
{
"template_id": "tmpl_customer_onboarding",
"name": "My Customer Onboarding",
"customizations": {
"agents": {
"verification": "agt_my_verification_agent",
"operations": "agt_my_ops_agent"
},
"settings": {
"timeout_seconds": 600
}
}
}
Step Typesβ
Agent Actionβ
Execute an action using an AI agent.
{
"type": "agent_action",
"agent_id": "agt_abc123",
"config": {
"action": "process_refund",
"input_mapping": {
"order_id": "{{trigger.payload.order_id}}",
"amount": "{{trigger.payload.amount}}"
}
}
}
Conditionβ
Branch workflow based on a condition.
{
"type": "condition",
"config": {
"condition": "{{step_1.result.amount}} > 100",
"if_true": "step_approval",
"if_false": "step_auto_process"
}
}
Parallelβ
Execute multiple steps in parallel.
{
"type": "parallel",
"config": {
"steps": ["step_notify_customer", "step_update_crm", "step_log_event"],
"wait_for_all": true
}
}
Waitβ
Pause workflow for a specified duration.
{
"type": "wait",
"config": {
"duration_seconds": 3600,
"reason": "Waiting for bank processing"
}
}
Webhookβ
Call an external webhook.
{
"type": "webhook",
"config": {
"url": "https://api.example.com/notify",
"method": "POST",
"headers": {
"Authorization": "Bearer {{secrets.api_key}}"
},
"body": {
"event": "workflow_completed",
"data": "{{workflow.result}}"
}
}
}
Variable Interpolationβ
Reference data from previous steps using double curly braces:
| Variable | Description | Example |
|---|---|---|
{{trigger.payload}} | Input data | {{trigger.payload.email}} |
{{step_X.result}} | Step result | {{step_1.result.verified}} |
{{workflow.execution_id}} | Current execution | {{workflow.execution_id}} |
{{secrets.KEY}} | Secret value | {{secrets.api_key}} |
Code Examplesβ
TypeScript/JavaScriptβ
import { FAOS } from '@faosx/sdk';
const faos = new FAOS('sk_live_abc123...');
// Create workflow
const workflow = await faos.workflows.create({
name: 'Customer Onboarding',
trigger: { type: 'webhook' },
steps: [
{
id: 'step_1',
type: 'agent_action',
agent_id: 'agt_verification',
config: { action: 'verify_identity' }
}
]
});
// Execute workflow
const execution = await faos.workflows.execute(workflow.id, {
input: { customer_id: 'cus_123' },
wait_for_completion: true
});
console.log(execution.result);
Pythonβ
from faosx import FAOS
faos = FAOS('sk_live_abc123...')
# Create workflow
workflow = faos.workflows.create(
name='Customer Onboarding',
trigger={'type': 'webhook'},
steps=[
{
'id': 'step_1',
'type': 'agent_action',
'agent_id': 'agt_verification',
'config': {'action': 'verify_identity'}
}
]
)
# Execute workflow
execution = faos.workflows.execute(
workflow.id,
input={'customer_id': 'cus_123'},
wait_for_completion=True
)
print(execution.result)
cURLβ
# Create workflow
curl -X POST https://api.faosx.ai/v1/workflows \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"name": "Customer Onboarding",
"trigger": {"type": "webhook"},
"steps": [...]
}'
# Execute workflow
curl -X POST https://api.faosx.ai/v1/workflows/wfl_abc123/execute \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"input": {"customer_id": "cus_123"},
"wait_for_completion": false
}'
Webhooksβ
Subscribe to workflow events:
workflow.createdworkflow.updatedworkflow.deletedworkflow.execution.startedworkflow.execution.completedworkflow.execution.failedworkflow.execution.step_completed
See Webhooks API for details.
Errorsβ
Common workflow-specific errors:
| Error Code | HTTP Status | Description |
|---|---|---|
workflow_not_found | 404 | Workflow ID doesn't exist |
invalid_step_config | 400 | Step configuration invalid |
workflow_timeout | 408 | Execution exceeded timeout |
step_failed | 500 | Step execution failed |
circular_dependency | 400 | Workflow has circular references |
See Error Reference for all error codes.
Rate Limitsβ
| Endpoint | Limit |
|---|---|
| Create Workflow | 20/hour |
| Execute Workflow | 100/minute per workflow |
| All other endpoints | 60/minute |
Next Stepsβ
- Agents API - Manage AI agents
- Webhooks - Real-time event notifications
- Error Reference - Complete error documentation