POST /functions/v1/run-workflow
Executes a workflow starting from a specified element and processes all connected agents in sequence.Request
Headers
Bearer token for authentication:
Bearer <your-supabase-jwt-token>Must be
application/jsonBody Parameters
The ID of the workflow element to start execution from. Can be in UUID format (e.g.,
123e4567-e89b-12d3-a456-426614174000-node-1) or a custom format.Response
Indicates whether the workflow executed successfully
Array of execution results for each agent in the workflow
The ID of the executed element
The output from the agent execution. Structure varies by agent type:Text Generator:
text(string): Generated textsuccess(boolean): Execution status
messages(array): Array of email messages
success(boolean): Send statusmessageId(string): Gmail message ID
success(boolean): Send statusmessageId(string): Discord message ID
repoName(string): Repository namebranch(string): Branch namecommits(array): Array of commit objectssummary(string): Summary of commits
Workflow Execution
The workflow engine:- Resolves Element: Extracts workflow ID from the
startElementIdor searches through user workflows - Loads Workflow: Fetches workflow data including elements and connections
- Builds Execution Graph: Creates a connection map from workflow connections
- Executes Sequentially: Processes agents using breadth-first traversal
- Context Management: Maintains output context for placeholder resolution
- Cycles Prevention: Tracks processed elements to avoid infinite loops
Supported Agent Types
text_generator- Calls/generate-textendpointgmail_reader- Calls/read-gmailendpointgmail_sender- Calls/send-gmailendpointdiscord_messenger- Calls/send-discordendpointgithub_reader- Calls/read-githubendpoint
Placeholder Resolution
Agent configurations can use placeholders that reference outputs from previous agents:Example
Request
Success Response
Error Response
Error Codes
| Status Code | Error Message | Description |
|---|---|---|
| 400 | Start element ID is required | Missing startElementId parameter |
| 400 | Could not determine workflow ID | Invalid element ID format |
| 400 | Agent not configured | Agent configuration missing |
| 404 | Workflow not found | Workflow doesn’t exist or user lacks access |
| 404 | Starting element not found in workflow | Element ID not found in workflow |
| 500 | Failed to fetch workflow | Database error retrieving workflow |
| 500 | Failed to fetch agent configuration | Error loading agent config |
Notes
- Workflows execute in breadth-first order based on connections
- Already processed elements are skipped to prevent cycles
- Each agent’s output is stored in a context object for subsequent agents
- Agent configurations are loaded from the
agent_configstable - The workflow must belong to the authenticated user