How can I rotate my user API token?
For security reasons and best practices, you should aim to rotate API keys every so often. You can rotate your API key automatically with the push of a button in your dbt Cloud environment or manually using the command line.
- Automatic
- Manual
To automatically rotate your API key:
- Navigate to the Account settings by clicking the gear icon in the top right of your dbt Cloud account.
- Select API Access from the lefthand side.
- In the API pane, click
Rotate
.
- Rotate your User API token by replacing
YOUR_USER_ID
,YOUR_CURRENT_PAT_TOKEN
, andYOUR_ACCESS_URL
with your information in the following request.
curl --location --request POST 'https://cloud.getdbt.com/api/v3/accounts/YOUR_ACCOUNT_ID/users/YOUR_USER_ID/apikey/' \
--header 'Authorization: Token YOUR_CURRENT_PAT_TOKEN'
- Find your
YOUR_USER_ID
by reading How to find your user ID. - Find your
YOUR_CURRENT_TOKEN
by going to Profile Settings -> API Access and copying the API key. - Find
YOUR_ACCESS_URL
for your region and plan.
If YOUR_USER_ID
= 123
, YOUR_CURRENT_TOKEN
= abcf9g
, then your curl request will be:
curl --location --request POST 'https://YOUR_ACCESS_URL/api/v2/users/123/apikey/' \
--header 'Authorization: Token abcf9g'
-
Find the new key in the API response or in dbt Cloud.
-
To find the new key in dbt Cloud, go to Profile Settings -> API Access.
dbt Cloud deployments
If your dbt Cloud deployment uses a different access URL, replace YOUR_ACCESS_URL
with the URL of your instance.
For example, if your deployment is Virtual Private dbt:
✅ http://cloud.customizedurl.getdbt.com/
❌ http://cloud.getdbt.com/
0