Execution Context Variables

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

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
{{ taskrun.value }}Current loop or flowable value
{{ parent.taskrun.value }}Value of the nearest parent task run
{{ parent.outputs }}Outputs of the nearest parent task run
{{ parents }}List of parent task runs
{{ labels }}Execution labels accessible by key

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

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?