Workflow API Reference

The AgenticFlow Workflows API provides comprehensive programmatic access to create, manage, and execute both traditional sequential workflows and advanced multi-agent Workforce systems. Build sophisticated automation pipelines that scale from simple tasks to complex enterprise processes.

🎯 API Overview

The Workflows API enables:

  • πŸ”§ Workflow Lifecycle Management - Create, configure, deploy, and monitor workflows

  • ⚑ Execution Control - Run workflows with data, track progress, and manage results

  • πŸ“Š Bulk Processing - Handle thousands of records with table-based execution

  • πŸ€– Workforce Integration - Orchestrate multi-agent collaboration workflows

  • πŸ“ˆ Performance Analytics - Monitor execution metrics and optimize performance

Base URL: https://api.agenticflow.ai/v1 Authentication: Bearer token (API key required) Rate Limits: 500 workflow executions/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/workflows

βš™οΈ Workflow Management

Create Workflow

Create a new workflow with complete node configuration.

Endpoint: POST /workflows

const workflow = await fetch('https://api.agenticflow.ai/v1/workflows', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: "Customer Feedback Analysis Pipeline",
    description: "Analyze customer feedback and generate insights",
    type: "traditional", // or "workforce"
    nodes: [
      {
        id: "input_data",
        type: "csv_input",
        position: { x: 100, y: 100 },
        configuration: {
          required_columns: ["feedback_text", "customer_id", "date"],
          validation_mode: "strict"
        }
      },
      {
        id: "sentiment_analysis",
        type: "llm",
        position: { x: 300, y: 100 },
        configuration: {
          model: "claude-3-5-sonnet-20241022",
          prompt: "Analyze the sentiment of this feedback: {{feedback_text}}. Return JSON with sentiment, confidence, and key themes.",
          response_format: "json_object",
          temperature: 0.2
        }
      },
      {
        id: "categorize_feedback",
        type: "llm",
        position: { x: 500, y: 100 },
        configuration: {
          model: "gpt-4",
          prompt: "Categorize this feedback: {{feedback_text}}. Categories: product, service, billing, technical. Return JSON.",
          response_format: "json_object"
        }
      },
      {
        id: "generate_response",
        type: "email",
        position: { x: 700, y: 100 },
        configuration: {
          template_id: "customer_feedback_response",
          to: "{{customer_email}}",
          subject: "Thank you for your feedback",
          personalization: true
        }
      }
    ],
    connections: [
      { from: "input_data", to: "sentiment_analysis" },
      { from: "sentiment_analysis", to: "categorize_feedback" },
      { from: "categorize_feedback", to: "generate_response" }
    ],
    settings: {
      timeout: 300,
      retry_failed_nodes: true,
      max_retries: 3,
      parallel_execution: false,
      error_handling: "continue_on_error"
    },
    tags: ["customer_service", "analysis", "automation"],
    is_active: true
  })
});

const response = await workflow.json();

Request Body:

{
  "name": "string (required)",
  "description": "string (optional)",
  "type": "traditional|workforce (required)",
  "nodes": [
    {
      "id": "string (required)",
      "type": "string (required)",
      "position": { "x": "number", "y": "number" },
      "configuration": "object (node-specific)"
    }
  ],
  "connections": [
    {
      "from": "string (node_id)",
      "to": "string (node_id)",
      "conditions": "object (optional)"
    }
  ],
  "settings": {
    "timeout": "number (seconds)",
    "retry_failed_nodes": "boolean",
    "max_retries": "number",
    "parallel_execution": "boolean",
    "error_handling": "stop_on_error|continue_on_error|retry_on_error"
  },
  "tags": ["string"],
  "is_active": "boolean",
  "metadata": "object"
}

Response:

{
  "id": "workflow_clx8k2n4m0001js0h3q5j4k8r",
  "name": "Customer Feedback Analysis Pipeline",
  "description": "Analyze customer feedback and generate insights",
  "type": "traditional",
  "nodes": [...],
  "connections": [...],
  "settings": {...},
  "tags": ["customer_service", "analysis", "automation"],
  "is_active": true,
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z",
  "workspace_id": "ws_main_workspace",
  "version": 1
}

List Workflows

Retrieve all workflows with filtering and pagination.

Endpoint: GET /workflows

