Execute Ensemble
Name of the ensemble to execute
Input data for the ensemble
Execute asynchronously and return execution ID immediately
Maximum execution time in milliseconds
Stream execution progress via Server-Sent Events
Response
Unique execution identifier
Execution status: completed, failed, running, waiting_for_input
Ensemble output data (if completed)
Error details (if failed)
Execution time in milliseconds
Unix timestamp of execution start
curl -X POST https://your-worker.workers.dev/api/v1/execute \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ensemble": "order-processing",
"input": {
"orderId": "ORD-123",
"customerId": "CUST-456"
}
}'
{
"id": "exec_abc123def456",
"status": "completed",
"output": {
"status": "success",
"total": 99.99,
"paymentId": "ch_1234567890"
},
"duration": 1523,
"timestamp": 1704067200000
}
Get Execution Status
Retrieve the status and result of a specific execution.
Execution ID returned from execute endpoint
Response
Current status: completed, failed, running, waiting_for_input
Result data (if completed)
Error information (if failed)
Execution progress informationNumber of completed members
Currently executing member name
curl https://your-worker.workers.dev/api/v1/executions/exec_abc123def456 \
-H "Authorization: Bearer YOUR_API_KEY"
{
"id": "exec_abc123def456",
"status": "running",
"progress": {
"completed": 3,
"total": 7,
"current": "process-payment"
},
"timestamp": 1704067200000
}
Resume Execution
Resume a workflow waiting for human input (HITL).
HITL token from execution status
Human input data matching the HITL fields
curl -X POST https://your-worker.workers.dev/api/v1/executions/exec_abc123/resume \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"token": "hitl_xyz789",
"input": {
"approved": true,
"comments": "Looks good"
}
}'
{
"id": "exec_abc123def456",
"status": "completed",
"output": {
"approved": true,
"result": "published"
},
"duration": 3522,
"timestamp": 1704067200000
}
Cancel Execution
Cancel a running execution.
curl -X DELETE https://your-worker.workers.dev/api/v1/executions/exec_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
{
"id": "exec_abc123def456",
"status": "cancelled",
"message": "Execution cancelled successfully"
}
Stream Execution
Execute an ensemble and stream progress updates via Server-Sent Events (SSE).
Event Types
| Event | Description |
start | Execution started |
member.start | Member execution started |
member.complete | Member execution completed |
member.error | Member execution failed |
hitl.waiting | Waiting for human input |
complete | Execution completed |
error | Execution failed |
const eventSource = new EventSource(
'https://your-worker.workers.dev/api/v1/stream',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
ensemble: 'order-processing',
input: { orderId: 'ORD-123' }
})
}
);
eventSource.addEventListener('member.complete', (event) => {
const data = JSON.parse(event.data);
console.log(`Completed: ${data.member}`);
});
eventSource.addEventListener('complete', (event) => {
const data = JSON.parse(event.data);
console.log('Final output:', data.output);
eventSource.close();
});
eventSource.addEventListener('error', (event) => {
console.error('Stream error:', event);
eventSource.close();
});
event: start
data: {"id":"exec_abc123","timestamp":1704067200000}
event: member.start
data: {"member":"validate-order","timestamp":1704067200100}
event: member.complete
data: {"member":"validate-order","duration":123,"timestamp":1704067200223}
event: member.start
data: {"member":"process-payment","timestamp":1704067200250}
event: member.complete
data: {"member":"process-payment","duration":1200,"output":{"paymentId":"ch_123"},"timestamp":1704067201450}
event: complete
data: {"id":"exec_abc123","status":"completed","output":{"total":99.99},"duration":1523,"timestamp":1704067201523}
Error Codes
| Code | Description | Resolution |
VALIDATION_ERROR | Invalid input data | Check input schema |
ENSEMBLE_NOT_FOUND | Ensemble doesn’t exist | Verify ensemble name |
EXECUTION_NOT_FOUND | Execution ID not found | Check execution ID |
INVALID_TOKEN | HITL token invalid/expired | Request new token |
TIMEOUT | Execution exceeded timeout | Increase timeout or optimize workflow |
RATE_LIMIT_EXCEEDED | Too many requests | Implement backoff, increase limits |