Variables and Expressions
Use variables and expressions to reference workflow input, earlier step outputs, and computed values at runtime.
Workflow steps often reference values that are not known until runtime: the workflow input, the output of an earlier step, or a derived value computed from both. Use the ${...} template syntax inside any string field of a step.
Template syntax
A ${...} reference can appear anywhere a string is accepted in a step. It is resolved every time the step runs, just before the step executes. Each step sees the latest workflow input and every previously-completed step's outputs.
There are four forms.
| Form | Description |
|---|---|
${input.<field>} or ${input.<nested.path>} | Reads from the workflow's input object (the payload that the trigger provided). |
${steps.<name>.output.<field>} | Reads from a named earlier step's output. You can use the step index instead of the name (${steps.0.output.<field>}). |
${<field>} (no dot) | Backward-compatible shorthand that resolves to input.<field>. Prefer the explicit ${input.<field>} form for clarity. |
${expr: <expression>} | Evaluates an inline expression using the same engine as the compute step. |
Examples
# Read workflow input
amount: "${input.amount}"
# Read a named step's output
amount: "${steps.calc_split.output.bank_share}"
# Read a step output by index
amount: "${steps.0.output.transfer_id}"
# Backward-compatible flat input lookup
amount: "${amount}"
# Inline expression
amount: "${expr: monetary_max(input.requested_amount - input.fee, 0)}"Forward references are rejected
A step can only reference earlier steps. Referring to a step that comes later in the workflow is rejected at validation time, before the workflow is persisted. This guarantees that every ${steps.<name>...} resolution has a value available when the step runs.
invalid_workflow_definition: step "send_to_bank" references a later step "calc_split"
field_path: steps[0].send_money.amountInline expressions
${expr: ...} evaluates an expression using a sandboxed engine. The expression has access to:
input.<field>: every workflow input field.steps.<name>.output.<field>: every previously-completed step's output.- The monetary helper functions listed below.
Expressions are sandboxed: no operating system access, no network, no reflection. The maximum expression length is 1024 characters.
Monetary helpers
All monetary helpers work in centavos (the smallest currency unit). PHP 200 is 20000. Basis points are used for percentages: 250 basis points = 2.5%, 10000 basis points = 100%.
| Helper | Signature | Description |
|---|---|---|
monetary_percent(amount, bp) | (int64, int64) → int64 | Returns amount × bp / 10000. Use for percentage splits in basis points. |
monetary_split(amount, parts) | (int64, int) → []int64 | Splits amount into parts equal centavo amounts. Distributes the rounding remainder to the first elements so the sum is exact. |
monetary_div(dividend, divisor) | (int64, int64) → int64 | Integer division in centavos. |
monetary_mod(dividend, divisor) | (int64, int64) → int64 | Integer modulo in centavos. |
monetary_min(a, b) | (int64, int64) → int64 | The smaller of two amounts. |
monetary_max(a, b) | (int64, int64) → int64 | The larger of two amounts. Useful with 0 as a floor. |
monetary_abs(amount) | (int64) → int64 | The absolute value of a signed amount. |
Centavos, always. Every amount field is in centavos:send_money.amount, every output ofcompute, every helper input and result. To send PHP 1,000.00, use100000.
Updated about 5 hours ago