const workflows = await fetch('https://api.agenticflow.ai/v1/workflows?' + new URLSearchParams({
  limit: '50',
  offset: '0',
  type: 'traditional',
  tags: 'customer_service,automation',
  is_active: 'true',
  sort: 'created_at_desc'
}), {
  headers: {
    'Authorization': 'Bearer af_live_your_api_key'
  }
});

const response = await workflows.json();

Query Parameters:

  • limit (integer, 1-100): Number of workflows to return (default: 50)

  • offset (integer): Number of workflows to skip (default: 0)

  • type (string): Filter by workflow type (traditional, workforce)

  • tags (string): Comma-separated list of tags to filter by

  • is_active (boolean): Filter by active status

  • search (string): Search in workflow names and descriptions

  • sort (string): Sort order (created_at_asc, created_at_desc, name_asc, name_desc)

Get Workflow

Retrieve detailed information about a specific workflow.

Endpoint: GET /workflows/{workflow_id}

const workflow = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r', {
  headers: {
    'Authorization': 'Bearer af_live_your_api_key'
  }
});

const response = await workflow.json();

Update Workflow

Modify an existing workflow's configuration.

Endpoint: PUT /workflows/{workflow_id}

const updatedWorkflow = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: "Enhanced Customer Feedback Analysis",
    nodes: [
      // Updated node configurations
    ],
    settings: {
      timeout: 600,
      parallel_execution: true
    }
  })
});

▢️ Workflow Execution

Execute Workflow (Single Run)

Run a workflow with specific input data.

Endpoint: POST /workflows/{workflow_id}/execute

const execution = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/execute', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    input: {
      feedback_text: "The product is amazing but shipping was slow",
      customer_id: "cust_12345",
      customer_email: "[email protected]",
      date: "2024-01-15"
    },
    options: {
      wait_for_completion: true,
      include_intermediate_results: false,
      timeout: 300,
      priority: "normal"
    },
    context: {
      user_id: "user_12345",
      execution_source: "api",
      metadata: {
        campaign_id: "campaign_winter_2024"
      }
    }
  })
});

const response = await execution.json();

Request Body:

{
  "input": "object (required)",
  "options": {
    "wait_for_completion": "boolean (default: true)",
    "include_intermediate_results": "boolean (default: false)",
    "timeout": "number (seconds, default: 300)",
    "priority": "low|normal|high (default: normal)"
  },
  "context": {
    "user_id": "string (optional)",
    "execution_source": "string (optional)",
    "metadata": "object (optional)"
  }
}

Response:

{
  "execution_id": "exec_clx8k2n4m0001js0h3q5j4k8r",
  "workflow_id": "workflow_clx8k2n4m0001js0h3q5j4k8r",
  "status": "completed",
  "result": {
    "sentiment_analysis": {
      "sentiment": "mixed",
      "confidence": 0.82,
      "key_themes": ["product_satisfaction", "shipping_delay"]
    },
    "categorize_feedback": {
      "category": "service",
      "subcategory": "shipping",
      "confidence": 0.91
    },
    "generate_response": {
      "email_sent": true,
      "message_id": "msg_response_12345"
    }
  },
  "execution_metrics": {
    "total_duration": "12.34s",
    "nodes_executed": 4,
    "nodes_successful": 4,
    "nodes_failed": 0,
    "total_tokens": 1247,
    "total_cost": 0.0823
  },
  "started_at": "2024-01-15T10:30:00Z",
  "completed_at": "2024-01-15T10:30:12Z"
}

Bulk Execution (Table Run)

Execute workflow with multiple rows of data (CSV/Excel processing).

Endpoint: POST /workflows/{workflow_id}/execute/bulk

const bulkExecution = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/execute/bulk', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    data: [
      {
        feedback_text: "Great product, fast shipping!",
        customer_id: "cust_001",
        customer_email: "[email protected]"
      },
      {
        feedback_text: "Product broke after one week",
        customer_id: "cust_002", 
        customer_email: "[email protected]"
      },
      {
        feedback_text: "Average quality, okay price",
        customer_id: "cust_003",
        customer_email: "[email protected]"
      }
    ],
    options: {
      batch_size: 10,
      parallel_batches: 3,
      wait_for_completion: false,
      error_handling: "continue_on_error",
      progress_webhook: "https://your-app.com/webhook/progress"
    }
  })
});

const response = await bulkExecution.json();

Request Body:

