Open MercatoDocsSearch docsAPI reference

User guide

Transitions

Draw a transition for each permitted path out of a step. Use its trigger and conditions to describe when the run should take that path.

When more than one transition may match, review its priority and any configured activities.

What Are Transitions?

A transition represents a possible path from one step to another. When a step completes, the workflow engine evaluates all outgoing transitions to determine where to go next.

Key Concepts:

Trigger Types

Transitions can be triggered in different ways depending on your workflow needs.

auto (Automatic)

The transition fires immediately when the source step completes.

{
  "transitionId": "start-to-review",
  "fromStepId": "start",
  "toStepId": "review-request",
  "trigger": "auto"
}

Use When:

manual (Manual)

The transition requires explicit user action (e.g., clicking "Approve" or "Reject" on a user task).

{
  "transitionId": "review-to-approved",
  "fromStepId": "review-request",
  "toStepId": "end-approved",
  "trigger": "manual",
  "transitionName": "Approve"
}

Use When:

signal (Signal-Based)

The transition fires when a specific signal is received.

{
  "transitionId": "wait-to-continue",
  "fromStepId": "wait-for-payment",
  "toStepId": "fulfill-order",
  "trigger": "signal",
  "preConditions": [
    {
      "ruleId": "payment-confirmed",
      "expression": "signal.name === 'payment-confirmed'"
    }
  ]
}

Use When:

Learn more about signals →

timer (Timer-Based)

The transition fires after a specified duration.

{
  "transitionId": "escalate-after-delay",
  "fromStepId": "wait-for-response",
  "toStepId": "escalated",
  "trigger": "timer",
  "timerConfig": {
    "duration": "2 days"
  }
}

Use When:

Conditions

Transitions can have pre-conditions and post-conditions that determine whether they can be taken.

Pre-Conditions

Evaluated before the transition fires. If any pre-condition fails, the transition is skipped.

{
  "transitionId": "approve-high-value",
  "fromStepId": "review",
  "toStepId": "end-approved",
  "trigger": "manual",
  "preConditions": [
    {
      "ruleId": "amount-check",
      "expression": "context.amount <= 10000"
    }
  ]
}

Use Cases:

Post-Conditions

Evaluated after the transition activities execute. If any post-condition fails, the workflow enters an error state.

{
  "transitionId": "charge-payment",
  "fromStepId": "validate",
  "toStepId": "fulfilled",
  "trigger": "auto",
  "postConditions": [
    {
      "ruleId": "payment-success",
      "expression": "activities.charge-payment.output.status === 'succeeded'"
    }
  ]
}

Use Cases:

Business Rules Integration

Conditions can reference business rules defined in the business rules module:

{
  "preConditions": [
    {
      "ruleId": "approval-required",
      "ruleReference": "purchase.requires-approval"
    }
  ]
}

Learn more about business rules →

Priority

When multiple transitions from the same step are valid, priority determines which one is taken.

{
  "transitionId": "high-priority-path",
  "fromStepId": "decision",
  "toStepId": "fast-track",
  "trigger": "auto",
  "priority": 100,
  "preConditions": [
    {
      "ruleId": "urgent",
      "expression": "context.priority === 'urgent'"
    }
  ]
}
{
  "transitionId": "normal-priority-path",
  "fromStepId": "decision",
  "toStepId": "standard-process",
  "trigger": "auto",
  "priority": 0
}

Priority Rules:

Use Cases:

Activities on Transitions

Transitions can execute activities as the workflow moves from one step to another.

{
  "transitionId": "approve-and-notify",
  "fromStepId": "review",
  "toStepId": "end-approved",
  "trigger": "manual",
  "activities": [
    {
      "activityId": "send-approval-email",
      "activityName": "Send Approval Email",
      "activityType": "SEND_EMAIL",
      "config": {
        "to": "{{context.requesterEmail}}",
        "subject": "Your request has been approved",
        "body": "Request {{context.requestId}} has been approved."
      }
    },
    {
      "activityId": "update-status",
      "activityName": "Update Request Status",
      "activityType": "UPDATE_ENTITY",
      "config": {
        "commandId": "sales.orders.update",
        "statusDictionary": "sales.order_status",
        "input": {
          "id": "{{context.requestId}}",
          "statusValue": "approved"
        }
      }
    }
  ]
}

Use Cases:

Learn more about activities →

Example: Multi-Path Approval Workflow

