# Dbt Cloud

## **Prerequisites**

Before proceeding with the template configuration, the following must be set up in the environment:

1. **Variable**:
   * **`dbt_account_id`**: The unique identifier for the dbt Cloud account.
2. **Secret**:
   * **`dbt_personal_token`**: A personal API token used for authentication. This token ensures secure access to the dbt Cloud API and must be stored securely.

{% hint style="info" %}
**Note**: Using securely stored secrets like `dbt_personal_token` is strongly recommended to protect sensitive credentials.
{% endhint %}

{% hint style="warning" %}
To access the dbt Cloud API, you must be on the 'Team' or 'Enterprise' plan. The API is not available on the free plan.
{% endhint %}

## Authentication

* Ensure that the **`dbt_account_id`** variable is correctly set and matches the dbt Cloud account you wish to interact with.
* Generate the **`dbt_personal_token`** from dbt Cloud:
  * Navigate to your dbt Cloud account settings.
  * Create a personal token under the **API Access** section.
  * Save this token securely in your environment as **`dbt_personal_token`**.

## Triggering Dbt cloud

When a registered job in Erathos successfully completes, the specified Job will be triggered.

POST Payload:

```json
{
  "description": "Trigger DBT job run on Cloud",
  "is_active": true,
  "method": "POST",
  "url": "https://cloud.getdbt.com/api/v2/accounts/${{variables.dbt_account_id}}/jobs/<DBT_JOB_ID/run/",
  "header": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer ${{secrets.dbt_personal_token}}"
  },
  "body": {
    "cause": "finished job on Erathos platform triggered by ${{erathos.triggered_by}}"
  },
  "rules": [
  ],
  "jobs": [
    "<ERATHOS_JOB_ID>",
  ]
}
```


---

# Agent Instructions: 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:

```
GET https://docs.erathos.com/api/quickstart/dbt-cloud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