{
  "data": [
    {
      "column1": "value1",
      "column2": "value2"
    }
  ],
  "options": {
    "batch_size": "number (default: 50)",
    "parallel_batches": "number (default: 5)",
    "wait_for_completion": "boolean (default: false)",
    "error_handling": "stop_on_error|continue_on_error|retry_on_error",
    "progress_webhook": "string (optional)",
    "completion_webhook": "string (optional)"
  }
}

Response:

{
  "bulk_execution_id": "bulk_exec_clx8k2n4m0001js0h3q5j4k8r",
  "workflow_id": "workflow_clx8k2n4m0001js0h3q5j4k8r",
  "status": "processing",
  "progress": {
    "total_rows": 3,
    "processed_rows": 0,
    "successful_rows": 0,
    "failed_rows": 0,
    "percentage": 0
  },
  "estimated_completion": "2024-01-15T10:35:00Z",
  "batch_config": {
    "batch_size": 10,
    "parallel_batches": 3
  },
  "started_at": "2024-01-15T10:30:00Z"
}

File Upload for Bulk Execution

Upload CSV/Excel file for bulk processing.

Endpoint: POST /workflows/{workflow_id}/execute/upload

const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('options', JSON.stringify({
  batch_size: 25,
  parallel_batches: 4,
  column_mapping: {
    "feedback": "feedback_text",
    "customer": "customer_id"
  }
}));

const uploadExecution = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/execute/upload', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key'
  },
  body: formData
});

const response = await uploadExecution.json();

πŸ“Š Execution Monitoring

Get Execution Status

Monitor the progress of a workflow execution.

Endpoint: GET /executions/{execution_id}

const status = await fetch('https://api.agenticflow.ai/v1/executions/exec_clx8k2n4m0001js0h3q5j4k8r', {
  headers: {
    'Authorization': 'Bearer af_live_your_api_key'
  }
});

const response = await status.json();

Response:

{
  "execution_id": "exec_clx8k2n4m0001js0h3q5j4k8r",
  "workflow_id": "workflow_clx8k2n4m0001js0h3q5j4k8r", 
  "status": "running",
  "progress": {
    "current_node": "sentiment_analysis",
    "nodes_completed": 2,
    "total_nodes": 4,
    "percentage": 50,
    "estimated_time_remaining": "8s"
  },
  "partial_results": {
    "input_data": {
      "rows_processed": 1,
      "validation_passed": true
    },
    "sentiment_analysis": {
      "sentiment": "positive",
      "confidence": 0.89
    }
  },
  "metrics": {
    "duration_so_far": "4.2s",
    "tokens_used": 234,
    "cost_so_far": 0.012
  },
  "started_at": "2024-01-15T10:30:00Z"
}

Get Bulk Execution Status

Monitor progress of bulk/table execution.

Endpoint: GET /bulk-executions/{bulk_execution_id}

const bulkStatus = await fetch('https://api.agenticflow.ai/v1/bulk-executions/bulk_exec_clx8k2n4m0001js0h3q5j4k8r', {
  headers: {
    'Authorization': 'Bearer af_live_your_api_key'
  }
});

const response = await bulkStatus.json();

Response:

{
  "bulk_execution_id": "bulk_exec_clx8k2n4m0001js0h3q5j4k8r",
  "workflow_id": "workflow_clx8k2n4m0001js0h3q5j4k8r",
  "status": "processing",
  "progress": {
    "total_rows": 1000,
    "processed_rows": 347,
    "successful_rows": 341,
    "failed_rows": 6,
    "percentage": 34.7,
    "current_batch": 15,
    "total_batches": 40
  },
  "performance_metrics": {
    "avg_processing_time_per_row": "2.1s",
    "rows_per_minute": 28.6,
    "estimated_completion": "2024-01-15T11:15:00Z",
    "resource_utilization": 0.73
  },
  "error_summary": {
    "validation_errors": 3,
    "timeout_errors": 2,
    "api_errors": 1,
    "most_common_error": "Invalid email format"
  },
  "started_at": "2024-01-15T10:30:00Z"
}

Cancel Execution

Stop a running workflow execution.

Endpoint: POST /executions/{execution_id}/cancel

const cancellation = await fetch('https://api.agenticflow.ai/v1/executions/exec_clx8k2n4m0001js0h3q5j4k8r/cancel', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    reason: "User requested cancellation",
    save_partial_results: true
  })
});

