Overview
The Workflows API provides programmatic access to SO1’s n8n automation infrastructure. Trigger workflows, monitor executions, manage webhooks, and coordinate complex automation sequences.
Base URL: https://api.so1.io/v1/control-plane/workflows
Trigger Workflow
Execute an n8n workflow with custom payload and execution parameters.
Endpoint
POST /v1/control-plane/workflows/trigger
Request Body
Workflow identifier or slug (e.g., deployment-pipeline, wf-abc123)
Workflow input data (passed to workflow trigger node)
Execution configuration
async (immediate return) or sync (wait for completion)
Maximum execution time in seconds (sync mode only)
Queue priority: low, normal, high, critical
Webhook notification configuration
HTTPS endpoint for execution updates
Events: execution.started, execution.completed, execution.failed, execution.waiting
Example Request
curl -X POST https://api.so1.io/v1/control-plane/workflows/trigger \
-H "Authorization: Bearer so1_key_abc123xyz" \
-H "Content-Type: application/json" \
-d '{
"workflowId": "deployment-pipeline",
"payload": {
"service": "api-gateway",
"environment": "production",
"version": "v2.4.1",
"rollbackOnFailure": true
},
"execution": {
"mode": "async",
"priority": "high"
},
"webhook": {
"url": "https://your-app.com/webhooks/n8n",
"events": ["execution.completed", "execution.failed"],
"secret": "whsec_abc123xyz"
}
}'
Response
{
"success": true,
"data": {
"executionId": "exec-abc123xyz789",
"workflowId": "deployment-pipeline",
"status": "running",
"startedAt": "2024-03-10T15:30:00Z",
"n8nExecutionUrl": "https://n8n.so1.io/execution/exec-abc123xyz789"
},
"meta": {
"requestId": "req-def456",
"timestamp": "2024-03-10T15:30:00.123Z"
}
}
Example Response (Sync - Completed)
{
"success": true,
"data": {
"executionId": "exec-abc123xyz789",
"workflowId": "user-onboarding",
"status": "completed",
"result": {
"success": true,
"outputs": {
"userCreated": true,
"emailSent": true,
"subscriptionActive": true
},
"nodesExecuted": 8,
"duration": 2.4
},
"startedAt": "2024-03-10T15:30:00Z",
"completedAt": "2024-03-10T15:30:02.4Z"
}
}
Get Execution Status
Retrieve detailed status and output of a workflow execution.
Endpoint
GET /v1/control-plane/workflows/executions/{executionId}
Path Parameters
Execution identifier returned from trigger endpoint
Query Parameters
Include full node input/output data
Example Request
curl -X GET "https://api.so1.io/v1/control-plane/workflows/executions/exec-abc123?includeData=true" \
-H "Authorization: Bearer so1_key_abc123xyz"
Response
Example Response (Running)
{
"success": true,
"data": {
"executionId": "exec-abc123xyz789",
"workflowId": "deployment-pipeline",
"workflowName": "Production Deployment Pipeline",
"status": "running",
"progress": {
"nodesCompleted": 4,
"nodesTotal": 7,
"currentNode": "Railway Deploy"
},
"startedAt": "2024-03-10T15:30:00Z",
"estimatedCompletionAt": "2024-03-10T15:33:00Z"
}
}
Example Response (Completed with Data)
{
"success": true,
"data": {
"executionId": "exec-abc123xyz789",
"workflowId": "deployment-pipeline",
"workflowName": "Production Deployment Pipeline",
"status": "completed",
"result": {
"success": true,
"outputs": {
"deploymentId": "dep-xyz123",
"deploymentUrl": "https://api-production.railway.app",
"healthCheckPassed": true,
"rollbackRequired": false
},
"nodesExecuted": 7,
"duration": 142.5
},
"nodeData": [
{
"nodeName": "Validate Version",
"nodeType": "n8n-nodes-base.function",
"status": "completed",
"duration": 0.3,
"output": { "valid": true, "version": "v2.4.1" }
},
{
"nodeName": "Railway Deploy",
"nodeType": "n8n-nodes-base.httpRequest",
"status": "completed",
"duration": 125.8,
"output": { "deploymentId": "dep-xyz123", "status": "live" }
}
// ... more nodes
],
"startedAt": "2024-03-10T15:30:00Z",
"completedAt": "2024-03-10T15:32:22.5Z"
}
}
Example Response (Failed)
{
"success": true,
"data": {
"executionId": "exec-abc123xyz789",
"workflowId": "deployment-pipeline",
"status": "failed",
"error": {
"code": "NODE_EXECUTION_FAILED",
"message": "Railway deployment failed: Health check timeout",
"nodeName": "Railway Deploy",
"details": {
"httpStatus": 500,
"railwayError": "Service failed to respond to health checks after 60s"
}
},
"startedAt": "2024-03-10T15:30:00Z",
"failedAt": "2024-03-10T15:31:15Z",
"duration": 75
}
}
List Workflow Executions
Retrieve paginated list of workflow executions with filtering.
Endpoint
GET /v1/control-plane/workflows/executions
Query Parameters
Filter by specific workflow
Filter by status: running, completed, failed, waiting, cancelled
ISO 8601 date - filter executions after this date
ISO 8601 date - filter executions before this date
Example Request
curl -X GET "https://api.so1.io/v1/control-plane/workflows/executions?workflowId=deployment-pipeline&status=completed&limit=10" \
-H "Authorization: Bearer so1_key_abc123xyz"
Response
{
"success": true,
"data": {
"executions": [
{
"executionId": "exec-abc123",
"workflowId": "deployment-pipeline",
"status": "completed",
"startedAt": "2024-03-10T15:30:00Z",
"completedAt": "2024-03-10T15:32:22Z",
"duration": 142.5
}
// ... more executions
],
"pagination": {
"total": 342,
"limit": 10,
"offset": 0,
"hasMore": true
}
}
}
Cancel Execution
Stop a running workflow execution.
Endpoint
POST /v1/control-plane/workflows/executions/{executionId}/cancel
Request Body
Cancellation reason (optional, for audit logs)
Example Request
curl -X POST https://api.so1.io/v1/control-plane/workflows/executions/exec-abc123/cancel \
-H "Authorization: Bearer so1_key_abc123xyz" \
-H "Content-Type: application/json" \
-d '{"reason": "Superseded by newer deployment"}'
Response
{
"success": true,
"data": {
"executionId": "exec-abc123",
"status": "cancelled",
"cancelledAt": "2024-03-10T15:35:00Z"
}
}
List Workflows
Get all available workflows with metadata.
Endpoint
GET /v1/control-plane/workflows
Query Parameters
Filter workflows by tag (e.g., deployment, notification, automation)
Example Request
curl -X GET "https://api.so1.io/v1/control-plane/workflows?tag=deployment&active=true" \
-H "Authorization: Bearer so1_key_abc123xyz"
Response
{
"success": true,
"data": {
"workflows": [
{
"workflowId": "deployment-pipeline",
"name": "Production Deployment Pipeline",
"description": "Automated deployment to Railway with health checks and rollback",
"tags": ["deployment", "production", "railway"],
"active": true,
"version": 3,
"nodes": 7,
"averageDuration": 145.2,
"executionCount": 1247,
"successRate": 98.4,
"lastExecutedAt": "2024-03-10T15:30:00Z",
"webhookUrl": "https://n8n.so1.io/webhook/deployment-pipeline"
},
{
"workflowId": "user-onboarding",
"name": "User Onboarding Automation",
"description": "Create user account, send welcome email, setup workspace",
"tags": ["automation", "onboarding", "users"],
"active": true,
"version": 2,
"nodes": 8,
"averageDuration": 3.1,
"executionCount": 5623,
"successRate": 99.7,
"lastExecutedAt": "2024-03-10T15:28:00Z"
}
]
}
}
Register Webhook
Register a new webhook trigger for a workflow.
Endpoint
POST /v1/control-plane/workflows/{workflowId}/webhooks
Path Parameters
Workflow to attach webhook
Request Body
Webhook URL path (e.g., /deploy, /github-push)
HTTP method: GET, POST, PUT, PATCH, DELETE
Webhook authentication settings
Auth type: none, apiKey, hmac, oauth
Header name for API key auth (e.g., X-API-Key)
Secret for HMAC signature verification
Example Request
curl -X POST https://api.so1.io/v1/control-plane/workflows/deployment-pipeline/webhooks \
-H "Authorization: Bearer so1_key_abc123xyz" \
-H "Content-Type: application/json" \
-d '{
"path": "/deploy",
"method": "POST",
"authentication": {
"type": "hmac",
"hmacSecret": "webhook_secret_abc123"
}
}'
Response
{
"success": true,
"data": {
"webhookId": "wh-xyz789",
"workflowId": "deployment-pipeline",
"url": "https://n8n.so1.io/webhook/deploy",
"method": "POST",
"active": true,
"createdAt": "2024-03-10T15:30:00Z"
}
}
Workflow Scheduling
Schedule recurring workflow executions.
Endpoint
POST /v1/control-plane/workflows/{workflowId}/schedule
Request Body
Cron expression (e.g., 0 2 * * * for daily at 2 AM UTC)
IANA timezone (e.g., America/New_York)
Default payload for scheduled executions
Enable schedule immediately
Example Request
curl -X POST https://api.so1.io/v1/control-plane/workflows/backup-database/schedule \
-H "Authorization: Bearer so1_key_abc123xyz" \
-H "Content-Type: application/json" \
-d '{
"cron": "0 2 * * *",
"timezone": "America/New_York",
"payload": {
"database": "production",
"retentionDays": 30
},
"enabled": true
}'
Response
{
"success": true,
"data": {
"scheduleId": "sch-abc123",
"workflowId": "backup-database",
"cron": "0 2 * * *",
"timezone": "America/New_York",
"nextRunAt": "2024-03-11T02:00:00-04:00",
"enabled": true
}
}
Common Patterns
Wait for Workflow Completion
async function waitForWorkflowCompletion(executionId: string): Promise<any> {
const maxAttempts = 120; // 10 minutes
for (let attempt = 0; attempt < maxAttempts; attempt++) {
const response = await fetch(
`https://api.so1.io/v1/control-plane/workflows/executions/${executionId}`,
{ headers: { 'Authorization': `Bearer ${process.env.SO1_API_KEY}` } }
);
const { data } = await response.json();
if (data.status === 'completed') {
return data.result;
} else if (data.status === 'failed') {
throw new Error(data.error.message);
}
await new Promise(resolve => setTimeout(resolve, 5000));
}
throw new Error('Workflow timeout');
}
Trigger Workflow with Retry Logic
async function triggerWorkflowWithRetry(
workflowId: string,
payload: any,
maxRetries: number = 3
): Promise<string> {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
const response = await fetch(
'https://api.so1.io/v1/control-plane/workflows/trigger',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SO1_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ workflowId, payload })
}
);
if (!response.ok) throw new Error('Trigger failed');
const { data } = await response.json();
return data.executionId;
} catch (error) {
if (attempt === maxRetries - 1) throw error;
await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, attempt)));
}
}
throw new Error('Max retries exceeded');
}
Error Codes
| Code | Description | Resolution |
|---|
WORKFLOW_NOT_FOUND | Workflow ID does not exist | Check available workflows |
WORKFLOW_INACTIVE | Workflow is deactivated | Activate workflow in n8n |
EXECUTION_FAILED | Workflow execution error | Check node error details |
WEBHOOK_INVALID | Invalid webhook configuration | Verify path and authentication |
SCHEDULE_INVALID | Invalid cron expression | Use valid cron syntax |
PAYLOAD_TOO_LARGE | Workflow payload exceeds 5MB | Reduce payload size |