Last active
January 14, 2021 22:47
-
-
Save vudngo/c505d75c79e7ed1fe6592a64a790b331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = "https://sentry.io/api/0/projects/<ORG_SLUG_HERE>/<PROJECT_SLUG_HERE>/rules/" | |
payload = "{\"environment\":null,\"actionMatch\":\"all\",\"frequency\":\"30\",\"name\":\"API Alert Example\",\"conditions\":[{\"name\":\"An event is first seen\",\"id\":\"sentry.rules.conditions.first_seen_event.FirstSeenEventCondition\"},\n{\"interval\":\"1h\",\"name\":\"An event is seen more than 50 times in 1h\",\"value\":50,\"id\":\"sentry.rules.conditions.event_frequency.EventFrequencyCondition\"}],\"id\":\"412675\",\"actions\":[{\"name\":\"Send a notification (for all legacy integrations)\",\"id\":\"sentry.rules.actions.notify_event.NotifyEventAction\"},{\"channel_id\":\"CA6MX2DE2\",\"name\":\"Send a notification to the vu Slack workspace to #ember-errors and show tags [] in notification\",\"workspace\":\"1305\",\"tags\":\"\",\"id\":\"sentry.integrations.slack.notify_action.SlackNotifyServiceAction\",\"channel\":\"#ember-errors\"}]}" | |
headers = { | |
'Content-Type': "application/json", | |
'Authorization': "Bearer <API_TOKEN_HERE>" | |
} | |
response = requests.request("POST", url, data=payload, headers=headers) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment