❓ Who is this for: This is for advanced users of dbt Cloud that are interested in expanding their knowledge of the dbt API via an interactive Postman Collection. We only suggest diving into this once you have a strong knowledge of dbt + dbt Cloud. You have a couple of options to review the collection:
- get a live version of the collection via .
- check out the collection documentation to learn how to use it.
The dbt Cloud API has well-documented endpoints for creating, triggering and managing dbt Cloud jobs. But there are other endpoints that aren’t well documented yet, and they’re extremely useful for end-users. These endpoints exposed by the API enable organizations not only to orchestrate jobs, but to manage their dbt Cloud accounts programmatically. This creates some really interesting capabilities for organizations to scale their dbt Cloud implementations.
The main goal of this article is to spread awareness of these endpoints as the docs are being built & show you how to use them.
You can use this blog post as an entry point to this postman collection to help you automate previously manual tasks, such as managing dbt Cloud account infrastructure, creating dbt Cloud projects, database connections, and managing users.
Please keep in mind that the collection is not an evergreen doc. We are actively developing and updating the API endpoints used to interact with dbt Cloud, so endpoint urls and / or expected request formats may change. Each endpoint in the collection provides comment capabilities, so please notify us there if something looks amiss.
With all of that being said, why should dbt users care about automating dbt Cloud account management?
What problems does programmatic dbt Cloud account management solve?
When first learning dbt Cloud and operating at a smaller scale, most end users tend to favor manual, GUI based workflows for creating and managing their account infrastructure. Many of our customers start off this way, but they usually end up running into these bottlenecks as the number of jobs and projects multiplies. Here are some examples of the kind of bottlenecks I hear our growing customers talk about.
- “I find myself wasting time manually clicking through the UI to manage infrastructure, especially after deploying more than a handful of projects and environments.”
- “I don’t have peace of mind that my production environment is configured exactly as intended. If a new team member deletes or changes something, I have to run a fire drill to fix it.”
- “My organization requires me to run any environmental configuration changes through code review and version control.”
We usually advise our customers to leverage API requests to automate these typically manual tasks, and you should, too!
Beyond the day-to-day process of managing their dbt Cloud accounts, many organizations benefit from being able to quickly replicate environments as they experiment with new dbt features and development patterns. Governance is another benefit of managing infrastructure in code, as resource definitions can be version controlled and inspected by the relevant teams before changes go live. These concepts are high on our minds as we look to provide additional capabilities to our customers in their use of dbt Cloud. Happy APIing!
Below this you’ll find a series of example requests - use these to guide you or check out the Postman Collection to try it out yourself.
Examples of how to use the Postman Collection
Let’s run through some examples on how to make good use of this Postman Collection.
Migrating dbt Cloud Projects
One common question we hear from customers is “How can we migrate resources from one dbt Cloud project to another?” Often, they’ll create a development project, in which users have access to the UI and can manually make changes, and then migrate selected resources from the development project to a production project once things are ready.
There are several reasons one might want to do this, including:
- Probably the most common is separating dev/test/prod environments across dbt Cloud projects to enable teams to build manually in a development project, and then automatically migrate those environments & jobs to a production project.
- Building “starter projects” they can deploy as templates for new teams onboarding to dbt from a learning standpoint.
- Some particularly security conscious customers may require version control and governance processes to run before any change to infrastructure, including their dbt Cloud accounts.
Below, we show an example of migrating an environment and a job definition from a development project to a production project. Note that this assumes you already have both projects set up. You could take this automation process even further by creating new projects with repository and database connections via the API as well. Please refer to the collection for additional details.
Before you start: Make sure to get your API key and add it to the Authentication Header of your requests.
Our example contains the following elements:
Pull the environment from the development project
All of this information is obtainable from the API (see the postman collection), but you can also identify the correct IDs to use from the URL when logged in to dbt Cloud:
- Account ID: 28885
- Project ID: 86704
- Environment ID: 75286
We’ll send a GET request to
Push the environment to the production project
We take the response from the GET request above, and then to the following:
Adjust some of the variables for the new environment:
- Change the the value of the “project_id” field from 86704 to 86711
- Change the value of the “name” field from “dev-staging” to “production–api-generated”
- Set the “custom_branch” field to “main”
Send the POST request shown below to: https://cloud.getdbt.com/api/v3/accounts/28885/projects/86711/environments/
- Note the environment ID returned in the response, as we’ll use to create a dbt Cloud job in the next step
Pull the job definition from the dev project
We send a GET request to:
Push the job definition to the prod project
- Adjust some of the variables for the new job:
- Remove the “created_at”, “updated_at”, and “is_deferrable” fields. Defer logic is out of scope for this post.
- Change the value of the “name” field to “production-run–api-generated”
- Sent the POST request shown below to https://cloud.getdbt.com/api/v2/accounts/28885/jobs/
"cron": "0 * * * *",
"cron_humanized": "Every hour",
And we’re done! We now have the basic mechanics in place for migrating dbt Cloud Objects.