Skip to main content

Create and use params in Airflow

Params are arguments which you can pass to an Airflow DAG or task at runtime and are stored in the Airflow context dictionary for each DAG run. You can pass DAG and task-level params by using the params parameter.

Params are ideal to store information that is specific to individual DAG runs like changing dates, file paths or ML model configurations. Params are not encrypted and therefore not suitable to pass secrets. See also Best practices for storing information in Airflow.

This guide covers:

  • How to pass params to a DAG at runtime.
  • How to define DAG-level param defaults which are rendered in the Trigger DAG UI.
  • How to access params in an Airflow task.
  • The hierarchy of params in Airflow.

Assumed knowledge

To get the most out of this guide, you should have an understanding of:

Pass params to a DAG run at runtime

Params can be passed to a DAG at runtime in four different ways:

  • In the Airflow UI by using the Trigger DAG w/ config button.
  • Running a DAG with the --conf flag using the Airflow CLI (airflow dags trigger).
  • Using the TriggerDagRunOperator with the conf parameter.
  • Making a POST request to the Airflow REST APIs Trigger a new DAG run endpoint and using the conf parameter.

Param values passed to a DAG by any of these methods will override existing default values for the same key as long as the Airflow core config dag_run_conf_overrides_params is set to True.


While it's possible to pass non-JSON serializable params, this behavior is deprecated and will be removed in a future release. It is best practice to make sure your params are JSON serializable.

Trigger DAG w/ config

You can pass params to a DAG from the Airflow UI by clicking on the Play button and selecting Trigger DAG w/ config.

Trigger DAG w/ config

This button opens a UI in which you can specify details for the DAG run:

Trigger DAG UI


In Airflow 2.7+, you need to explicitly set the environment variable AIRFLOW__WEBSERVER__SHOW_TRIGGER_FORM_IF_NO_PARAMS=True for the Trigger DAG w/ config button to appear in the Airflow UI.

  • You can set the Logical date of the DAG run to any date that is in between the start_date and the end_date of the DAG to create DAG runs in the past or future.
  • You can set the Run id to any string. If no run ID is specified, Airflow generates one based on the type of run (scheduled, dataset_triggered, manual or backfill) and the logical date (for example: manual__2023-06-16T08:03:45+00:00).
  • You can select configurations from recent DAG runs in the Select Recent Configurations dropdown menu.
  • The Trigger DAG UI will render a UI element for every DAG-level params you define with a default value. See also Define DAG-level param defaults.
  • The information in the UI elements generates a Configuration JSON. You can directly edit the Generated Configuration JSON in the UI and add any additional params, whether a default has been defined for them or not.

After setting the configuration, you can start the DAG run with the Trigger button.


When you run an Airflow DAG from the CLI, you can pass params to the DAG run by providing a JSON string to the --conf flag. For example, to trigger the params_default_example DAG with the value of Hello from the CLI for param1, run:

Run Airflow commands from the Astro CLI using astro dev run:

astro dev run dags trigger params_defaults_example --conf '{"param1" : "Hello from the CLI"}'

The CLI prints the configuration for the triggered run to the command line:

CLI output

You can use a --conf flag with the following Airflow CLI sub-commands:

  • airflow dags backfill
  • airflow dags test
  • airflow dags trigger


The TriggerDagRunOperator is a core Airflow operator that allows you to start a DAG run from within another DAG. You can use the TriggerDAGRunOperator conf param to trigger the dependent DAG with a specific configuration.

The DAG below uses the TriggerDagRunOperator to trigger the tdro_example_downstream DAG while passing a dynamic value for the upstream_color param via the conf parameter. The value for upstream_color is passed via a Jinja template pulling the return value of an upstream task via XCom.

from pendulum import datetime
from airflow.decorators import dag, task
from airflow.operators.trigger_dagrun import TriggerDagRunOperator
import random

start_date=datetime(2023, 6, 1),
def tdro_example_upstream():
def choose_color():
color = random.choice(["blue", "red", "green", "yellow"])
return color

