Workflows API Reference

Complete REST API reference for AI Workflows.

Base URL

base-url
https://api.stack0.dev/v1

Authentication

All API requests require authentication using your API key:

authentication
curl -X POST https://api.stack0.dev/v1/workflows \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{"projectSlug": "my-project", "slug": "my-workflow", "name": "My Workflow"}'
POST/workflows

Create a new workflow.

Request Body

FieldTypeDescription
projectSlugstringProject identifier (required)
slugstringUnique workflow slug (required)
namestringDisplay name (required)
descriptionstringWorkflow description
stepsStepDefinition[]Array of step definitions
variablesobjectVariable definitions
request-body.json
{
"projectSlug": "my-project",
"slug": "content-pipeline",
"name": "Content Pipeline",
"steps": [
{
"id": "step-1",
"type": "llm",
"name": "Generate",
"provider": "anthropic",
"model": "claude-3-5-sonnet-20241022",
"prompt": "Write about {{topic}}"
}
],
"variables": {
"topic": { "type": "string", "required": true }
}
}
GET/workflows

List all workflows for a project.

Query Parameters

ParameterTypeDescription
projectSlugstringProject identifier (required)
limitnumberMax results (default: 20)
offsetnumberPagination offset
GET/workflows/:id

Get a specific workflow by ID.

PATCH/workflows/:id

Update a workflow.

DELETE/workflows/:id

Delete a workflow.

POST/workflows/:id/run

Start a workflow run.

Request Body

FieldTypeDescription
projectSlugstringProject identifier (required)
variablesobjectInput variables
webhookobjectWebhook configuration
metadataobjectCustom metadata
run-request.json
{
"projectSlug": "my-project",
"variables": {
"topic": "AI in Healthcare"
},
"webhook": {
"url": "https://yourapp.com/webhook",
"secret": "your-secret"
},
"metadata": {
"userId": "user_123"
}
}

Response

run-response.json
{
"id": "run_xyz789",
"workflowId": "workflow_abc123",
"status": "pending",
"variables": { "topic": "AI in Healthcare" },
"metadata": { "userId": "user_123" },
"totalSteps": 2,
"completedSteps": 0,
"createdAt": "2025-01-15T10:30:00Z"
}
GET/workflows/runs/:id

Get a workflow run by ID.

Response

get-run-response.json
{
"id": "run_xyz789",
"workflowId": "workflow_abc123",
"status": "completed",
"variables": { "topic": "AI in Healthcare" },
"output": {
"outline": "1. Introduction...",
"content": "AI is transforming healthcare..."
},
"stepStates": {
"generate-outline": {
"status": "completed",
"startedAt": "2025-01-15T10:30:01Z",
"completedAt": "2025-01-15T10:30:05Z",
"attempts": 1
},
"write-content": {
"status": "completed",
"startedAt": "2025-01-15T10:30:05Z",
"completedAt": "2025-01-15T10:30:12Z",
"attempts": 1
}
},
"totalSteps": 2,
"completedSteps": 2,
"totalDurationMs": 11000,
"creditsUsed": 15,
"startedAt": "2025-01-15T10:30:01Z",
"completedAt": "2025-01-15T10:30:12Z",
"createdAt": "2025-01-15T10:30:00Z"
}
GET/workflows/runs

List workflow runs.

Query Parameters

ParameterTypeDescription
projectSlugstringProject identifier (required)
workflowIdstringFilter by workflow ID
statusstringpending, running, completed, failed, cancelled
limitnumberMax results (default: 50)
offsetnumberPagination offset
POST/workflows/runs/:id/cancel

Cancel a running workflow.

Step Definition

Structure of a workflow step:

FieldTypeDescription
idstringUnique step identifier
typestringllm, image, video, audio, code, http, transform, condition, loop
namestringDisplay name
providerstringanthropic, openai, gemini, replicate, stack0
modelstringModel identifier
promptstringPrompt template (supports {{variables}})
dependsOnstring[]Step IDs this step depends on
outputVariablestringName for output in result

Run Status Values

StatusDescription
pendingRun created, waiting to start
runningWorkflow executing steps
completedAll steps completed successfully
failedOne or more steps failed
cancelledRun was cancelled