> ## 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.

# Create a dbt Cloud connection in Airflow

<Info>
  This page hasn't yet been updated for Airflow 3. The concepts shown are relevant, but some code may need to be updated. If you run any examples, take care to update import statements and watch for any other breaking changes.
</Info>

[dbt Cloud](https://www.getdbt.com/product/what-is-dbt/) is a SaaS product that runs SQL-first transformation workflows. Integrating dbt Cloud with Airflow allows you to trigger dbt cloud jobs and check their status from an Airflow DAG.

This guide provides the basic setup for creating a dbt Cloud Airflow connection. For a complete integration tutorial, see [Orchestrate dbt Cloud jobs with Airflow](/docs/learn/2.x/airflow-dbt-cloud). To run your dbt core jobs using Airflow, see [Orchestrate dbt-core Jobs with Airflow](/docs/learn/2.x/airflow-dbt).

## Prerequisites

* The [Astro CLI](/docs/cli/v1.43/overview).
* A locally running [Astro project](/docs/cli/v1.43/get-started-cli).
* A [dbt Cloud account](https://cloud.getdbt.com/)

## Get connection details

A connection from Airflow to dbt Cloud requires the following information:

* dbt Cloud URL
* API token
* Account ID

Complete the following steps to retrieve these values:

1. In the dbt Cloud UI, copy the URL of your dbt Cloud account. It should be formatted as `https://cloud.getdbt.com`. Your URL might be different based on the hosted region of your dbt Cloud. See [dbt Cloud URIs](https://docs.getdbt.com/docs/cloud/manage-access/sso-overview#auth0-multi-tenant-uris) for more details.

2. If you're using a dbt Developer account, follow the [dbt documentation](https://docs.getdbt.com/docs/dbt-cloud-apis/user-tokens#user-api-tokens) to copy the API token for your user account. To generate a token for a service account, see [Generating service account tokens](https://docs.getdbt.com/docs/dbt-cloud-apis/service-tokens#generating-service-account-tokens).

3. To retrieve the Account ID of your dbt account, go to the settings page in dbt Cloud UI. Then, from the URL of the settings page, copy the account ID, which is an integer appearing after `accounts`. For example, in the URL `https://cloud.getdbt.com/settings/accounts/88348`, the account ID is `88348`.

## Create your connection

<Info>
  Astro users can also create connections using the [Astro Environment Manager](/docs/astro/manage-connections-variables#astro-environment-manager), which stores connections in an Astro-managed secrets backend. These connections can be shared across multiple deployed and local Airflow environments. See [Create Airflow connections in the Astro UI](/docs/astro/create-and-link-connections).
</Info>

1. Open your Astro project and add the following line to your `requirements.txt` file:

   ```text wrap theme={null}
   apache-airflow-providers-dbt-cloud
   ```

   This will install the dbt Cloud provider package, which makes the dbt Cloud connection type available in Airflow.

2. Run `astro dev restart` to restart your local Airflow environment and apply your changes in `requirements.txt`.

3. In the Airflow UI for your local Airflow environment, go to **Admin** > **Connections**. Click **+** to add a new connection, then select the connection type as **dbt Cloud**.

4. Fill out the following connection fields using the information you retrieved from [Get connection details](#get-connection-details):

   * **Connection Id**: Enter a name for the connection.
   * **Tenant**: Enter the dbt Cloud URL.
   * **API Token**: Enter your user token or service access token.
   * **Account ID**: Enter your dbt cloud account ID. This field is optional. If you skip this, you must pass the account ID to the dbt cloud operator or hook.

5. Click **Test**. After the connection test succeeds, click **Save**.

   <Frame>
     <img src="https://mintcdn.com/astronomer/dALHYMAz3j7hCvzV/images/img/examples/connection-dbt-cloud.png?fit=max&auto=format&n=dALHYMAz3j7hCvzV&q=85&s=38d9cf3d004021f081fe1c4ec6f2f242" alt="dbt Cloud connection test" width="1748" height="888" data-path="images/img/examples/connection-dbt-cloud.png" />
   </Frame>

<Info>
  Note that the connection test only tests the **Tenant** and **API Token** fields. It won't validate your **Account ID**.
</Info>

## How it works

Airflow uses Python's `requests` library to connect to dbt Cloud through the [`DbtCloudHook`](https://airflow.apache.org/docs/apache-airflow-providers-dbt-cloud/stable/_api/airflow/providers/dbt/cloud/hooks/dbt/index.html).

## See also

* [Apache Airflow dbt cloud provider package documentation](https://airflow.apache.org/docs/apache-airflow-providers-dbt-cloud/stable/connections.html)
* dbt Cloud modules in the [Airflow Registry](https://airflow.apache.org/registry/)
* [Import and export Airflow connections using Astro CLI](/docs/astro/import-export-connections-variables#using-the-astro-cli-local-environments-only)
