Create an Issue Alert Rule for a Project

POST /api/0/projects/{organization_slug}/{project_id_or_slug}/rules/

Create a new issue alert rule for the given project.

An issue alert rule triggers whenever a new event is received for any issue in a project that matches the specified alert conditions. These conditions can include a resolved issue re-appearing or an issue affecting many users. Alert conditions have three parts:

  • Triggers: specify what type of activity you'd like monitored or when an alert should be triggered.
  • Filters: help control noise by triggering an alert only if the issue matches the specified criteria.
  • Actions: specify what should happen when the trigger conditions are met and the filters match.

Path Parameters

organization_slug (string)
REQUIRED

The slug of the organization the resource belongs to.

project_id_or_slug (string)
REQUIRED

The id or slug of the project the resource belongs to.

Body Parameters

name (string)
REQUIRED

The name for the rule.

actionMatch (string)
REQUIRED

A string determining which of the conditions need to be true before any filters are evaluated.

  • all - All conditions must evaluate to true.
  • any - At least one of the conditions must evaluate to true.
  • none - All conditions must evaluate to false.
conditions (array(object))
REQUIRED

A list of triggers that determine when the rule fires. See below for a list of possible conditions.

A new issue is created

Copied
{
    "id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
}

The issue changes state from resolved to unresolved

Copied
{
    "id": "sentry.rules.conditions.regression_event.RegressionEventCondition"
}

The issue is seen more than value times in interval

  • value - An integer
  • interval - Valid values are 1m, 5m, 15m, 1h, 1d, 1w and 30d (m for minutes, h for hours, d for days, and w for weeks).
Copied
{
    "id": "sentry.rules.conditions.event_frequency.EventFrequencyCondition",
    "value": 500,
    "interval": "1h"
}

The issue is seen by more than value users in interval

  • value - An integer
  • interval - Valid values are 1m, 5m, 15m, 1h, 1d, 1w and 30d (m for minutes, h for hours, d for days, and w for weeks).
Copied
{
    "id": "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition",
    "value": 1000,
    "interval": "15m"
}

The issue affects more than value percent of sessions in interval

  • value - An integer from 0 to 100
  • interval - Valid values are 5m, 10m, 30m, and 1h (m for minutes, h for hours).
Copied
{
    "id": "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition",
    "value": 50,
    "interval": "10m"
}
actions (array(object))
REQUIRED

A list of actions that take place when all required conditions and filters for the rule are met. See below for a list of possible actions.

Send a notification to Suggested Assignees

  • fallthroughType - Who the notification should be sent to if there are no suggested assignees. Valid values are ActiveMembers, AllMembers, and NoOne.
Copied
{
    "id" - "sentry.mail.actions.NotifyEmailAction",
    "targetType" - "IssueOwners",
    "fallthroughType" - "ActiveMembers"
}

Send a notification to a Member or a Team

  • targetType - One of Member or Team.
  • fallthroughType - Who the notification should be sent to if it cannot be sent to the original target. Valid values are ActiveMembers, AllMembers, and NoOne.
  • targetIdentifier - The ID of the Member or Team the notification should be sent to.
Copied
{
    "id": "sentry.mail.actions.NotifyEmailAction",
    "targetType": "Team"
    "fallthroughType": "AllMembers"
    "targetIdentifier": 4524986223
}

