Skip to content

Set Variable

The set variable step stores key-value pairs in the $vars namespace, which persists across the entire workflow execution. The step editor shows a key-value form where you define variable names and their values.

Set variable step editor with key-value pairs

Each set-variable step merges its output into the existing $vars — it doesn’t replace them. This means values accumulate and you can update individual keys without losing others.

First set-variable step — initialize some state:

KeyValue
offset0
hasMoretrue
items{{ $util.emptyArray }}

Later set-variable step — update specific keys (the others are preserved):

KeyValue
offset100
items{{ $vars.items | arrayConcat: fetch-page.body.data }}

After this, $vars contains { offset: 100, hasMore: true, items: [...] }.

Accumulating inside a for-each loop:

KeyValue
processedCount{{ $vars.processedCount | plus: 1 }}

Storing computed values for later steps:

KeyValue
fullName{{ initial.firstName }} {{ initial.lastName }}
isVip{{ initial.totalOrders | gte: 100 }}

Access variables anywhere in the workflow:

{{ $vars.processedCount }}
{{ $vars.fullName }}