API Reference
Complete HTTP API reference for Stepflow
API Reference
Stepflow exposes a REST API through framework adapters. All adapters implement the same endpoints.
Base URL
The base URL depends on your adapter configuration:
// Hono
app.route("/api/stepflow", createStepflowRoutes(stepflow));
// Express
app.use("/api/stepflow", createStepflowRouter(stepflow));
// Next.js
// Routes are at /api/stepflow/[...path]Authentication
Stepflow supports multiple authentication methods:
API Key
curl -X POST https://api.example.com/api/stepflow/trigger/my-workflow \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"userId": "123"}'Bearer Token
curl -X POST https://api.example.com/api/stepflow/trigger/my-workflow \
-H "Authorization: Bearer your-jwt-token" \
-H "Content-Type: application/json" \
-d '{"userId": "123"}'Public Access Token
For client-side run monitoring:
curl https://api.example.com/api/stepflow/runs/run_123?token=pat_xyzEndpoints
Trigger Workflow
Start a new workflow execution.
POST /trigger/{workflowId}Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
workflowId | path | string | Yes | Workflow identifier |
Request Body:
{
"userId": "user_123",
"email": "user@example.com"
}Response:
{
"runId": "run_abc123",
"publicAccessToken": "pat_xyz789"
}Status Codes:
| Code | Description |
|---|---|
| 200 | Workflow triggered successfully |
| 400 | Invalid request body |
| 401 | Unauthorized |
| 404 | Workflow not found |
Get Run
Retrieve the current status of a workflow run.
GET /runs/{runId}Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
runId | path | string | Yes | Run identifier |
token | query | string | No | Public access token |
Response:
{
"id": "run_abc123",
"workflowId": "welcome-user",
"status": "running",
"input": {
"userId": "user_123",
"email": "user@example.com"
},
"steps": [
{
"name": "send-welcome",
"status": "completed",
"result": { "sent": true }
},
{
"name": "send-followup",
"status": "pending"
}
],
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:31:00Z"
}Run Status Values:
| Status | Description |
|---|---|
pending | Run is queued |
running | Run is executing |
completed | Run finished successfully |
failed | Run failed with error |
cancelled | Run was cancelled |
Stream Run Updates
Subscribe to real-time updates via Server-Sent Events (SSE).
GET /runs/{runId}/streamParameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
runId | path | string | Yes | Run identifier |
token | query | string | No | Public access token |
Response:
event: status
data: {"status":"running","stepName":"send-email"}
event: step
data: {"name":"send-email","status":"completed","result":{"sent":true}}
event: complete
data: {"status":"completed","result":{"success":true}}Event Types:
| Event | Description |
|---|---|
status | Run status changed |
step | Step completed or failed |
complete | Run finished |
error | Run failed |
Notify Event
Send an event to a waiting workflow.
POST /notify/{eventId}Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
eventId | path | string | Yes | Event identifier |
Request Body:
{
"status": "paid",
"amount": 99.99,
"transactionId": "txn_456"
}Response:
{
"success": true
}Health Check
Check service health status.
GET /healthResponse:
{
"status": "ok",
"timestamp": "2024-01-15T10:30:00Z"
}OpenAPI Specification
The complete OpenAPI 3.1 specification is available at:
- YAML: /openapi.yaml
You can import this into tools like Postman, Insomnia, or use it to generate client SDKs.
Error Responses
All error responses follow this format:
{
"error": "Workflow not found",
"code": "WORKFLOW_NOT_FOUND"
}Common error codes:
| Code | HTTP Status | Description |
|---|---|---|
WORKFLOW_NOT_FOUND | 404 | Workflow ID doesn't exist |
RUN_NOT_FOUND | 404 | Run ID doesn't exist |
EVENT_NOT_FOUND | 404 | Event ID doesn't exist |
UNAUTHORIZED | 401 | Missing or invalid auth |
INVALID_INPUT | 400 | Request body validation failed |