πŸ€– Workforce (Multi-Agent) Workflows

Create Workforce Workflow

Create a multi-agent collaboration workflow.

Endpoint: POST /workflows

const workforceWorkflow = await fetch('https://api.agenticflow.ai/v1/workflows', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: "Content Creation & Review Workforce",
    description: "Multi-agent system for content creation, review, and optimization",
    type: "workforce",
    nodes: [
      {
        id: "trigger",
        type: "trigger",
        position: { x: 100, y: 200 },
        configuration: {}
      },
      {
        id: "research_agent",
        type: "agent",
        position: { x: 300, y: 100 },
        configuration: {
          agent_id: "agent_researcher",
          thread_option: "CREATE_NEW",
          message: "Research the topic: {{topic}}. Provide key facts, trends, and insights."
        }
      },
      {
        id: "writer_agent",
        type: "agent",
        position: { x: 300, y: 300 },
        configuration: {
          agent_id: "agent_writer",
          thread_option: "CREATE_NEW",
          message: "Write a blog post about {{topic}}. Use research: {{node_outputs[\"research_agent\"].content}}"
        }
      },
      {
        id: "editor_agent",
        type: "agent",
        position: { x: 500, y: 200 },
        configuration: {
          agent_id: "agent_editor",
          thread_option": "CREATE_NEW",
          message: "Review and edit this content for clarity and engagement: {{node_outputs[\"writer_agent\"].content}}"
        }
      },
      {
        id: "seo_optimizer",
        type: "tool",
        position: { x: 700, y: 200 },
        configuration: {
          workflow_id: "workflow_seo_optimization",
          input: {
            content: "{{node_outputs[\"editor_agent\"].content}}",
            target_keywords: "{{keywords}}"
          }
        }
      }
    ],
    connections: [
      { from: "trigger", to: "research_agent" },
      { from: "trigger", to: "writer_agent" },
      { from: "research_agent", to: "editor_agent" },
      { from: "writer_agent", to: "editor_agent" },
      { from: "editor_agent", to: "seo_optimizer" }
    ],
    settings: {
      max_execution_time: 1800,
      agent_coordination: "parallel_where_possible",
      error_handling: "retry_with_different_agent"
    }
  })
});

Execute Workforce Workflow

Run a multi-agent workflow with trigger data.

Endpoint: POST /workflows/{workflow_id}/execute

const workforceExecution = await fetch('https://api.agenticflow.ai/v1/workflows/workforce_workflow_id/execute', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    trigger_data: {
      topic: "Artificial Intelligence in Healthcare",
      keywords: ["AI healthcare", "medical AI", "healthcare automation"],
      target_audience: "healthcare professionals",
      content_length: "2000 words"
    },
    options: {
      wait_for_completion: true,
      include_agent_conversations: true,
      coordination_strategy: "intelligent_sequencing"
    }
  })
});

const response = await workforceExecution.json();

Response:

{
  "execution_id": "workforce_exec_clx8k2n4m0001js0h3q5j4k8r",
  "workflow_id": "workforce_workflow_id",
  "status": "completed",
  "agent_results": {
    "research_agent": {
      "content": "Key findings about AI in healthcare...",
      "metadata": {
        "sources_used": 15,
        "research_confidence": 0.92,
        "execution_time": "23s"
      }
    },
    "writer_agent": {
      "content": "Full blog post content...",
      "metadata": {
        "word_count": 2156,
        "readability_score": 8.2,
        "execution_time": "45s"
      }
    },
    "editor_agent": {
      "content": "Edited and refined content...",
      "changes_made": ["improved_clarity", "enhanced_flow", "added_transitions"],
      "metadata": {
        "improvements": 23,
        "execution_time": "31s"
      }
    },
    "seo_optimizer": {
      "optimized_content": "SEO-enhanced content...",
      "seo_score": 87,
      "keywords_density": {
        "AI healthcare": 1.2,
        "medical AI": 0.8
      }
    }
  },
  "coordination_metrics": {
    "total_agent_interactions": 12,
    "parallel_execution_time": "89s",
    "sequential_execution_saved": "34s",
    "coordination_efficiency": 0.82
  }
}

πŸ“ˆ Analytics and Reporting

Workflow Performance Analytics

Get detailed performance metrics for workflows.

Endpoint: GET /workflows/{workflow_id}/analytics

