{"_id":"5bc49df51d1b0000182bfeb0","project":"564e5930c3553e0d003e53d0","version":{"_id":"564e5a9b1560880d008d30dc","project":"564e5930c3553e0d003e53d0","__v":22,"createdAt":"2015-11-19T23:26:19.166Z","releaseDate":"2015-11-19T23:26:19.166Z","categories":["564e5a9b1560880d008d30dd","566318e1f5ca460d00f41896","56631d08cd54d50d005015fa","56631d2a81ad7417006a202c","5668ba19fbd7680d009375f4","5668cb8b10bda80d00797ed9","5668cb9d10bda80d00797eda","56830d8a3f94e00d004e2a7a","56830d9072bb720d0091f594","56830d94cb4d190d0027698e","56830dc44aecbd0d00a464c5","569e90f3c9b43e0d00c4bab1","56a96d338791090d00113bab","56b12d8336d2580d00247877","56c36bf0a869d017002ea55b","56c36bf93d30210d00ea84bb","56c77749b935671700ff0304","56c7ab9e5652c217008e091a","56cb8bdad5c6241d00ef5e61","58aefce02470660f00b54539","58aefd0bebd7370f0078b954","59ca65ca4337830026edf24f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Foundation","version_clean":"2.0.0","version":"2"},"category":{"_id":"56a96d338791090d00113bab","__v":13,"pages":["56a96d492bb3910d000ee931","56c3cec2106c12170020db96","56c51da4ba4a540d0091b9b7","56c51dc3ba4a540d0091b9b9","56c51eb916c7190d00ff7b19","56c51ec2d7b9ed19008d1752","56c51eec668eb01900719bcd","56c51effba4a540d0091b9bb","56c51f1cf7c4da0d00614b02","56c51f2a8dc1c51900abc142","56c51f367de3580d00bdaf2a","56c67b6270e7660d004a8985","56c67b7cfd00bb0d0016daad"],"project":"564e5930c3553e0d003e53d0","version":"564e5a9b1560880d008d30dc","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-28T01:21:55.716Z","from_sync":false,"order":1,"slug":"patterns","title":"REST API v2"},"user":"5668c7855d13810d0060961d","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-10-15T14:02:29.855Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"[block:api-header]\n{\n  \"title\": \"Definition\"\n}\n[/block]\nEvent rules are used to configure what happens to an event that is sent to PagerDuty from your monitoring tools and other integrations. An event rule can suppress, set severity, set incident priority, add a note, and route an event to a service. When routing an event, an incident may be created on the target service.\n\nAll requests should be made to the `/event_rules` endpoint and must specify the following headers:\n\n  * **Authorization**: All PagerDuty REST APIs require [Authentication](doc:authentication). In order to make successful requests to the API, you must provide a valid form of authorization.\n  * **Content-Type:** `application/json`\n  * **Accept**: `application/vnd.pagerduty+json;version=2`\n[block:api-header]\n{\n  \"title\": \"Event Intelligence\"\n}\n[/block]\nSome API features are available as part of our [Event Intelligence](https://www.pagerduty.com/features/event-intelligence-and-automation/) product. These include:\n\n* The ability to use an event rule to add a note to an incident\n* The ability to set up a threshold event rule\n* The ability to have a scheduled or recurring event rule\n[block:api-header]\n{\n  \"title\": \"List Global Event Rules\"\n}\n[/block]\nA `GET` request to `/event_rules` will return a list of all global event rules in your account. There are no parameters for this request.\n\nThere are some key elements to note in the response. Namely, each `rule` has an `id`. The `id` of a rule is important to note; it's required to update properties of that rule, or to delete the rule.\n\n# Parameters\n\nNone.\n\n### Sample Response\n\n```\n{\n    \"rules\": [\n        {\n            \"id\": \"6d53c1c5-a960-4c39-b675-3539039bd275\",\n            \"condition\": [\n                \"or\",\n                [\n                    \"equals\",\n                    [\n                        \"path\",\n                        \"payload\",\n                        \"source\"\n                    ],\n                    \"prod-website\"\n                ]\n            ],\n            \"catch_all\": false,\n            \"advanced_condition\": [],\n            \"actions\": [\n                [\n                    \"route\",\n                    \"PYZDVUB\"\n                ]\n            ]\n        },\n        {\n            \"id\": \"daf1f0e0-0480-4730-ba87-14ec00e15bdd\",\n            \"catch_all\": true,\n            \"advanced_condition\": [],\n            \"actions\": [\n                [\n                    \"suppress\",\n                    true\n                ]\n            ]\n        }\n    ],\n    \"object_version\": \"JRm2lJc3S8u4pwpR1w9ScLA5.BQogPF2\",\n    \"format_version\": \"1\",\n    \"external_id\": \"<Global routing key>\"\n}\n```\n### Displayed in the UI\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/432dac7-KB_-_Event_Rules_-_PagerDuty.jpg\",\n        \"KB_-_Event_Rules_-_PagerDuty.jpg\",\n        3140,\n        776,\n        \"#f1f1f1\"\n      ]\n    }\n  ]\n}\n[/block]\n### Other Fields\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`object_version`\",\n    \"1-0\": \"`format_version`\",\n    \"2-0\": \"`external_id`\",\n    \"0-1\": \"This is the version number of the event rules schema. If any significant changes to the schema happen, this version will be bumped and the schema changes documented. There are no immediate plans to change this schema.\",\n    \"1-1\": \"The revision number of the account’s current ruleset. This changes every time the ruleset changes.\",\n    \"2-1\": \"The global event rules routing key.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Create a Global Event Rule\"\n}\n[/block]\nA `POST` request to `/event_rules` will create a new global event rule.\n\n# Parameters\n\n## Condition\n\nThe `condition` field contains a list of conditions. The first field in the list is `and` or `or`, followed by a list of operators and values.\n\n### Example\n\n```\n\"condition\": [\n  \"and\",\n  [\n    \"contains\",\n    [\n      \"path\",\n      \"payload\",\n      \"source\"\n    ],\n    \"website\"\n  ]\n]\n```\n\n### Displayed in the UI\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b6843f2-Event_Rules_-_PagerDuty.jpg\",\n        \"Event_Rules_-_PagerDuty.jpg\",\n        3154,\n        896,\n        \"#f1f0f0\"\n      ]\n    }\n  ]\n}\n[/block]\n### Operators\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Operator\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`contains`\",\n    \"1-0\": \"`ncontains`\",\n    \"2-0\": \"`exists`\",\n    \"3-0\": \"`nexists`\",\n    \"4-0\": \"`equals`\",\n    \"5-0\": \"`nequals`\",\n    \"6-0\": \"`matches`\",\n    \"7-0\": \"`nmatches`\",\n    \"0-1\": \"The field contains a value.\",\n    \"1-1\": \"The field does not contain a value.\",\n    \"2-1\": \"The field exists.\",\n    \"3-1\": \"The field does not exist.\",\n    \"4-1\": \"The field equals a value.\",\n    \"5-1\": \"The field does not equal a value.\",\n    \"6-1\": \"The field matches a regular expression with [RE2 syntax](https://github.com/google/re2).\",\n    \"7-1\": \"The field does not match a regular expression with [RE2 syntax](https://github.com/google/re2).\"\n  },\n  \"cols\": 2,\n  \"rows\": 8\n}\n[/block]\nThe value after the operator is another list. The first element is `path`, followed by the name of a field. If the field is a child of another field, the full field path can be traversed. For example, given this event payload:\n\n```\n{\"parent\":{\"child\":{\"grandchild\": 1}}}\n```\n\nThe following is written in order to use the `grandchild` field:\n\n```\n[\n  \"path\",\n  \"parent\",\n  \"child\",\n  \"grandchild\"\n]\n```\n\n## Advanced Condition\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"First Element\",\n    \"h-1\": \"Second Element\",\n    \"h-2\": \"Third Element\",\n    \"h-3\": \"Fourth Element\",\n    \"h-4\": \"Fifth Element\",\n    \"0-0\": \"`active-between`\",\n    \"1-0\": \"`scheduled-weekly`\",\n    \"2-0\": \"`frequency-over`\",\n    \"0-1\": \"The start time in milliseconds (number of milliseconds since the Unix Epoch on January 1st, 1970 at UTC).\",\n    \"0-2\": \"The end time in milliseconds.\",\n    \"1-1\": \"The start time in milliseconds (number of milliseconds since the Unix Epoch on January 1st, 1970 at UTC).\",\n    \"1-2\": \"The duration in milliseconds.\",\n    \"1-3\": \"The time zone.\",\n    \"1-4\": \"An array of day values. Ex: [1, 3, 5] is Monday, Wednesday, Friday.\",\n    \"2-1\": \"The frequency.\",\n    \"2-2\": \"The amount of time to wait before triggering.\",\n    \"2-3\": \"The unit of time. Possible values are: “minutes”, “hours”, and “days”.\",\n    \"2-4\": \"--\",\n    \"0-3\": \"--\",\n    \"0-4\": \"--\"\n  },\n  \"cols\": 5,\n  \"rows\": 3\n}\n[/block]\n## Actions\n\nThe `actions` list contains one or more items. Each action within the list is itself a list.\n\n### Example\n\n```\n\"actions\": [\n  [\n    \"route\",\n    \"PABC123\"\n  ],\n  [\n    \"suppress\",\n    false\n  ],\n  [\n    \"severity\",\n    \"info\"\n  ]\n]\n```\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"First Element\",\n    \"h-1\": \"Second Element\",\n    \"0-0\": \"`route`\",\n    \"1-0\": \"`suppress`\",\n    \"2-0\": \"`severity`\",\n    \"3-0\": \"`annotate`\",\n    \"0-1\": \"The service ID of the target service. You can find the service you want to route to by calling the services endpoint.\",\n    \"1-1\": \"A boolean value indicating whether or not the event should be suppressed.\",\n    \"2-1\": \"One of `info`, `warning`, `error`, `critical`, or `unknown`.\",\n    \"3-1\": \"The note to set on any new incident created as a result of the event rule.\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Update a Global Event Rule\"\n}\n[/block]\nIssue a `PUT` request to `/event_rules/<rule_id>` to update an existing global event rule. The parameters are the same as when creating a new global event rule.\n[block:api-header]\n{\n  \"title\": \"Delete a Global Event Rule\"\n}\n[/block]\nIssue a `DELETE` request to `/event_rules/<rule_id>` to delete a global event rule.\n[block:api-header]\n{\n  \"title\": \"Example Requests\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n \\\"condition\\\": [\\n   \\\"and\\\",\\n     [\\\"contains\\\",\\n       [\\\"path\\\", \\\"payload\\\", \\\"source\\\"],\\n       \\\"website\\\"\\n     ]\\n ],\\n \\\"actions\\\": [\\n   [\\\"route\\\",\\\"PXYZ123\\\"]\\n ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Basic routing rule\"\n    }\n  ]\n}\n[/block]","excerpt":"Manage your global event rules using the REST API","slug":"global-event-rules-api","type":"basic","title":"Global Event Rules API"}

Global Event Rules API

Manage your global event rules using the REST API

[block:api-header] { "title": "Definition" } [/block] Event rules are used to configure what happens to an event that is sent to PagerDuty from your monitoring tools and other integrations. An event rule can suppress, set severity, set incident priority, add a note, and route an event to a service. When routing an event, an incident may be created on the target service. All requests should be made to the `/event_rules` endpoint and must specify the following headers: * **Authorization**: All PagerDuty REST APIs require [Authentication](doc:authentication). In order to make successful requests to the API, you must provide a valid form of authorization. * **Content-Type:** `application/json` * **Accept**: `application/vnd.pagerduty+json;version=2` [block:api-header] { "title": "Event Intelligence" } [/block] Some API features are available as part of our [Event Intelligence](https://www.pagerduty.com/features/event-intelligence-and-automation/) product. These include: * The ability to use an event rule to add a note to an incident * The ability to set up a threshold event rule * The ability to have a scheduled or recurring event rule [block:api-header] { "title": "List Global Event Rules" } [/block] A `GET` request to `/event_rules` will return a list of all global event rules in your account. There are no parameters for this request. There are some key elements to note in the response. Namely, each `rule` has an `id`. The `id` of a rule is important to note; it's required to update properties of that rule, or to delete the rule. # Parameters None. ### Sample Response ``` { "rules": [ { "id": "6d53c1c5-a960-4c39-b675-3539039bd275", "condition": [ "or", [ "equals", [ "path", "payload", "source" ], "prod-website" ] ], "catch_all": false, "advanced_condition": [], "actions": [ [ "route", "PYZDVUB" ] ] }, { "id": "daf1f0e0-0480-4730-ba87-14ec00e15bdd", "catch_all": true, "advanced_condition": [], "actions": [ [ "suppress", true ] ] } ], "object_version": "JRm2lJc3S8u4pwpR1w9ScLA5.BQogPF2", "format_version": "1", "external_id": "<Global routing key>" } ``` ### Displayed in the UI [block:image] { "images": [ { "image": [ "https://files.readme.io/432dac7-KB_-_Event_Rules_-_PagerDuty.jpg", "KB_-_Event_Rules_-_PagerDuty.jpg", 3140, 776, "#f1f1f1" ] } ] } [/block] ### Other Fields [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "0-0": "`object_version`", "1-0": "`format_version`", "2-0": "`external_id`", "0-1": "This is the version number of the event rules schema. If any significant changes to the schema happen, this version will be bumped and the schema changes documented. There are no immediate plans to change this schema.", "1-1": "The revision number of the account’s current ruleset. This changes every time the ruleset changes.", "2-1": "The global event rules routing key." }, "cols": 2, "rows": 3 } [/block] [block:api-header] { "title": "Create a Global Event Rule" } [/block] A `POST` request to `/event_rules` will create a new global event rule. # Parameters ## Condition The `condition` field contains a list of conditions. The first field in the list is `and` or `or`, followed by a list of operators and values. ### Example ``` "condition": [ "and", [ "contains", [ "path", "payload", "source" ], "website" ] ] ``` ### Displayed in the UI [block:image] { "images": [ { "image": [ "https://files.readme.io/b6843f2-Event_Rules_-_PagerDuty.jpg", "Event_Rules_-_PagerDuty.jpg", 3154, 896, "#f1f0f0" ] } ] } [/block] ### Operators [block:parameters] { "data": { "h-0": "Operator", "h-1": "Description", "0-0": "`contains`", "1-0": "`ncontains`", "2-0": "`exists`", "3-0": "`nexists`", "4-0": "`equals`", "5-0": "`nequals`", "6-0": "`matches`", "7-0": "`nmatches`", "0-1": "The field contains a value.", "1-1": "The field does not contain a value.", "2-1": "The field exists.", "3-1": "The field does not exist.", "4-1": "The field equals a value.", "5-1": "The field does not equal a value.", "6-1": "The field matches a regular expression with [RE2 syntax](https://github.com/google/re2).", "7-1": "The field does not match a regular expression with [RE2 syntax](https://github.com/google/re2)." }, "cols": 2, "rows": 8 } [/block] The value after the operator is another list. The first element is `path`, followed by the name of a field. If the field is a child of another field, the full field path can be traversed. For example, given this event payload: ``` {"parent":{"child":{"grandchild": 1}}} ``` The following is written in order to use the `grandchild` field: ``` [ "path", "parent", "child", "grandchild" ] ``` ## Advanced Condition [block:parameters] { "data": { "h-0": "First Element", "h-1": "Second Element", "h-2": "Third Element", "h-3": "Fourth Element", "h-4": "Fifth Element", "0-0": "`active-between`", "1-0": "`scheduled-weekly`", "2-0": "`frequency-over`", "0-1": "The start time in milliseconds (number of milliseconds since the Unix Epoch on January 1st, 1970 at UTC).", "0-2": "The end time in milliseconds.", "1-1": "The start time in milliseconds (number of milliseconds since the Unix Epoch on January 1st, 1970 at UTC).", "1-2": "The duration in milliseconds.", "1-3": "The time zone.", "1-4": "An array of day values. Ex: [1, 3, 5] is Monday, Wednesday, Friday.", "2-1": "The frequency.", "2-2": "The amount of time to wait before triggering.", "2-3": "The unit of time. Possible values are: “minutes”, “hours”, and “days”.", "2-4": "--", "0-3": "--", "0-4": "--" }, "cols": 5, "rows": 3 } [/block] ## Actions The `actions` list contains one or more items. Each action within the list is itself a list. ### Example ``` "actions": [ [ "route", "PABC123" ], [ "suppress", false ], [ "severity", "info" ] ] ``` [block:parameters] { "data": { "h-0": "First Element", "h-1": "Second Element", "0-0": "`route`", "1-0": "`suppress`", "2-0": "`severity`", "3-0": "`annotate`", "0-1": "The service ID of the target service. You can find the service you want to route to by calling the services endpoint.", "1-1": "A boolean value indicating whether or not the event should be suppressed.", "2-1": "One of `info`, `warning`, `error`, `critical`, or `unknown`.", "3-1": "The note to set on any new incident created as a result of the event rule." }, "cols": 2, "rows": 4 } [/block] [block:api-header] { "title": "Update a Global Event Rule" } [/block] Issue a `PUT` request to `/event_rules/<rule_id>` to update an existing global event rule. The parameters are the same as when creating a new global event rule. [block:api-header] { "title": "Delete a Global Event Rule" } [/block] Issue a `DELETE` request to `/event_rules/<rule_id>` to delete a global event rule. [block:api-header] { "title": "Example Requests" } [/block] [block:code] { "codes": [ { "code": "{\n \"condition\": [\n \"and\",\n [\"contains\",\n [\"path\", \"payload\", \"source\"],\n \"website\"\n ]\n ],\n \"actions\": [\n [\"route\",\"PXYZ123\"]\n ]\n}", "language": "json", "name": "Basic routing rule" } ] } [/block]