Here's a complete example showing conditional routing:

Example approval routes for three amount bands
The example approves small requests immediately and sends larger amounts to a manager or director.
Diagram source
graph TD
    START --> REVIEW[Review Request]
    REVIEW -->|1,000 or less| APPROVED[Auto-Approved]
    REVIEW -->|over 1,000 through 10,000| MANAGER[Manager Approval]
    REVIEW -->|over 10,000| DIRECTOR[Director Approval]
    MANAGER --> APPROVED
    MANAGER --> REJECTED[Rejected]
    DIRECTOR --> APPROVED
    DIRECTOR --> REJECTED

    classDef focus fill:#e0f29c,stroke:#34402d,color:#172011,stroke-width:2px
    class REVIEW focus

Transitions:

  1. START → Review Request (auto, no conditions)
  2. Review → Auto-Approved (auto, priority 100, if amount ≤ $1000)
  3. Review → Manager Approval (auto, priority 50, if amount ≤ $10,000)
  4. Review → Director Approval (auto, priority 0, fallback)
  5. Manager → Approved (manual, sends email)
  6. Manager → Rejected (manual, sends email)
  7. Director → Approved (manual, sends email)
  8. Director → Rejected (manual, sends email)

Handling Failures

Compensation

When a transition's post-condition fails or an activity throws an error, compensation activities can roll back changes (saga pattern).

{
  "activities": [
    {
      "activityId": "reserve-inventory",
      "activityType": "CALL_API",
      "config": { "url": "..." },
      "compensate": true,
      "compensationActivity": {
        "activityType": "CALL_API",
        "config": {
          "url": "https://inventory.example.com/release/{{context.productId}}"
        }
      }
    }
  ]
}

Learn more about compensation →

Continue on Failure

By default, if an activity fails, the workflow stops. You can override this:

{
  "transitionId": "attempt-notification",
  "continueOnActivityFailure": true,
  "activities": [
    {
      "activityType": "SEND_EMAIL",
      "config": { "to": "{{context.email}}" }
    }
  ]
}

Error Routes

A transition can be marked as an error route with "kind": "error". It is only ever taken when its source step fails – normal routing ignores it entirely – so adding one can never change the happy path.

{
  "transitionId": "charge-failed",
  "fromStepId": "charge_card",
  "toStepId": "notify_finance",
  "kind": "error",
  "trigger": "auto"
}

When an error route is followed, the failure is published into the run context under the reserved key __error, so the recovery path can read what went wrong. In the Studio, steps that can fail grow an error output handle and error routes render as red dashed lines with a warning icon.

Error Directives

When a step fails and has no error route wired, its errorDirective decides what happens:

ModeEffect
failThe workflow fails. This is the default and what happens when no directive is set.
continueWithFallbackThe run carries on. The step itself stays FAILED – the history is not rewritten – and fallbackValue is written into the context under the failing step's id.
failureQueueThe run is parked rather than failed: it is paused and flagged as needing attention, so it can be resumed after somebody fixes the cause. Because it is suspended and not terminated, compensation does not run.
{
  "stepId": "charge_card",
  "stepType": "AUTOMATED",
  "errorDirective": { "mode": "continueWithFallback", "fallbackValue": { "charged": false } }
}

Workflow-Level Error Handler

As a last resort, a definition can declare one errorHandler – exactly one of two forms:

{ "errorHandler": { "stepId": "cleanup" } }

Jumps to a step inside the same workflow, with __error in context. A step never jumps to itself.

{ "errorHandler": { "workflowId": "ops.incident-triage", "version": 2 } }

Starts another workflow as a catch-all, with the failed step id, the error and a snapshot of the context as its input. It is scheduled before compensation runs, so the snapshot describes the failure rather than the cleanup, and it still runs when compensation itself throws. Catch-all handlers do not nest: a handler workflow that fails does not trigger another one.

The order is always: a wired error route first, then the step's directive, then the workflow-level handler, then plain failure.

Routes on the Canvas

Routes carry their configuration on their face, so a decision is readable without opening anything:

Route priority is edited by dragging a step's outgoing routes into the order you want them tried, rather than by typing numbers; the numeric priority is derived from that order. Decision steps (IF_ELSE, SWITCH) get the same ordering through their case list instead, so there is only ever one control for it.

Next Steps

See Also:

Previous: Step Types · Next: User Tasks