const analytics = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/analytics?' + new URLSearchParams({
  start_date: '2024-01-01',
  end_date: '2024-01-31',
  granularity: 'daily',
  metrics: 'executions,performance,costs,errors'
}), {
  headers: {
    'Authorization': 'Bearer af_live_your_api_key'
  }
});

const response = await analytics.json();

Response:

{
  "workflow_id": "workflow_clx8k2n4m0001js0h3q5j4k8r",
  "period": {
    "start_date": "2024-01-01",
    "end_date": "2024-01-31"
  },
  "metrics": {
    "executions": {
      "total_executions": 2547,
      "successful_executions": 2489,
      "failed_executions": 58,
      "success_rate": 0.977,
      "avg_executions_per_day": 82.2
    },
    "performance": {
      "avg_execution_time": "8.7s",
      "median_execution_time": "6.2s",
      "95th_percentile_time": "18.4s",
      "fastest_execution": "2.1s",
      "slowest_execution": "47.3s"
    },
    "costs": {
      "total_cost": 234.56,
      "avg_cost_per_execution": 0.092,
      "cost_breakdown": {
        "llm_usage": 189.23,
        "tool_calls": 31.45,
        "data_processing": 13.88
      }
    },
    "errors": {
      "error_rate": 0.023,
      "common_errors": {
        "timeout": 23,
        "validation_error": 18,
        "api_limit": 12,
        "node_failure": 5
      }
    }
  },
  "node_performance": [
    {
      "node_id": "sentiment_analysis",
      "avg_execution_time": "3.2s",
      "success_rate": 0.995,
      "error_count": 12
    }
  ]
}

Export Execution Results

Download results from bulk executions.

Endpoint: GET /bulk-executions/{bulk_execution_id}/results

const results = await fetch('https://api.agenticflow.ai/v1/bulk-executions/bulk_exec_clx8k2n4m0001js0h3q5j4k8r/results?' + new URLSearchParams({
  format: 'csv',
  include_metadata: 'true',
  filter_status: 'successful'
}), {
  headers: {
    'Authorization': 'Bearer af_live_your_api_key'
  }
});

// For CSV download
if (results.headers.get('content-type').includes('text/csv')) {
  const csvData = await results.text();
  // Handle CSV data
} else {
  const jsonResults = await results.json();
}

Query Parameters:

  • format (string): Export format (json, csv, excel)

  • include_metadata (boolean): Include execution metadata

  • filter_status (string): Filter by execution status (successful, failed, all)

  • columns (string): Comma-separated list of columns to include


πŸ› οΈ Advanced Workflow Features

Workflow Templates

Create and manage reusable workflow templates.

Endpoint: POST /workflow-templates

const template = await fetch('https://api.agenticflow.ai/v1/workflow-templates', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: "Customer Feedback Analysis Template",
    description: "Template for analyzing customer feedback with sentiment analysis",
    category: "customer_analytics",
    template: {
      nodes: [...],
      connections: [...],
      settings: {...}
    },
    variables: {
      "sentiment_model": {
        "type": "model_selection",
        "options": ["claude-3-5-sonnet", "gpt-4", "gemini-pro"],
        "default": "claude-3-5-sonnet",
        "description": "AI model for sentiment analysis"
      },
      "response_template": {
        "type": "email_template",
        "required": false,
        "description": "Template for customer response emails"
      }
    },
    tags": ["template", "customer_analytics", "sentiment"]
  })
});

Workflow Versions

Manage different versions of workflows.

Endpoint: POST /workflows/{workflow_id}/versions

const version = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/versions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    version_name: "v2.1.0",
    description: "Added improved error handling and faster processing",
    changes: {
      nodes: {...},
      settings: {...}
    },
    set_as_active: false
  })
});

Workflow Scheduling

Schedule workflows to run automatically.

Endpoint: POST /workflows/{workflow_id}/schedule

const schedule = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/schedule', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    schedule_type: "cron",
    cron_expression: "0 9 * * 1", // Every Monday at 9 AM
    timezone: "America/New_York",
    input_data: {
      data_source: "database_query",
      query: "SELECT * FROM feedback WHERE created_date >= CURDATE() - INTERVAL 7 DAY"
    },
    notifications: {
      on_success: ["[email protected]"],
      on_failure: ["[email protected]"],
      include_summary: true
    },
    is_active: true
  })
});

πŸ”Œ Webhooks and Integration

