Managed Airflow (Gen 3) | Managed Airflow (Gen 2) | Managed Airflow (Legacy Gen 1)
Apache Airflow has a REST API interface that you can use to perform tasks such as getting information about DAG runs and tasks, updating DAGs, getting Airflow configuration, adding and deleting connections, and listing users.
For an example of using Airflow REST API with Cloud Run functions, see Triggering DAGs with Cloud Run functions.
Airflow REST API versions
- Airflow 2 uses the Airflow REST API v1.
- The experimental REST API is deprecated by Airflow.
Configure the Airflow REST API
The Airflow REST API v1 is enabled by default in Airflow 2.
Managed Airflow uses its own API authentication backend.Authorization works in the standard way provided by Airflow. When a new user
authorizes through the API, the user's account gets the Op role by default.
You can enable or disable the Airflow REST API, or change the default user role by overriding the following Airflow configuration options:
| Section | Key | Value | Notes |
|---|---|---|---|
api
|
(Airflow 2.2.5 and earlier) auth_backend (Airflow 2.3.0 and later) auth_backends
|
airflow.composer.api.backend.composer_auth
|
To disable the stable REST API, change to
airflow.api.auth.backend.deny_all |
api
|
composer_auth_user_registration_role
|
Op
|
You can specify any other role. |
Allow API calls to Airflow REST API using web server access control
Depending on the method used to call Airflow REST API, the caller method can use either IPv4 or IPv6 address. Remember to unblock the IP traffic to Airflow REST API using web server access control.
Use the default configuration option which is
All IP addresses have access (default) if you are not sure from which IP
addresses your calls to Airflow REST API will be sent.
Make calls to Airflow REST API
This section provides an example Python script which you can use to trigger DAGs with the Airflow REST API.
In the script, set the following variables:
dag_id: name of a DAG, as defined in the DAG source file.dag_config: configuration for the DAG run.web_server_url: Your Airflow web server URL. The format ishttps://<web-server-id>.composer.googleusercontent.com.(Airflow 3)
logical_date: The logical date for the DAG run.