> ## Documentation Index
> Fetch the complete documentation index at: https://astronomer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# DAG-level parameters in Airflow

In Airflow, you can configure when and how your DAG runs by setting parameters in the DAG object. DAG-level parameters affect how the entire DAG behaves, as opposed to task-level parameters which only affect a single task or [Airflow configs](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html) which affect the entire Airflow instance.

This guide covers all user-relevant DAG-level parameters in Airflow.

## Basic DAG-level parameters

There are four basic DAG-level parameters. It is best practice to always set these parameters in any DAG:

| Parameter    | Description                                                                                                                                                                                                                                                                                       |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dag_id`     | The name of the DAG. This must be unique for each DAG in the Airflow environment. When using the `@dag` decorator and not providing the `dag_id` parameter name, the function name is used as the `dag_id`. When using the `DAG` class, this parameter is required.                               |
| `start_date` | The date and time after which the DAG starts being scheduled. Note that the first actual run of the DAG may be later than this date depending on how you define the schedule. See [DAG scheduling and timetables in Airflow](/docs/learn/scheduling-in-airflow) for more information. Default: `None`. |
| `schedule`   | The schedule for the DAG. There are many different ways to define a schedule, see [Scheduling in Airflow](/docs/learn/scheduling-in-airflow) for more information. Defaults to `None`.                                                                                                                 |
| `catchup`    | Whether the scheduler should backfill all missed DAG runs between the current date and the start date when the DAG is unpaused. This parameter defaults to `False`. See [Catchup](/docs/learn/rerunning-dags#catchup) for more information.                                                            |

## UI parameters

Some parameters [add documentation](/docs/learn/custom-airflow-ui-docs-tutorial) to a DAG or change its appearance in the Airflow UI:

| Parameter     | Description                                                                                                                                                                                                                                          |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `description` | A short string that is displayed in the Airflow UI next to the DAG name.                                                                                                                                                                             |
| `doc_md`      | A string that is rendered as [DAG documentation](/docs/learn/custom-airflow-ui-docs-tutorial) in the Airflow UI. Tip: use `__doc__` to use the docstring of the Python file. It is a best practice to give all your DAGs a descriptive DAG documentation. |
| `tags`        | A list of tags shown in the Airflow UI to help with filtering DAGs.                                                                                                                                                                                  |

## Jinja templating parameters

There are parameters that relate to [Jinja templating](/docs/learn/templating), such as:

| Parameter                       | Description                                                                                                                                                                                                                                                                                                                       |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `template_searchpath`           | A list of folders where Jinja looks for templates. The path of the DAG file is included by default.                                                                                                                                                                                                                               |
| `template_undefined`            | The behavior of Jinja when a variable is undefined. Defaults to [StrictUndefined](https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.StrictUndefined).                                                                                                                                                                        |
| `render_template_as_native_obj` | Whether to render Jinja templates as native Python objects instead of strings. Defaults to `False`.                                                                                                                                                                                                                               |
| `user_defined_macros`           | A dictionary of macros that are available in the DAG's Jinja templates. Use `user_defined_filters` to add filters and `jinja_environment_kwargs` for additional Jinja configuration. See [Macros: using custom functions and variables in templates](/docs/learn/templating#macros-using-custom-functions-and-variables-in-templates). |

## Scaling

Some parameters can be used to scale your DAG's resource usage in Airflow. See [Scaling Airflow to optimize performance](/docs/learn/airflow-scaling-workers) for more information.

| Parameter                         | Description                                                                                                        |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `max_active_tasks`                | The number of task instances allowed to run concurrently one run of this DAG.                                      |
| `max_active_runs`                 | The number of active DAG runs allowed to run concurrently for this DAG.                                            |
| `max_consecutive_failed_dag_runs` | (experimental) The maximum number of consecutive failed DAG runs, after which the scheduler will disable this DAG. |

## Callback parameters

These parameters help you configure the behavior of [Airflow callbacks](/docs/learn/error-notifications-in-airflow#airflow-callbacks).

| Parameter             | Description                                                         |
| --------------------- | ------------------------------------------------------------------- |
| `on_success_callback` | A function to be executed after completion of a successful DAG run. |
| `on_failure_callback` | A function to be executed after a failed DAG run.                   |

<Tip>
  On Astro, you can use Astro alerts instead of or in addition to Airflow callbacks. See [When to use Airflow or Astro alerts for your pipelines on Astro](/docs/astro/best-practices/airflow-vs-astro-alerts) for more information.
</Tip>

## Other parameters

Other DAG parameters include:

| Parameter                 | Description                                                                                                                                                                                                                                                                                                                                                        |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `end_date`                | The date beyond which no further DAG runs will be scheduled. Defaults to `None`.                                                                                                                                                                                                                                                                                   |
| `default_args`            | A dictionary of parameters that are applied to all tasks in the DAG. These parameters are passed directly to each operator, so they must be parameters that are part of the `BaseOperator`. You can override default arguments at the task level.                                                                                                                  |
| `params`                  | A dictionary of DAG-level Airflow params. See [Airflow params](/docs/learn/airflow-params) for more information.                                                                                                                                                                                                                                                        |
| `dagrun_timeout`          | The time it takes for a DAG run of this DAG to time out and be marked as `failed`.                                                                                                                                                                                                                                                                                 |
| `access_control`          | Specify optional permissions for roles specific to an individual DAG. See [DAG-level permissions](https://airflow.apache.org/docs/apache-airflow/stable/security/access-control.html#dag-level-permissions). This can't be implemented on Astro. Astronomer recommends customers to use [Astro's RBAC features](/docs/astro/user-permissions) instead.                  |
| `is_paused_upon_creation` | Whether the DAG is paused when it is created. When not set, the Airflow config `core.dags_are_paused_at_creation` is used, which defaults to `True`.                                                                                                                                                                                                               |
| `auto_register`           | Defaults to `True` and can be set to `False` to prevent DAGs using a `with` context from being automatically registered which can be relevant in some advanced dynamic DAG generation use cases. See [Registering dynamic DAGs](https://airflow.apache.org/docs/apache-airflow/stable/howto/dynamic-dag-generation.html#registering-dynamic-dags).                 |
| `fail_fast`               | You can set this parameter to `True` to stop DAG execution as soon as one task in this DAG fails. Any tasks that are still running are marked as `failed`, and any tasks that haven't run yet are marked as `skipped`. Note that you can't have any [trigger rule](/docs/learn/airflow-trigger-rules) other than `all_success` in a DAG with `fail_fast` set to `True`. |
| `dag_display_name`        | Overrides the `dag_id` to display a different DAG name in the Airflow UI. This parameter allows special characters.                                                                                                                                                                                                                                                |
| `allowed_run_types`       | (Airflow 3.2+) A list of run types that are allowed for this Dag. Available run types are `scheduled`, `backfill`, `manual`, `asset_triggered`, and `asset_materialization`. If `manual` isn't in the list of allowed run types, a schedule has to be defined. By default all run types are allowed for a Dag.                                                     |
