# dbt Cloud

> Orchestrate dbt Cloud data transformation - list projects, environments, jobs and runs, and trigger job runs - via the Administrative API v2.

Lets an agent orchestrate your dbt Cloud project through the Administrative API v2: list projects, environments, and jobs, get a job, trigger a job run, and list or inspect runs. Useful for kicking off transformations and checking their status from a workflow.

## What it can do

| Method | What it does |
| --- | --- |
| `dbt_projects_list` | List projects in the account. |
| `dbt_environments_list` | List environments (optionally filtered by project). |
| `dbt_jobs_list` | List jobs (optionally filtered by project / environment). |
| `dbt_job_get` | Get one job by ID. |
| `dbt_job_run` | Trigger a job run (a `cause` reason is required). |
| `dbt_runs_list` | List runs (filter by job, project, status, order). |
| `dbt_run_get` | Get one run by ID (optionally expand related objects). |
| `dbt_request` | Generic passthrough to any API v2 endpoint for full API coverage. |

## How to get your credentials

dbt Cloud authenticates with a **service token** sent as the `Authorization: Token <token>` header. You also need your numeric **account ID**.

1. Sign in to [dbt Cloud](https://cloud.getdbt.com).
2. Go to **Account Settings -> Service Tokens** ([service token docs](https://docs.getdbt.com/docs/dbt-cloud-apis/service-tokens)).
3. Create a token, grant it the permission sets you need (for example Job Admin to trigger runs), and copy it - it is shown once.
4. Find your **account ID**: it is the number in your dbt Cloud URL, e.g. `cloud.getdbt.com/deploy/12345/...` -> `12345`.
5. If your account is on a regional / single-tenant cell, note your base URL (for example `https://emea.dbt.com`); otherwise leave it as the default.
6. Paste them into FlyMyAI.

## Fields to fill

| FlyMyAI field | Where it comes from |
| --- | --- |
| `DBT_SERVICE_TOKEN` | dbt Cloud -> Account Settings -> Service Tokens |
| `DBT_ACCOUNT_ID` | The number in your dbt Cloud URL |
| `DBT_BASE_URL` | Optional - default `https://cloud.getdbt.com`; regional cells use e.g. `https://emea.dbt.com` |

## Troubleshooting

- **`401 Unauthorized`** - the service token is wrong or revoked. Create a new one under Account Settings -> Service Tokens.
- **`403 Forbidden`** - the token lacks the permission set for the action (for example triggering a run needs Job Admin). Re-issue the token with the right permissions.
- **`404 Not Found` on every call** - the account ID is wrong, or your account is on a regional cell. Check the account ID in the URL and set `DBT_BASE_URL` to your cell's host.
- **`dbt_job_run` rejected** - the `cause` field is required; provide a short reason such as "Triggered via FlyMyAI".

## Links

- [dbt Cloud API v2 reference](https://docs.getdbt.com/dbt-cloud/api-v2)
- [Service tokens](https://docs.getdbt.com/docs/dbt-cloud-apis/service-tokens)
