Template expressions and functions
Extractor and Charger instructions use template expressions. Loader and Transformer instructions have narrower dynamic interfaces.
To author inputs and connect them to jobs, see Inputs and parameters.
Where expressions run
| Stage | Expression behavior |
|---|---|
| Extractor | Selected request, authentication, metadata, matrix, output key, URL, header, body, and condition fields can render or resolve template expressions. |
| Loader | No general template-expression interface. targetRelation and each sourceField are static. A default is a typed literal or a declared server parameter. |
| Transformer | Use SQL placeholders such as :start, :end, and :billing_month for declared inputs. Use {{loaded}}, {{transformed}}, and {{charged}} for compiled origins. |
| Charger | The whole template is rendered with inputs before the Charger model is parsed. Keep expressions input-scoped and bounded. |
An Extractor database query uses the SQL dialect of the selected source database. Transformer SQL uses DuckDB.
Syntax
Use ${{ expression }} inside a string to render text around a dynamic value:
url: ${{ inputs.base_url }}/v1${{ next | default("/invoices") }}
A field that expects a structured value can use a bare expression or the same wrapper:
matrix:
invoice: ${{ outputs.invoices }}
Common accessors:
inputs.billing_month
inputs["Access key"]
outputs.instances[matrix.region]
matrix.customer.id
list.first(outputs.invoices).id
Use quoted bracket access for a name that is not a plain identifier.
Supported operators include:
+ - * / % ^ ! == != < <= > >= |
The pipe operator passes a value into a function, as in next | default("/invoices") above. default(a, b, ...) returns the first truthy value. null, false, 0, empty strings, and empty arrays are not truthy. If no argument is truthy, the result is null.
Runtime context
| Context | Available in | Meaning |
|---|---|---|
inputs | Extractor and Charger | Resolved template, workflow, job, input-group, schedule, and run input values. SecretRef inputs resolve at runtime. |
outputs | Extractor only | Values captured by earlier Extractor requests. Later requests read them as outputs.<name>. |
matrix | Extractor request execution | The current matrix combination of the request. Use it in URLs, metadata, output keys, headers, bodies, conditions, and dependent matrix dimensions. |
next | Extractor pagination | The current pagination token or URL of the request. Usually paired with default. |
Expressions can also call now(), which returns the run reference time. Every job, retry, and correction of a run sees the same value. It is not an input, and no input can override it. The name WORKFLOW_RUN_REFERENCE_TIME is reserved: instructions that declare an input with that name, or a run that supplies a value under it, are refused.
When several layers set the same input, the most specific layer wins: run value, then schedule value, then workflow input groups, then job value, then workflow value, then the instruction default. See Inputs and precedence.
Callbacks
Some list and conditional helpers accept callbacks:
fn(item) { item.id }
fn(invoice) { invoice.total > 0 }
Use a callback to filter, map, reduce, group, or conditionally select values from output arrays.
matrix:
invoice: ${{ list.filter(outputs.invoices, fn(invoice) { invoice.status == "ready" }) }}
Function catalog
This catalog is an index. The template function reference documents signatures, behavior, and examples, and is authoritative where the two differ.
| Namespace | Functions |
|---|---|
| Global | if, default, and, or, truthy, simplify, now |
string | toUppercase, toLowercase, capitalize, camelCase, pascalCase, snakeCase, kebabCase, title, concat, split, join, contains, startsWith, endsWith, indexOf, lastIndexOf, slice, len, trim, trimStart, trimEnd, charAt, reverse, repeat, replace, truncate, padStart, padEnd, isEmpty, matches, format, base64Encode, base64Decode, jsonEncode, urlEncode, urlDecode, htmlEscape, htmlUnescape |
list | len, first, last, get, contains, isEmpty, join, reverse, concat, flatten, unique, count, sum, avg, min, max, sort, sortBy, slice, take, skip, chunk, zip, indexOf, map, filter, filterMap, flatMap, find, every, some, reduce, groupBy |
num | abs, ceil, floor, round, sqrt, sign, min, max, avg, sum, clamp, fibonacci, toInt, toFloat |
date | parse, parseDate, parseDateTime, parseTime, format, setTime, setTimezone, toTimezone, add, addYear, addMonth, addDay, addHour, addMinute, addSecond, isBefore, isAfter, isBetween, isEqual, isFirstDayOfMonth, isLastDayOfMonth, earliest, latest, toStartOf, toEndOf, toStartOfYear, toStartOfMonth, toStartOfDay, toStartOfHour, toStartOfMinute, toStartOfSecond, toStartOfNextYear, toStartOfNextMonth, toStartOfNextDay, toStartOfNextHour, toStartOfNextMinute, toStartOfNextSecond, toStartOfPreviousMonth, toEndOfYear, toEndOfMonth, toEndOfDay, toEndOfHour, toEndOfMinute, toEndOfSecond, toEndOfPreviousYear, toEndOfPreviousMonth, toEndOfPreviousDay, toEndOfPreviousHour, toEndOfPreviousMinute, toEndOfPreviousSecond |
Examples:
headers:
X-Billing-Month: ${{ inputs.billing_month }}
X-Period-Seconds: ${{ num.toInt(inputs.period_seconds) }}
url: ${{ inputs.base_url }}/usage?start=${{ string.urlEncode(inputs.start) }}&end=${{ string.urlEncode(inputs.end) }}
matrix:
account: ${{ list.unique(outputs.accounts) }}
service: ${{ outputs.services_by_account[matrix.account] }}
metadata:
period_start: ${{ date.toStartOf(inputs.start, "month") }}
period_end: ${{ date.toEndOf(inputs.start, "month") }}
JSON request bodies
- The namespace is part of the function name. Use
string.concat, not bareconcat. The global helpers, such asdefaultandif, have no namespace. and,or,default, andifevaluate their arguments left to right and stop when the result is known, so a guard such asand(x != null, !string.isEmpty(x))is safe whenxis missing. All other functions evaluate every argument first.- Expression string literals use double quotes. Single-quoted literals are not valid. In a JSON template file, escape each double quote that belongs to the expression. YAML block strings do not need this escape.
Use string.jsonEncode when a dynamic value must become a JSON string. The function adds the quotes and escapes control characters. This example adds the ARG skip token only after the first page:
body: >-
{"query":"Resources | order by id asc","options":{${{ if(next, fn() { string.concat(string.jsonEncode("$skipToken"), ":", string.jsonEncode(next)) }, fn() { "" }) }}}}
Keep JSON punctuation that is always present outside expressions. Do not create JSON quotes with Base64 or manual escape sequences.
Secret handling
Use a declared SecretRef input or a secret binding for sensitive values:
inputs:
- name: client_secret
type: SecretRef
Then reference it:
authentications:
- name: partner-oauth
type: OAuth2
url: ${{ inputs.token_url }}
clientId: ${{ inputs.client_id }}
clientSecret: ${{ inputs.client_secret }}
Do not put raw tokens, passwords, client secrets, API keys, or fallback secret literals inside expressions. See Secrets.
Common mistakes
| Mistake | Better approach |
|---|---|
Using Extractor outputs or matrix in Charger instructions. | Pass the value as an input and reference inputs.<name>. |
Using ${{ }}, JSONPath, or nested selectors in Loader sourceField. | Use one exact source field name. For nested data, see Loader instructions. |
| Treating Transformer SQL as Extractor template syntax. | Declare inputs[].name, use SQL placeholders such as ':billing_month', and use {{loaded}} or {{transformed}} for schemas. |
Hiding a raw secret in default(inputs.secret, "raw-value"). | Store the secret separately and use a SecretRef input. |
Writing inputs.Access key for an input name with a space. | Use quoted bracket access: ${{ inputs["Access key"] }}. Dotted access works only for plain names such as inputs.access_key. |