> For the complete documentation index, see [llms.txt](https://docs.erathos.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.erathos.com/api/quickstart/airflow.md).

# Airflow

## Prerequisites

Ensure the following variables are configured in the Airflow environment:

* **`airflow_url`**: Base URL of the Airflow server.
* **`airflow_dag_id`**: Identifier of the DAG to be triggered.

{% hint style="info" %}
**Note:** While you can directly use the target URL, we strongly recommend leveraging variables and secrets for enhanced security and maintainability.
{% endhint %}

## Authentication

For Airflow authentication, a Base64-encoded token is required:

* Generate the token using the string `username:password`.
* Example command to generate the token:

  ```bash
  echo -n "username:password" | base64
  ```
* Store this token securely as a secret named **`airflow_base64_token`**.

## Triggering a DAG

When a registered job in Erathos successfully completes, the specified DAG will be triggered with the following parameters:

* **`schema_name`**: Name of the related schema.
* **`table_name`**: Name of the related table.

POST Payload:

```json
{
  "description": "Trigger Airflow DAG run on success job execution",
  "is_active": true,
  "method": "POST",
  "url": "https://${{variables.airflow_url}}/api/v1/dags/${{variables.airflow_dag_id}}/dagRuns",
  "header": {
    "Authorization": "Basic ${{secrets.airflow_base64_token}}" 
  },
  "body": {
    "conf": {
      "schema": "${{erathos.schema_name}}",
      "table": "${{erathos.table_name}}"
    },
    "note": "triggered on Erathos platform by ${{erathos.triggered_by}}"
  },
  "rules": [
    {
      "variable_name": "STATUS",
      "operation": "EQUAL",
      "value": "FINISHED"
    },
  ],
  "jobs": [
    "<ERATHOS_JOB1_ID>",
    "<ERATHOS_JOB2_ID>",
    ...
    "<ERATHOS_JOBN_ID>"
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.erathos.com/api/quickstart/airflow.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
