Execution Context Variables

For the complete documentation index, see llms.txt. For a full content snapshot, see llms-full.txt. Append .md to any kestra.io/docs/* URL for plain Markdown.

Use this page to find out what data is available inside {{ ... }} at runtime — including flow metadata, inputs, outputs, trigger values, secrets, and namespace variables.

Understand the execution context

Kestra expressions combine the Pebble templating engine with the execution context to dynamically render flow properties.

The execution context usually includes:

  • flow
  • execution
  • inputs
  • outputs
  • labels
  • tasks
  • trigger when the flow was started by a trigger
  • vars when the flow defines variables
  • namespace in Enterprise Edition when namespace variables are configured
  • envs for environment variables
  • globals for global configuration values
  • item inside a Loop task iteration

The Debug Expression console is available in the Kestra UI under Executions → Logs → Debug Expression. Enter any expression and evaluate it against the live execution context without modifying the flow.

Default execution context variables

ParameterDescription
{{ flow.id }}Identifier of the flow
{{ flow.namespace }}Namespace of the flow
{{ flow.tenantId }}Tenant identifier in Enterprise Edition
{{ flow.revision }}Flow revision number
{{ execution.id }}Unique execution identifier
{{ execution.startDate }}Start date of the execution
{{ execution.state }}Current execution state
{{ execution.originalId }}Original execution ID preserved across replays
{{ task.id }}Current task identifier
{{ task.type }}Fully qualified class name of the current task
{{ taskrun.id }}Current task run identifier
{{ taskrun.startDate }}Start date of the current task run
{{ taskrun.attemptsCount }}Retry and restart attempt count
{{ taskrun.parentId }}Parent task run identifier for nested tasks
{{ parent.outputs }}Outputs of the nearest parent task run
{{ parents }}List of parent task runs
{{ labels }}Execution labels accessible by key
{{ trace.parent }}W3C traceparent header for the current execution; only populated when OpenTelemetry tracing is enabled

Example:

id: expressions
namespace: company.team
tasks:
- id: debug_expressions
type: io.kestra.plugin.core.debug.Return
format: |
taskId: {{ task.id }}
date: {{ execution.startDate | date("yyyy-MM-dd HH:mm:ss.SSSSSS") }}

Trigger variables

When the execution is started by a Schedule trigger:

ParameterDescription
{{ trigger.date }}Date of the current schedule
{{ trigger.next }}Date of the next schedule
{{ trigger.previous }}Date of the previous schedule

When the execution is started by a Flow trigger:

ParameterDescription
{{ trigger.executionId }}ID of the triggering execution
{{ trigger.namespace }}Namespace of the triggering flow
{{ trigger.flowId }}ID of the triggering flow
{{ trigger.flowRevision }}Revision of the triggering flow

Loop iteration context

Inside a Loop task, each iteration runs as an isolated sub-execution. The item variable is available to all tasks within that sub-execution.

ExpressionDescription
{{ item.index }}Zero-based index of the current iteration
{{ item.value }}Value of the current iteration
{{ item.key }}Map key of the current iteration; only set when values is a map
{{ item.parent.index }}Index of the nearest enclosing loop (nested loops only)
{{ item.parent.value }}Value of the nearest enclosing loop (nested loops only)
{{ item.parents[n].value }}Value of the nth ancestor loop, counting from innermost ([0] = immediate parent)

Because item is bound to the loop execution rather than individual task runs, flowable tasks nested inside a Loop (such as If or Parallel) can access item directly without any parent. prefix.

tasks:
- id: loop
type: io.kestra.plugin.core.flow.Loop
values: ["value 1", "value 2", "value 3"]
tasks:
- id: check
type: io.kestra.plugin.core.flow.If
condition: '{{ item.value == "value 2" }}'
then:
- id: log
type: io.kestra.plugin.core.log.Log
message: "Matched at index {{ item.index }}: {{ item.value }}"

Environment and global variables

Kestra provides access to environment variables prefixed with ENV_ by default, unless configured otherwise in the runtime and storage configuration.

  • reference ENV_FOO as {{ envs.foo }}
  • reference the configured environment name as {{ kestra.environment }}
  • reference the configured Kestra URL as {{ kestra.url }}
  • reference global variables from configuration as {{ globals.foo }}

Flow variables and inputs

Use flow-level variables with vars.*:

id: flow_variables
namespace: company.team
variables:
my_variable: "my_value"
tasks:
- id: print_variable
type: io.kestra.plugin.core.debug.Return
format: "{{ vars.my_variable }}"

Use inputs with inputs.*:

id: render_inputs
namespace: company.team
inputs:
- id: myInput
type: STRING
tasks:
- id: myTask
type: io.kestra.plugin.core.debug.Return
format: "{{ inputs.myInput }}"

Secrets, credentials, namespace variables, and outputs

Use secret() to inject secret values at runtime:

tasks:
- id: myTask
type: io.kestra.plugin.core.debug.Return
format: "{{ secret('MY_SECRET') }}"

Use credential() in Enterprise Edition to inject a short-lived token from a managed Credential:

tasks:
- id: request
type: io.kestra.plugin.core.http.Request
method: GET
uri: https://api.example.com/v1/ping
auth:
type: BEARER
token: "{{ credential('my_oauth') }}"

credential() returns the short-lived token only. The credential itself is managed in the Kestra UI.

Use namespace variables in Enterprise Edition with namespace.*. To set them up:

  1. Open the Kestra UI and navigate to Namespaces.
  2. Select the namespace where the flow runs.
  3. Open the Variables tab.
  4. Add a key-value pair such as github.token with the desired value.

Reference namespace variables in expressions using dot notation:

format: "{{ namespace.github.token }}"

If a namespace variable itself contains Pebble, evaluate it with render():

format: "{{ render(namespace.github.token) }}"

Use outputs with outputs.taskId.attribute:

message: |
First: {{ outputs.first.value }}
Second: {{ outputs['second-task'].value }}

Was this page helpful?