Please note: The user performing these actions through the API must have the "Notifications Administrator" role assigned, as in the UI.
LIST ALL POTENTIAL OPTIONS
In order to list all potential options, perform the following OPTIONS request, replacing "CHANNEL" with either "email" or "slack", as appropriate:
curl -OPT 'https://YOUR.STACK.datatap.adverity.com/api/notifications/CHANNEL/' \
-h 'Authorization: Token TOKEN_VALUE' \
LIST ALL ACTIVE EMAIL NOTIFICATIONS
In order to list all existing email notifications, perform the following GET request:
curl -GET 'https://YOUR.STACK.datatap.adverity.com/api/notifications/email/' \
-h 'Authorization: Token TOKEN_VALUE' \
Result (cropped to one entry)
{
"count": XYZ,
"next": null,
"previous": null,
"results": [
{
"id": EMAIL_NOTIFICATION_ID,
"user": USER_ID,
"topics": [
"ABC"
],
"enabled": true,
"stacks": [],
"datastreams": [],
"email": "RECIPIENT@DOMAIN.COM"
}
]
}
RETRIEVE A SPECIFIC NOTIFICATION
curl -GET 'https://YOUR.STACK.datatap.adverity.com/api/notifications/email/EMAIL_NOTIFICATION_ID/' \
-h 'Authorization: Token TOKEN_VALUE' \
Result
{
"id": EMAIL_NOTIFICATION_ID,
"user": USER_ID,
"topics": [
"ABC"
],
"enabled": true,
"stacks": [],
"datastreams": [],
"email": "RECIPIENT@DOMAIN.COM"
}
CREATE A NEW EMAIL NOTIFICATION
curl -POST 'https://YOUR.STACK.datatap.adverity.com/api/notifications/email/' \
-h 'Authorization: Token TOKEN_VALUE' \
-d '{
"topics":[
"ABC"
],
"stacks": ["STACK_ID"],
"email": "RECIPIENT@DOMAIN.COM"
}'
Result
{
"id": NOTIFICATION_ID,
"user": USER_ID,
"topics": [
"ABC"
],
"enabled": true,
"stacks": [],
"datastreams": [],
"email": "RECIPIENT@DOMAIN.COM"
}
{
"email": [
"Email provided is not associated with any existing user."
]
}
MODIFY AN EXISTING EMAIL NOTIFICATION
To amend an existing connection, send a PATCH request including the variable to change.
For instance, to change the recipient email address, the command would be as follows:
curl -PATCH 'https://YOUR.STACK.datatap.adverity.com/api/notifications/email/EMAIL_NOTIFICATION_ID/' \
-h 'Authorization: Token TOKEN_VALUE' \
-d'{"email": "NEW_RECIPIENT@DOMAIN.COM"}'
Result
{
"id": EMAIL_NOTIFICATION_ID,
"user": USER_ID,
"topics": [
"ABC"
],
"enabled": true,
"stacks": [
],
"datastreams": [],
"email": "NEW_RECIPIENT@DOMAIN.COM"
}
LIST ALL ACTIVE SLACK NOTIFICATIONS
curl -GET 'https://YOUR.STACK.datatap.adverity.com/api/notifications/slack/' \
-h 'Authorization: Token TOKEN_VALUE' \
Result
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": SLACK_NOTIFICATION_ID,
"user": USER_ID,
"topics": [
"ABC"
],
"enabled": true,
"stacks": [],
"datastreams": [],
"webhook_url": "SLACK_WEBHOOK_URL",
"channel": ""
}
]
}
CREATE A NEW SLACK NOTIFICATION
curl -POST 'https://YOUR.STACK.datatap.adverity.com/api/notifications/slack/' \
-h 'Authorization: Token TOKEN_VALUE' \
-d '{"webhook_url": "SLACK_WEBHOOK_URL", "topics": ["ABC", "XYZ"]}'
Result
{
"id": EMAIL_NOTIFICATION_ID,
"user": USER_ID,
"topics": [
"ABC"
],
"enabled": true,
"stacks": [],
"datastreams": [],
"webhook_url": "SLACK_WEBHOOK_URL",
"channel": ""
}
DELETE A NOTIFICATION
To delete a notification, use the following DELETE request. CHANNEL should be filled with either "email" or "slack", as appropriate.
curl -DELETE 'https://YOUR.STACK.datatap.adverity.com/api/notifications/CHANNEL/NOTIFICATION_ID/' \
-h 'Authorization: Token TOKEN_VALUE' \
Result
{
"status": "ok"
}
PARAMETERS EXPLAINED
"topics" - Criteria which will trigger a notification send. Required parameter.
"stacks" - The Workspace on which the notification will trigger. If left blank, all Workspaces that the user has access to will be used. Please use the stack_id for this.
"enabled" - Is this notification active. Default: true
"datastreams" - The individual Datastreams on which this notification will run. If left blank, they will run on every Datastream in the selected Workspace(s).
Comments
0 comments
Article is closed for comments.