Send a Slack notification

  • workspace - The integration ID associated with the Slack workspace.
  • channel - The name of the channel to send the notification to (e.g., #critical, Jane Schmidt).
  • channel_id (optional) - The ID of the channel to send the notification to.
  • tags - A string of tags to show in the notification, separated by commas (e.g., "environment, user, my_tag").
  • notes - Text to show alongside the notification. To @ a user, include their user id like @<USER_ID>. To include a clickable link, format the link and title like <http://example.com|Click Here>.
Copied
{
    "id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
    "workspace": 293854098,
    "channel": "#warning",
    "tags": "environment,level"
    "notes": "Please <http://example.com|click here> for triage information"
}

Send a Microsoft Teams notification

  • team - The integration ID associated with the Microsoft Teams team.
  • channel - The name of the channel to send the notification to.
Copied
{
    "id": "sentry.integrations.msteams.notify_action.MsTeamsNotifyServiceAction",
    "team": 23465424,
    "channel": "General"
}

Send a Discord notification

  • server - The integration ID associated with the Discord server.
  • channel_id - The ID of the channel to send the notification to.
  • tags - A string of tags to show in the notification, separated by commas (e.g., "environment, user, my_tag").
Copied
{
    "id": "sentry.integrations.discord.notify_action.DiscordNotifyServiceAction",
    "server": 63408298,
    "channel_id": 94732897,
    "tags": "browser,user"
}

Create a Jira Ticket

  • integration - The integration ID associated with Jira.
  • project - The ID of the Jira project.
  • issuetype - The ID of the type of issue that the ticket should be created as.
  • dynamic_form_fields (optional) - A list of any custom fields you want to include in the ticket as objects.
Copied
{
    "id": "sentry.integrations.jira.notify_action.JiraCreateTicketAction",
    "integration": 321424,
    "project": "349719"
    "issueType": "1"
}

Create a Jira Server Ticket

  • integration - The integration ID associated with Jira Server.
  • project - The ID of the Jira Server project.
  • issuetype - The ID of the type of issue that the ticket should be created as.
  • dynamic_form_fields (optional) - A list of any custom fields you want to include in the ticket as objects.
Copied
{
    "id": "sentry.integrations.jira_server.notify_action.JiraServerCreateTicketAction",
    "integration": 321424,
    "project": "349719"
    "issueType": "1"
}

Create a GitHub Issue

  • integration - The integration ID associated with GitHub.
  • repo - The name of the repository to create the issue in.
  • title - The title of the issue.
  • body (optional) - The contents of the issue.
  • assignee (optional) - The GitHub user to assign the issue to.
  • labels (optional) - A list of labels to assign to the issue.
Copied
{
    "id": "sentry.integrations.github.notify_action.GitHubCreateTicketAction",
    "integration": 93749,
    "repo": default,
    "title": "My Test Issue",
    "assignee": "Baxter the Hacker",
    "labels": ["bug", "p1"]
    ""
}

Create a GitHub Enterprise Issue

  • integration - The integration ID associated with GitHub Enterprise.
  • repo - The name of the repository to create the issue in.
  • title - The title of the issue.
  • body (optional) - The contents of the issue.
  • assignee (optional) - The GitHub user to assign the issue to.
  • labels (optional) - A list of labels to assign to the issue.
Copied
{
    "id": "sentry.integrations.github_enterprise.notify_action.GitHubEnterpriseCreateTicketAction",
    "integration": 93749,
    "repo": default,
    "title": "My Test Issue",
    "assignee": "Baxter the Hacker",
    "labels": ["bug", "p1"]
    ""
}

Create an Azure DevOps work item

  • integration - The integration ID.
  • project - The ID of the Azure DevOps project.
  • work_item_type - The type of work item to create.
  • dynamic_form_fields (optional) - A list of any custom fields you want to include in the work item as objects.
Copied
{
    "id": "sentry.integrations.vsts.notify_action.AzureDevopsCreateTicketAction",
    "integration": 294838,
    "project": "0389485",
    "work_item_type": "Microsoft.VSTS.WorkItemTypes.Task",
}

Send a PagerDuty notification

  • account - The integration ID associated with the PagerDuty account.
  • service - The ID of the service to send the notification to.
  • severity - The severity of the Pagerduty alert. This is optional, the default is critical for fatal issues, error for error issues, warning for warning issues, and info for info and debug issues.
Copied
{
    "id": "sentry.integrations.pagerduty.notify_action.PagerDutyNotifyServiceAction",
    "account": 92385907,
    "service": 9823924,
    "severity": "critical"
}

Send an Opsgenie notification

  • account - The integration ID associated with the Opsgenie account.
  • team - The ID of the Opsgenie team to send the notification to.
  • priority - The priority of the Opsgenie alert. This is optional, the default is P3.
Copied
{
    "id": "sentry.integrations.opsgenie.notify_action.OpsgenieNotifyTeamAction",
    "account": 8723897589,
    "team": "9438930258-fairy",
    "priority": "P1"
}

Send a notification to a service

  • service - The plugin slug.
Copied
{
    "id": "sentry.rules.actions.notify_event_service.NotifyEventServiceAction",
    "service": "mail"
}

Send a notification to a Sentry app with a custom webhook payload

  • settings - A list of objects denoting the settings each action will be created with. All required fields must be included.
  • sentryAppInstallationUuid - The ID for the Sentry app
Copied
{
    "id": "sentry.rules.actions.notify_event_sentry_app.NotifyEventSentryAppAction",
    "settings": [
        {"name": "title", "value": "Team Rocket"},
        {"name": "summary", "value": "We're blasting off again."},
    ],
    "sentryAppInstallationUuid": 643522
    "hasSchemaFormConfig": true
}

Send a notification (for all legacy integrations)

Copied
{
    "id": "sentry.rules.actions.notify_event.NotifyEventAction"
}
frequency (integer)
REQUIRED

How often to perform the actions once for an issue, in minutes. The valid range is 5 to 43200.

environment (string)

The name of the environment to filter by.

filterMatch (string)

A string determining which filters need to be true before any actions take place. Required when a value is provided for filters.

  • all - All filters must evaluate to true.
  • any - At least one of the filters must evaluate to true.
  • none - All filters must evaluate to false.
filters (array(object))

A list of filters that determine if a rule fires after the necessary conditions have been met. See below for a list of possible filters.

The issue is comparison_type than value time

  • comparison_type - One of older or newer
  • value - An integer
  • time - The unit of time. Valid values are minute, hour, day, and week.
Copied
{
    "id": "sentry.rules.filters.age_comparison.AgeComparisonFilter",
    "comparison_type": "older",
    "value": 3,
    "time": "week"
}

The issue has happened at least value times

  • value - An integer
Copied
{
    "id": "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter",
    "value": 120
}

The issue is assigned to No One

Copied
{
    "id": "sentry.rules.filters.assigned_to.AssignedToFilter",
    "targetType": "Unassigned"
}

The issue is assigned to targetType

  • targetType - One of Team or Member
  • targetIdentifier - The target's ID
Copied
{
    "id": "sentry.rules.filters.assigned_to.AssignedToFilter",
    "targetType": "Member",
    "targetIdentifier": 895329789
}

The event is from the latest release

Copied
{
    "id": "sentry.rules.filters.latest_release.LatestReleaseFilter"
}

The issue's category is equal to value

  • value - An integer correlated with a category. Valid values are 1 (Error), 2 (Performance), 3 (Profile), 4 (Cron), and 5 (Replay).
Copied
{
    "id": "sentry.rules.filters.issue_category.IssueCategoryFilter",
    "value": 2
}

The event's attribute value match value

  • attribute - Valid values are message, platform, environment, type, error.handled, error.unhandled, error.main_thread, exception.type, exception.value, user.id, user.email, user.username, user.ip_address, http.method, http.url, http.status_code, sdk.name, stacktrace.code, stacktrace.module, stacktrace.filename, stacktrace.abs_path, stacktrace.package, unreal.crashtype, and app.in_foreground.
  • match - The comparison operator. Valid values are eq (equals), ne (does not equal), sw (starts with), ew (ends with), co (contains), nc (does not contain), is (is set), and ns (is not set).
  • value - A string. Not required when match is is or ns.
Copied
{
    "id": "sentry.rules.conditions.event_attribute.EventAttributeCondition",
    "attribute": "http.url",
    "match": "nc",
    "value": "localhost"
}

The event's tags match key match value

  • key - The tag
  • match - The comparison operator. Valid values are eq (equals), ne (does not equal), sw (starts with), ew (ends with), co (contains), nc (does not contain), is (is set), and ns (is not set).
  • value - A string. Not required when match is is or ns.
Copied
{
    "id": "sentry.rules.filters.tagged_event.TaggedEventFilter",
    "key": "level",
    "match": "eq"
    "value": "error"
}

The event's level is match level

  • match - Valid values are eq, gte, and lte.
  • level - Valid values are 50 (fatal), 40 (error), 30 (warning), 20 (info), 10 (debug), 0 (sample).
Copied
{
    "id": "sentry.rules.filters.level.LevelFilter",
    "match": "gte"
    "level": "50"
}
owner (string)

The ID of the team or user that owns the rule.

Scopes

<auth_token> requires one of the following scopes:
  • alerts:write
  • project:admin
  • project:write
curl https://sentry.io/api/0/projects/{organization_slug}/{project_id_or_slug}/rules/ \
 -H 'Authorization: Bearer <auth_token>' \
 -H 'Content-Type: application/json' \
 -d '{}'
RESPONSESCHEMA
{
  "id": "1",
  "conditions": [
    {
      "id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
    }
  ],
  "filters": [
    {
      "targetType": "Unassigned",
      "id": "sentry.rules.filters.assigned_to.AssignedToFilter",
      "targetIdentifier": ""
    }
  ],
  "actions": [
    {
      "targetType": "Member",
      "fallthroughType": "ActiveMembers",
      "id": "sentry.mail.actions.NotifyEmailAction",
      "targetIdentifier": 1523125
    }
  ],
  "actionMatch": "any",
  "filterMatch": "all",
  "frequency": 1440,
  "name": "Owner Alert",
  "dateCreated": "2023-09-08T20:00:07.244602Z",
  "owner": "team:74234",
  "createdBy": {
    "id": 24601,
    "name": "Jean Valjean",
    "email": "jean@example.com"
  },
  "environment": null,
  "projects": [
    "python"
  ],
  "status": "active",
  "snooze": false
}