Workflow Webhooks

Set up webhooks for workflow events.

Endpoint: POST /workflows/{workflow_id}/webhooks

const webhook = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/webhooks', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: "https://your-app.com/webhook/workflow-events",
    events: [
      "execution.started",
      "execution.completed",
      "execution.failed",
      "bulk_execution.progress"
    ],
    headers: {
      "X-API-Key": "your_webhook_secret"
    },
    retry_config": {
      "max_retries": 3,
      "retry_delay": "exponential"
    },
    is_active: true
  })
});

Trigger Workflow via Webhook

Configure workflow to be triggered by external webhook.

Endpoint: POST /workflows/{workflow_id}/trigger-webhook

const triggerWebhook = await fetch('https://api.agenticflow.ai/v1/workflows/workflow_clx8k2n4m0001js0h3q5j4k8r/trigger-webhook', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af_live_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    webhook_name: "customer_feedback_trigger",
    authentication: {
      type: "api_key",
      header_name: "X-Webhook-Secret"
    },
    data_mapping": {
      "feedback_text": "$.message.content",
      "customer_id": "$.customer.id",
      "timestamp": "$.received_at"
    },
    validation_rules": {
      "required_fields": ["message.content", "customer.id"],
      "content_type": "application/json"
    }
  })
});

const response = await triggerWebhook.json();

Response:

{
  "webhook_id": "webhook_clx8k2n4m0001js0h3q5j4k8r",
  "webhook_url": "https://api.agenticflow.ai/webhooks/workflow_clx8k2n4m0001js0h3q5j4k8r/customer_feedback_trigger",
  "webhook_secret": "whs_abc123def456...",
  "created_at": "2024-01-15T10:30:00Z"
}

πŸš€ SDK Examples

Python SDK

import agenticflow

# Initialize client
client = agenticflow.Client(api_key="af_live_your_api_key")

# Create workflow
workflow = client.workflows.create(
    name="Sentiment Analysis Pipeline",
    type="traditional",
    nodes=[
        {
            "id": "sentiment",
            "type": "llm",
            "configuration": {
                "model": "claude-3-5-sonnet-20241022",
                "prompt": "Analyze sentiment: {{text}}"
            }
        }
    ],
    connections=[
        {"from": "input", "to": "sentiment"}
    ]
)

# Execute workflow
result = workflow.execute(input_data={
    "text": "I love this product!"
})

print(f"Sentiment: {result.result['sentiment']}")

# Bulk execution with CSV
bulk_result = workflow.execute_bulk(
    csv_file="feedback.csv",
    options={
        "batch_size": 50,
        "wait_for_completion": True
    }
)

print(f"Processed {bulk_result.progress['processed_rows']} rows")

Node.js SDK

const AgenticFlow = require('agenticflow');

// Initialize client
const client = new AgenticFlow({
  apiKey: 'af_live_your_api_key'
});

async function main() {
  // Create workforce workflow
  const workforce = await client.workflows.create({
    name: 'Content Creation Team',
    type: 'workforce',
    nodes: [
      {
        id: 'researcher',
        type: 'agent',
        configuration: {
          agentId: 'agent_researcher',
          message: 'Research topic: {{topic}}'
        }
      },
      {
        id: 'writer',
        type: 'agent',
        configuration: {
          agentId: 'agent_writer',
          message: 'Write content based on: {{node_outputs["researcher"].content}}'
        }
      }
    ]
  });

  // Execute with real-time monitoring
  const execution = await workforce.execute({
    triggerData: {
      topic: 'Future of AI'
    },
    options: { 
      waitForCompletion: false 
    }
  });

  // Monitor progress
  const monitor = setInterval(async () => {
    const status = await client.executions.get(execution.executionId);
    console.log(`Progress: ${status.progress.percentage}%`);
    
    if (status.status === 'completed') {
      console.log('Final result:', status.agentResults);
      clearInterval(monitor);
    }
  }, 2000);
}

main().catch(console.error);

πŸš€ Next Steps & Resources

πŸ“š Continue Learning

πŸ› οΈ Development Tools

πŸ’¬ Developer Support


βš™οΈ The Workflows API transforms complex business processes into automated, scalable systems. From simple data processing to sophisticated multi-agent orchestration, you have the power to automate any process and scale it across your entire organization.

Automate everything, scale infinitely.

Last updated

Was this helpful?