tdro = TriggerDagRunOperator(
conf={"upstream_color": "{{ ti.xcom_pull(task_ids='choose_color')}}"},

choose_color() >> tdro


Runs of the tdro_example_downstream DAG that are triggered by this upstream DAG will override the default value of the upstream_color param with the value passed via the conf parameter, which leads to the print_color task to print either red, green, blue or yellow.

from pendulum import datetime
from airflow.decorators import dag, task

start_date=datetime(2023, 6, 1),
params={"upstream_color": "Manual run, no upstream color available."},
def tdro_example_downstream():
def print_color(**context):



Define DAG-level param defaults

To specify params for all runs of a given DAG, pass default values to the param parameter of the @dag decorator or the DAG class in your DAG file. You can directly specify a default value or use the Param class to define a default value with additional attributes.

The DAG below has two DAG-level params with defaults: param1 and param2, the latter only accepting integers.

from pendulum import datetime
from airflow.decorators import dag, task
from airflow.models.param import Param

start_date=datetime(2023, 6, 1),
"param1": "Hello!",
"param2": Param(
def simple_param_dag():
def print_all_params(**context):
print(context["params"]["param1"] * 3)



If you define DAG-level param defaults, the Trigger DAG UI renders a form for each param. From this UI, you can then override your defaults for individual DAG runs. A param with a red asterisk is a required param.

Trigger DAG with simple defaults


When you specify a required type for a param, the field will be a required input by default because of JSON validation. To make a field optional but still require a specific input type, allow NULL values by setting the type to ["null", "<my_type>"].


By default, Airflow assumes that the values provided to a keyword in the params dictionary are strings. You can change this behavior by setting the DAG parameter render_template_as_native_obj=True. See Render native Python code.

Param types

The following param types are supported:

  • string: A string. This is the default type.
  • null: Allows the param to be None by being left empty.
  • integer or number: An integer (floats are not supported).
  • boolean: True or False.
  • array: An HTML multi line text field, every line edited will be made into a string array as the value.
  • object: A JSON entry field.

Param attributes

Aside from the type attribute, the Param class has several other attributes that you can use to define how users interact with the param:

  • title: The title of the param that appears in the Trigger DAG UI.
  • description: A description of the param.
  • description_html: A description defined in HTML that can contain links and other HTML elements. Note that adding invalid HTML might lead to the UI not rendering correctly.
  • section: Creates a section under which the param will appear in the Trigger DAG UI. All params with no specified section will appear under the default section DAG conf Parameters.
  • format: A JSON format that Airflow will validate a user's input against.
  • enum: A list of valid values for a param. Setting this attribute creates a dropdown menu in the UI.
  • const: Defines a permanent default value and hides the param from the Trigger DAG UI. Note that you still need to provide a default value for the param.
  • custom_html_form: Allows you to create custom HTML on top of the provided features.

All Param attributes are optional to set. For string type params, you can additionally set min_length and max_length to define the minimum and maximum length of the input. Similarly, integer and number type params can have a minimum and maximum value.

Param examples in the Airflow UI

This section presents a few examples of params and how they are rendered in the Trigger DAG UI.

The code snippet below defines a mandatory string param with a few UI elements to help users input a value.

"my_string_param": Param(
"Airflow is awesome!",
title="Favorite orchestrator:",
description="Enter your favorite data orchestration tool.",
section="Important params",

String param example

When you define date, datetime, or time param, a calendar picker appears in the Trigger DAG UI.

"my_datetime_param": Param(

Datetime param example

Providing a list of values to the enum attribute will create a dropdown menu in the Trigger DAG UI. Note that the default value must also be in the list of valid values provided to enum. Due to JSON validation rules, a value has to be selected.

"my_enum_param": Param(
"Hi :)", type="string", enum=["Hola :)", "Hei :)", "Bonjour :)", "Hi :)"]

Enum param example

A boolean type param will create a toggle in the Trigger DAG UI.

 "my_bool_param": Param(True, type="boolean"),

Bool param example

If you provide custom HTML to the custom_html_form attribute, you can create more complex UI elements like a color picker. For sample code, see this example DAG in the Airflow documentation.

Color picker example

Define task-level param defaults

You can set task-level param defaults in the same way as for DAG-level params. If a param of the same key is specified at both the DAG and task level, the task-level param will take precedence.

@task(params={"param1": "Hello World!"})
def t1(**context):

Access params in a task

You can access params in an Airflow task like you can with other elements in the Airflow context.

def t1(**context):

Params are also accessible as a Jinja template using the {{ params.my_param }} syntax.

If you try to access a param that has not been specified for a specific DAG run, the task will fail with an exception.

Param precedence

The order of precedence for params, with the first item taking most precedence, is as follows:

Was this page helpful?

Sign up for Developer Updates

Get a summary of new Astro features once a month.

You can unsubscribe at any time.
By proceeding you agree to our Privacy Policy, our Website Terms and to receive emails from Astronomer.