Flow variables and templates

Use template variables to pass data between steps and reference Flow inputs with {{variable}} syntax.

Basic syntax

Use double curly braces to reference a variable:

{{variableName}}

Use template variables in prompts, URLs, request bodies, and conditions.

Flow input

To pass values into a Flow through the Runtype API, include them in the inputs field. Reference each value by its key:

Name: {{customerName}}
Email: {{email}}
Order ID: {{orderId}}

For a record-based execution, use _record.metadata to read record metadata:

Customer: {{_record.metadata.customer_name}}
Status: {{_record.metadata.status}}

If you set an ownerId when you created the Record or conversation, read it from {{_record.ownerId}}, not from metadata. Runtype stores the owner in its own field, so {{_record.metadata.ownerId}} resolves empty. {{_record.ownerId}} also resolves empty for a Record that has no owner.

Step outputs

Reference an earlier step’s output by its outputVariable name:

{{summary_result}}

When the output is a JSON object, use dot notation to read nested fields:

Summary: {{generate_summary}}
Sentiment: {{analyze_sentiment.label}}
Confidence: {{analyze_sentiment.score}}

Nested properties

Use dot notation to read nested properties:

{{customer_data.metadata.tier}}
{{api_response.data[0].name}}
{{_record.metadata.address.city}}

Array access

Use bracket notation and a zero-based index to read array items:

{{search_results[0].metadata.title}}
{{search_results[1].metadata.content}}

System variables

Use these built-in variables in Flow templates:

VariableDescriptionExample
{{_now.iso}}ISO 8601 timestamp in UTC2026-05-20T17:42:13.123Z
{{_now.date}}Date in the execution timezone2026-05-20
{{_now.time}}24-hour time in the execution timezone10:42:13
{{_now.weekday}}Day of the week in the execution timezoneWednesday
{{_now.year}}, {{_now.month}}, {{_now.day}}Numeric date parts2026, 5, 20
{{_now.timezone}}Timezone used to render the date and time fieldsAmerica/Los_Angeles
{{_now.unix}}Unix timestamp in seconds1747772533
{{_execution.id}}ID for the Flow executionexec_01ks3wvfwhexxvrjngdnds7rbg
{{_execution.timestamp}}Execution start time2026-05-20T17:42:13.123Z
{{_execution.type}}Execution typestandalone, record, batch
{{_execution.mode}}How the Flow startsapi, dashboard, scheduled
{{_user.id}}ID of the user who triggered the Flowuser_01ks3wvfwhexxvrjngdnds7rbg
{{_user.organizationId}}ID of the user’s organizationorg_01ks3wvfwhexxvrjngdnds7rbg
{{_flow.id}}Flow IDflow_01ks3wvfwhexxvrjngdnds7rbg
{{_flow.name}}Flow nameCustomer Support Flow
{{_record.id}}Record ID in a record-based executionrec_01ks3wvfwhexxvrjngdnds7rbg
{{_record.ownerId}}Owner key you set on the Record or conversationuser_8f21
{{_record.metadata.customer_status}}Record metadata propertypaid
{{_endUser.id}}ID of the end user that you pass in the requestdana
{{_endUser.email}}End-user email address, when provideddana@example.com
{{_endUser.plan}}Additional field from the endUser objectstandard
{{_tenant.id}}ID of the Product Tenant that you pass in the requesttnt_staffingco
{{_tenant.plan}}Additional field from the tenant objectenterprise

An _agent variable is available only in an Agent’s memory.profileTemplate, not in Flow step templates. It carries {{_agent.id}} and, when the request selected a version, {{_agent.alias}}, {{_agent.versionId}}, and {{_agent.version}} (the version’s label). See Memory namespaces and release pointers.

The _schedule variable is available only in schedule-fired executions. It includes id, name, cron, timezone, lastRunAt, and nextRunAt fields.

An _endUser variable is present when you include an endUser object with an id in the dispatch request or the agents/:id/execute request. Use {{_endUser.id}} in an agent memory profileTemplate to keep long-term memory separate for each end user. _endUser identifies your customer’s end user, not the Runtype account holder in _user. If you omit endUser, a reference to _endUser resolves to an empty string.

A Product Tenant is your customer’s account or workspace inside your product. It sits between the builder organization in _user and the individual end user in _endUser. An _tenant variable is present when you include a tenant object with an id in the same requests. Use {{_tenant.id}} for state shared by a tenant’s end users and {{_endUser.id}} for state scoped to one end user. If you omit tenant, a reference to _tenant resolves to an empty string.

Runtype removes projectedId from both identity objects before it adds them to template context. Runtype uses durable tnt_* and eu_* projection IDs to scope records, secrets, and approval grants. A reference to {{_tenant.projectedId}} or {{_endUser.projectedId}} resolves to an empty value. If you include projectedId in the request, Runtype drops it. Use {{_tenant.id}} or {{_endUser.id}} instead. The flow validator reports a RESERVED_IDENTITY_VARIABLE recommendation.

Default values

Use a fallback when a variable might be undefined:

{{customerId || "unknown"}}
{{customerData.tier || "standard"}}

The || operator uses the first truthy value. Use ?? to fall back only when a value is null or undefined. Empty strings and 0 do not trigger ??.

String concatenation

Combine variables with surrounding text in a template:

Customer {{customerName}} placed order #{{orderId}} on {{_now.date}}

Calculations and conditional logic

Use a transform-data step for calculations, ternary expressions, and other complex logic. Template syntax supports variable references and fallback chains, but it does not support arithmetic or comparison operators.

Using variables in JSON

Insert variables into JSON request bodies and metadata as follows:

1{
2 "customer": "{{customerId}}",
3 "summary": "{{generate_summary}}",
4 "amount": {{calculate_total}},
5 "timestamp": "{{_now.iso}}"
6}

Quote string values. Leave numeric and boolean values unquoted.

Runtype evaluates variables at runtime. A reference to a step that has not run does not resolve.

Debugging variables

To inspect variable values, add a transform-data step. In the script, reference Flow variables by their outputVariable names:

1return {
2 debug: true,
3 customer_data_value: customer_data,
4 analysis_value: analysis,
5}

Check the step output in the execution results to see the returned values.

Variable scope

Within one Flow execution, use variables in these ways:

  • Reference an earlier step’s outputVariable in the same Flow.
  • Do not reference variables from another Flow.
  • Reference variables set inside a conditional branch after the conditional completes.

Best practices

Use these practices when you design variable references:

  • Use descriptive step names to make references clear.
  • Use defaults or conditionals when data might be missing.
  • Keep property chains shallow to reduce errors.
  • Test variables with representative data in each scenario.

Next steps

Continue with these Flow guides: