Skip to content

Expressions & XPath

Expressions & XPath

Expressions let you reference dynamic values within flowlet arguments. They are evaluated at runtime using the current execution context.

Syntax

Wrap an expression in double curly braces:

{{ expression }}

Entire argument values or parts of strings can be expressions:

{
"url": "https://api.example.com/users/{{ $prev.getUser.id }}",
"body": "{{ $prev.formatBody.json }}"
}

Referencing Previous Step Output

Use the step’s ref name to access its output:

{{ $prev.<ref>.<field> }}
{{ $prev.<ref>.<nested>.<field> }}

Examples:

{{ $prev.fetchUser.name }}
{{ $prev.fetchUser.address.city }}
{{ $prev.parseInvoice.lineItems[0].amount }}

Input Arguments

Access the args passed when the flow was triggered:

{{ $prev.args.invoiceId }}
{{ $prev.args.customerEmail }}

Sandbox Objects

$kv β€” KV Store Access

{{ $kv.get "myKey" }}
{{ $kv.getScoped "flow" $flowId "counter" }}

$date β€” Date & Time

{{ $date.now }} ← current UTC datetime
{{ $date.format "2006-01-02" }} ← formatted date (Go layout)
{{ $date.unix }} ← unix timestamp
{{ $date.addDays 7 }} ← 7 days from now

$rand β€” Random Values

{{ $rand.uuid }} ← UUID v4
{{ $rand.cuid }} ← CUID2
{{ $rand.int 1 100 }} ← random int between 1 and 100
{{ $rand.string 16 }} ← random alphanumeric string of length 16

$q β€” Query Helpers

{{ $q.urlencode $prev.search.term }}
{{ $q.base64 $prev.data.raw }}
{{ $q.jsonStringify $prev.payload }}
{{ $q.jsonParse $prev.response.body }}

Operators and Functions

Arithmetic:

{{ add $prev.a.value $prev.b.value }}
{{ mul $prev.price.amount 1.2 }}
{{ div 100 $prev.count.total }}

String operations:

{{ upper $prev.name.first }}
{{ lower $prev.status.value }}
{{ trim $prev.input.text }}
{{ replace $prev.text.raw "old" "new" }}
{{ split $prev.csv.line "," }}
{{ join $prev.array.items ", " }}
{{ contains $prev.body.text "error" }}
{{ hasPrefix $prev.url.value "https" }}

Comparison:

{{ eq $prev.status.code 200 }}
{{ gt $prev.count.value 0 }}
{{ and (eq $prev.type.value "invoice") (gt $prev.amount.value 1000) }}
{{ or (eq $prev.tier.value "premium") (eq $prev.tier.value "enterprise") }}
{{ not (eq $prev.deleted.flag true) }}

Array operations:

{{ len $prev.items.list }}
{{ index $prev.items.list 0 }}
{{ slice $prev.items.list 0 10 }}

XPath for Document Data

When working with XML responses or structured document data, use XPath syntax:

/root/items/item[0]/name
/response/data/@attribute
//invoice/lineItems/item[price > 100]/description

XPath expressions are used within the PDF extract, OCR, and XML processing modules.

Conditional Expressions

{{ if gt $prev.amount.value 1000 }}high-value{{ else }}standard{{ end }}

Nested Data Access

For deeply nested JSON:

{{ $prev.apiResponse.data.user.profile.displayName }}
# Or use index for array access:
{{ index $prev.results.items 2 }}
{{ index (index $prev.matrix.rows 0) 1 }}