Skip to content

Instantly share code, notes, and snippets.

@boxysean
Last active March 27, 2023 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save boxysean/c9076a7950fef1c9e7379d7bf664df98 to your computer and use it in GitHub Desktop.
Save boxysean/c9076a7950fef1c9e7379d7bf664df98 to your computer and use it in GitHub Desktop.
dbt Cloud Notification configuration
# Run these commands to create/modify new Notification configurations in dbt Cloud that will alert
# an "external" email address of your choosing of job events: cancels, failures, and successes.
# Note that you MUST manage this Notification configuration via the API -- there is currently
# not UI configuration within dbt Cloud.
# parameters:
### url
# {dbt_url} # the base URL of your dbt account, eg cloud.getdbt.com or emea.dbt.com
# {account_id} # Account ID to setup notifications for
### headers and body
# "account_id": 1, # Account ID to setup notifications for
# "user_id": 1, # Ignored when creating notifications for a new user, required when updating notifications for an existing user
# "on_cancel": [1, 2], # Job IDs to trigger cancel notifications for
# "on_failure": [1, 4], # Job IDs to trigger failure notifications for
# "on_success": [1, 5], # Job IDs to trigger success notifications for
# "state": 1, # 1 = Active, 2 = Deleted
# "type": 4, # Always 4, External email notification type
# "external_email": "email@example.com" # The email to send notifications to - Needed for the notifications for a new user and has to be removed when updating
# create notifications for a new user
curl \
--location \
--request POST 'https://{dbt_url}/api/v2/accounts/{account_id}/notifications/' \
--header 'Authorization: Token {XXX}' \
--header 'Content-Type: application/json' \
--data-raw '{
"account_id": 1,
"user_id": 1,
"on_cancel": [1, 2],
"on_failure": [1, 4],
"on_success": [1, 5],
"state": 1,
"type": 4,
"external_email": "email@example.com"
}'
# get the list of existing notifications for non-dbt users
curl \
--location \
--request GET 'https://{dbt_url}/api/v2/accounts/{account_id}/notifications/?type=4' \
--header 'Authorization: Token XXX' \
--header 'Content-Type: application/json'
# update notifications for an existing user
curl \
--location \
--request POST 'https://emea.dbt.com/api/v2/accounts/31/notifications/' \
--header 'Authorization: Token b8f4b3e407255eac3e70dd2fe7fd3b6fd7edc18b' \
--header 'Content-Type: application/json' \
--data-raw '{
"account_id": 31,
"user_id": 99,
"on_cancel": [],
"on_failure": [1],
"on_success": [1],
"state": 1,
"type": 4
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment