Workflows & Automation
Chain email, SMS, billing calls, and CRUD writes into declarative, auditable multi-step flows that run on their own — triggered directly, or fired automatically when your data changes.
What a workflow is
{
"workflow_id": "order_invoice_on_payment",
"display_name": "Order Invoice on Payment",
"description": "Emails an invoice once an order is marked paid, then stamps the order.",
"version": "1.0.0",
"status": "Active",
"enabled": True,
"on_error": "continue",
"input_schema": {
"order_uuid": {"type": "string", "required": True},
"payment_state": {"type": "string", "required": True},
},
"steps": [ /* see "The six step types" below */ ],
}curl -X POST https://api.supero.dev/api/v1/services/execute \
-H "X-API-Key: $SUPERO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"service_id": "workflows",
"operation": "run_workflow",
"domain": "acme",
"input": {
"workflow_id": "order_invoice_on_payment",
"input": {"order_uuid": "3f9c1e2a-6b7d-4e11-9c2f-2a6f1d0b9a10", "payment_state": "paid"}
}
}'Two levels of "input"
Anatomy of a workflow definition
| Field | Type | Required | Notes |
|---|---|---|---|
| workflow_id | string | yes | Stable snake_case id used everywhere else — event bindings, direct run_workflow calls, the dashboard. e.g. order_invoice_on_payment. |
| display_name | string | yes | Human-readable name shown in the dashboard. |
| description | string | no | What the workflow does. |
| version | string | no | Free-form version string. |
| status | string | yes | Draft, Active, Disabled, or Archived — see below. |
| enabled | boolean | no | Set false to pause a workflow without changing status. Defaults to true. |
| input_schema | json | no | {field: {type, required}} — validated before the first step runs. A missing required field fails the run before any step (and any side effect) fires. |
| steps | json | yes | The ordered list of step objects — see "The six step types" below. |
| on_error | string | no | Default error strategy for steps that don't set their own: stop (default), continue, retry, or compensate. compensate turns the workflow into a saga — see Saga Compensation below. |
| max_retries | integer | no | Retries per step when on_error is retry. Default 3. |
| retry_delay_seconds | integer | no | Delay between retries, in seconds. Default 2. |
| timeout_seconds | integer | no | Overall time budget for the whole run. |
| tags | string | no | Comma-separated, for organizing workflows in the dashboard. |
status — the four states
| status | Meaning |
|---|---|
| Draft | Saved but not runnable. A direct run_workflow call and an event binding both fail with an explicit "in Draft status" error rather than silently no-op'ing. |
| Active | Runs normally, whether triggered directly or by an event binding. This is the only state that actually executes steps. |
| Disabled | Registered but blocked from running — same effect as enabled: false. |
| Archived | Retired; blocked from running, kept for history. |
A workflow must be Active + enabled to run
Validate before you activate
The six step types
| type | Purpose | Key fields |
|---|---|---|
| service_call | Call an operation on another imported service — email, sms, slack, billing, and the rest of the catalog. | service, operation, input_map, on_error |
| crud_operation | Create, read, update, or delete a record in your own data. | operation (create/read/update/delete), object_type, record_uuid, data |
| condition | Branch on a resolved value. | condition, then_steps, else_steps |
| parallel | Run a list of sub-steps concurrently; each is tracked individually in the run's results. | steps (a sub-step array) |
| transform | Pure data reshaping between steps — no external call. | output_map |
| loop | Run a body of sub-steps repeatedly until a condition holds or a ceiling is reached. This is the step that makes agent-style flows possible. | steps (a sub-step array), until, max_iterations |
loop
{
"id": "agent",
"type": "loop",
"max_iterations": 5,
"until": "{{steps.think.output.has_tool_calls}} == false",
"steps": [ /* body — runs sequentially, each sub-step sees the previous output */ ]
}until is evaluated after each iteration, so the body always runs at least once
crud_operation
{
"id": "mark_paid",
"type": "crud_operation",
"operation": "update",
"object_type": "acmestore:order",
"record_uuid": "{{input.order_uuid}}",
"data": {"workflow_status": "processed", "processed_at": "{{context.timestamp}}"}
}object_type must be namespace-qualified
condition
{
"id": "check_paid",
"type": "condition",
"condition": "{{input.payment_state}} == paid",
"then_steps": [ /* only run when the condition is true */ ],
"else_steps": [ ]
}parallel
{
"id": "notify_all_channels",
"type": "parallel",
"steps": [
{"id": "email_notify", "type": "service_call", "service": "email", "operation": "send_email", "on_error": "continue", "input_map": {"to_email": "{{input.email}}", "subject": "Shipped!", "body_html": "<p>Your order is on its way.</p>"}},
{"id": "sms_notify", "type": "service_call", "service": "sms", "operation": "send_sms", "on_error": "continue", "input_map": {"to_number": "{{input.phone}}", "body": "Your order has shipped."}}
]
}transform
{
"id": "prepare_invoice_data",
"type": "transform",
"output_map": {
"customer_email": "{{steps.get_customer.output.email}}",
"invoice_amount": "{{steps.calculate_total.output.total}}"
}
}Wiring data between steps
| Pattern | Resolves to | Example |
|---|---|---|
| {{input.field}} | A field from the workflow's own input | {{input.email}} |
| {{steps.<id>.output.field}} | A field from a prior step's output | {{steps.create_order.output.order_number}} |
| {{steps.<id>.status}} | A prior step's status (completed/failed/skipped) | {{steps.send_email.status}} |
| {{context.domain}} | The domain running the workflow | acme |
| {{context.timestamp}} | Current ISO-8601 timestamp | 2026-07-18T10:30:00Z |
| {{context.workflow_id}} | The running workflow's own id | order_invoice_on_payment |
Triggering a workflow
Event bindings
| Event | Fires when |
|---|---|
| @create:ns:type | A new record of that schema is created |
| @update:ns:type | An existing record of that schema is written |
| @delete:ns:type | A record of that schema is deleted |
| @signup | A new tenant_user completes signup through the app's own login page |
{
"event": "@signup",
"workflow_id": "welcome_on_signup",
"input_map": {"email": "user.email", "name": "user.full_name"}
}Reference hydration — multi-hop paths
{
"event": "@create:acmestore:order_item",
"workflow_id": "item_added_notification",
"input_map": {
"product_name": "product_name",
"customer_email": "order.customer.email"
}
}Registering bindings
Worked example — transactional email
welcome_on_signup — fires on @signup
{
"workflow_id": "welcome_on_signup",
"display_name": "Welcome Email",
"status": "Active", "enabled": True, "on_error": "continue",
"input_schema": {
"email": {"type": "string", "required": True},
"name": {"type": "string", "required": False},
},
"steps": [
{"id": "email", "type": "service_call", "service": "email", "operation": "send_email",
"on_error": "continue",
"input_map": {
"to_email": "{{input.email}}",
"subject": "Welcome to Acme Store!",
"body_html": "<p>Hi {{input.name}}, thanks for joining — your account is ready.</p>"}},
],
}order_invoice_on_payment — fires on @update:acmestore:order
{
"workflow_id": "order_invoice_on_payment",
"display_name": "Order Invoice on Payment",
"status": "Active", "enabled": True, "on_error": "continue",
"input_schema": {
"order_uuid": {"type": "string", "required": True},
"payment_state": {"type": "string", "required": True},
},
"steps": [
{"id": "check_paid", "type": "condition",
"condition": "{{input.payment_state}} == paid",
"then_steps": [
{"id": "email", "type": "service_call", "service": "email", "operation": "send_email",
"on_error": "continue",
"input_map": {
"to_email": "{{input.customer_email}}",
"subject": "Your Acme Store invoice",
"body_html": "<p>Thanks for your payment — order {{input.order_number}} is confirmed.</p>"}},
# Final step MUST stamp workflow_status so the UI status chip updates.
{"id": "mark_processed", "type": "crud_operation", "operation": "update",
"object_type": "acmestore:order", "record_uuid": "{{input.order_uuid}}",
"data": {"workflow_status": "processed", "processed_at": "{{context.timestamp}}"}},
],
"else_steps": []},
],
}[
{"event": "@signup", "workflow_id": "welcome_on_signup",
"input_map": {"email": "user.email", "name": "user.full_name"}},
{"event": "@update:acmestore:order", "workflow_id": "order_invoice_on_payment",
"input_map": {"order_uuid": "uuid", "order_number": "order_number",
"customer_email": "customer_email", "payment_state": "payment_state"}}
]send_email's input_map fields
End effectful workflows with a CRUD stamp
Saga Compensation — Undoing a Half-Finished Run
compensate makes a compensate block mandatory on every step
| compensate.kind | What it means |
|---|---|
automatic | The platform runs a known inverse operation. Used where the forward operation has a defined opposite. |
manual | A person has to intervene. The run records what needs undoing rather than undoing it. |
skip_acknowledged | There is genuinely nothing to undo, and you are saying so deliberately. Requires a reason. This is the canonical spelling — skip is rejected. |
none | No compensation. Reserve it for steps with no external effect. |
automatic compensation the platform keeps a catalog of inverse operations, so common forward operations already know how to reverse themselves.| Forward operation | Inverse |
|---|---|
create_subscription | cancel_subscription |
create_checkout_session | expire_session |
create_customer | delete_customer |
archive_attachment | unarchive_attachment |
adjust_quantity | adjust_quantity — self-inverse, applied with the opposite delta |
{
"id": "charge_customer",
"type": "service_call",
"service": "stripe_checkout",
"operation": "create_checkout_session",
"input_map": {"customer_uuid": "{{input.customer_uuid}}", "amount": "{{input.total}}"},
"compensate": {
"kind": "automatic",
"operation": "expire_session",
"input_map": {"session_id": "{{steps.charge_customer.output.session_id}}"},
},
}{
"id": "send_confirmation",
"type": "service_call",
"service": "email",
"operation": "send_email",
"input_map": {"to_email": "{{input.email}}", "subject": "Order confirmed"},
"compensate": {
"kind": "skip_acknowledged",
"reason": "An email that has already been delivered cannot be recalled; \
a correction email is sent by the failure handler instead.",
},
}Money steps deserve a second look
A compensate block is a single step, not a branch
Checking a run
curl -X POST https://api.supero.dev/api/v1/crud/acme/query \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "wf:workflow_instance",
"filters": {"workflow_id": "order_invoice_on_payment"},
"sort": [{"field": "started_at", "order": "desc"}],
"limit": 10
}'runs = org.crud.query("wf:workflow_instance") \
.filter(workflow_id="order_invoice_on_payment") \
.order_by("-started_at").limit(10).all()
steps = org.crud.query("wf:workflow_step_log") \
.filter(instance_uuid=runs[0]["uuid"]) \
.order_by("step_index").all()| workflow_instance field | Meaning |
|---|---|
| status | running, completed, failed, or partial (some steps succeeded, some failed under on_error: continue). A saga adds two more: compensated, and compensation_failed. See the Workflow Engine Reference for the full set. |
| steps_completed / steps_total / steps_failed | Counts, including branch and parallel sub-steps. |
| current_step | The id of the currently running (or last executed) step. |
| error_message | Populated on the first failure. |
| output_data | Per-step outputs keyed by step_id. |
| step_results | Per-step status, output, and duration_ms, keyed by step_id. |
| duration_ms, started_at, completed_at | Timing for the whole run. |
| workflow_step_log field | Meaning |
|---|---|
| status | running, completed, failed, or skipped. |
| step_type, service_id, operation_id | What the step was and, for service_call, what it targeted. |
| input_sent / output_received | Exact resolved input and the raw output for that step. |
| duration_ms, retry_count | Timing and how many retries were attempted. |
A silent send is a configuration problem, not a workflow bug
Simulation mode on self-hosted deployments
Services available to service_call steps
| service | operation | Key input_map fields |
|---|---|---|
| send_email | to_email, subject, body_html or body_text, from_name | |
| sms | send_sms | to_number, body |
| send_message | to_number, body | |
| push_notification | send_notification | device_token, title, body |
| slack | send_message | channel, text |
| billing | create_invoice | customer_uuid, amount, currency, due_date |
| stripe_checkout | create_checkout_session | success_url, amount, product_name |
| salesforce | create_lead | last_name, company, email |
| google_calendar | create_event | summary, start_time, end_time, add_meet |
| auth_otp | send_otp | channel, recipient, purpose |
Next steps
- Workflow Engine Reference — the exhaustive step, template and saga reference behind this page.
- Anatomy of a Supero App — where setup.py's workflow_definitions and event_bindings fit in the app bundle.
- Transactional Services — the managed services catalog workflows call into, and how services get imported and configured.
- Managing Data — the full CRUD API workflows read and write against.
- API Integrations — bringing external services into the catalog that a workflow can call.
- Workflow Orchestration — a worked end-to-end orchestration pattern.
On this page