> Documentation index for AI agents: https://docs.pagerduty.com/llms.txt

# List Service's Event Rules

`GET https://api.pagerduty.com/services/{id}/rules`

List Event Rules on a Service.
<!-- theme: warning -->
> ### End-of-life
> Rulesets and Event Rules will end-of-life soon. We highly recommend that you [migrate to Event Orchestration](https://support.pagerduty.com/docs/migrate-to-event-orchestration) as soon as possible so you can take advantage of the new functionality, such as improved UI, rule creation, APIs and Terraform support, advanced conditions, and rule nesting.

Scoped OAuth requires: `services.read`

## Authorization

- **api_key** (apiKey) — `Authorization` header. The API Key with format `Token token=<API_KEY>`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | The ID of the resource. |

## Query parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `limit` | integer |  | The number of results per page. |
| `offset` | integer |  | Offset to start pagination search results. |
| `total` | boolean |  | By default the `total` field in pagination responses is set to `null` to provide the fastest possible response times. Set `total` to `true` for this field to be populated. See our [Pagination Docs](https://docs.pagerduty.com/developer/pagination) for more information. Default: `false`. |
| `include[]` | string |  | Array of additional Models to include in response. One of: `migrated_metadata`. Items must be unique. |

## Header parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Accept` | string | yes | The `Accept` header is used as a versioning header. Default: `application/vnd.pagerduty+json;version=2`. |

## Response 200

A paginated array of Event Rule objects.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `offset` | integer |  | Echoes offset pagination property. Read-only. |
| `limit` | integer |  | Echoes limit pagination property. Read-only. |
| `more` | boolean |  | Indicates if there are additional records to return. Read-only. |
| `total` | integer \| null |  | The total number of records matching the given query. Read-only. |
| `migrated_at` | string (date-time) |  | The date/time the service's Event Rules were converted to a Service Orchestration. This property is only included if the `migrated_metadata` query parameter is provided. Read-only. |
| `migrated_by` | object |  | Reference to the user that converted the service's Event Rules to a Service Orchestration. This property is only included if the `migrated_metadata` query parameter is provided. Read-only. |
| `migrated_by.id` | string |  | Read-only. |
| `migrated_by.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `migrated_by.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `migrated_status` | string |  | The status indicating whether the service's Event Rules were successfully converted to a Service Orchestration. This property is only included if the `migrated_metadata` query parameter is provided. Read-only. One of: `completed`. |
| `migrated_to` | object |  | Reference to the Service Orchestration that the service's Event Rules were converted to. This property is only included if the `migrated_metadata` query parameter is provided. Read-only. |
| `migrated_to.id` | string |  | Read-only. |
| `migrated_to.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `migrated_to.self` | string (url) |  | The API show URL at which the object is accessible. Read-only. |
| `migrated_via` | string |  | Indicates whether the conversion was performed via the PagerDuty API or PagerDuty website. This property is only included if the `migrated_metadata` query parameter is provided. Read-only. One of: `API`, `UI`. |
| `rules` | array of object |  | The paginated list of Event Rules of the Service. |
| `rules[].id` | string |  | ID of the Event Rule. Read-only. |
| `rules[].self` | string (url) |  | the API show URL at which the object is accessible. Read-only. |
| `rules[].disabled` | boolean |  | Indicates whether the Event Rule is disabled and would therefore not be evaluated. |
| `rules[].conditions` | object |  | Conditions evaluated to check if an event matches this Event Rule. Is always empty for the catch_all rule, though. |
| `rules[].conditions.operator` | string | yes | Operator to combine sub-conditions. One of: `and`, `or`. |
| `rules[].conditions.subconditions` | array of object | yes | Array of sub-conditions. |
| `rules[].conditions.subconditions[].operator` | string | yes | The type of operator to apply. One of: `exists`, `nexists`, `equals`, `nequals`, `contains`, `ncontains`, `matches`, `nmatches`. |
| `rules[].conditions.subconditions[].parameters` | object | yes |  |
| `rules[].conditions.subconditions[].parameters.path` | string | yes | Path to a field in an event, in dot-notation. For Event Rules on a serivce, this will have to be a PD-CEF field. |
| `rules[].conditions.subconditions[].parameters.value` | string | yes | Value to apply to the operator. |
| `rules[].conditions.subconditions[].parameters.options` | object |  | Options to configure the operator. |
| `rules[].time_frame` | object |  | Time-based conditions for limiting when the rule is active. |
| `rules[].time_frame.active_between` | object |  | A fixed window of time during which the rule is active. |
| `rules[].time_frame.active_between.start_time` | integer | yes | The start time in milliseconds. |
| `rules[].time_frame.active_between.end_time` | integer | yes | End time in milliseconds. |
| `rules[].time_frame.scheduled_weekly` | object |  | A reccuring window of time based on the day of the week, during which the rule is active. |
| `rules[].time_frame.scheduled_weekly.start_time` | integer | yes | The amount of milliseconds into the day at which the window starts. |
| `rules[].time_frame.scheduled_weekly.duration` | integer | yes | The duration of the window in milliseconds. |
| `rules[].time_frame.scheduled_weekly.timezone` | string | yes | The timezone. |
| `rules[].time_frame.scheduled_weekly.weekdays` | array of integer | yes | An array of day values. Ex [1, 3, 5] is Monday, Wednesday, Friday. |
| `rules[].variables` | array of object |  | [Early Access] Populate variables from event payloads and use those variables in other event actions. |
| `rules[].variables[].type` | string | yes | The type of operation to populate the variable. One of: `regex`. |
| `rules[].variables[].name` | string | yes | The name of the variable. |
| `rules[].variables[].parameters` | object | yes | The parameters for performing the operation to populate the. |
| `rules[].variables[].parameters.value` | string | yes | The value for the operation. For example, an RE2 regular expression for regex-type variables. |
| `rules[].variables[].parameters.path` | string | yes | Path to a field in an event, in dot-notation. For Event Rules on a Service, this will have to be a PD-CEF field. |
| `rules[].position` | integer |  | Position/index of the Event Rule on the Service. Starting from position 0 (the first rule), rules are evaluated one-by-one until a matching Event Rule is found or the end of the list is reached. |
| `rules[].actions` | object |  | When an event matches this Event Rule, the actions that will be taken to change the resulting Alert and Incident. |
| `rules[].actions.annotate` | object \| null |  | Set a note on the resulting incident. |
| `rules[].actions.annotate.value` | string | yes | The content of the note. |
| `rules[].actions.event_action` | object \| null |  | Set whether the resulting alert status is trigger or resolve. |
| `rules[].actions.event_action.value` | string | yes | One of: `trigger`, `resolve`. |
| `rules[].actions.extractions` | array of one of: object \| object |  | Dynamically extract values to set and modify new and existing PD-CEF fields. |
| `rules[].actions.extractions[].target` | string | yes | (option 1) The PD-CEF field that will be set with the value from the regex. |
| `rules[].actions.extractions[].source` | string | yes | (option 1) The path to the event field where the regex will be applied to extract a value. |
| `rules[].actions.extractions[].regex` | string | yes | (option 1) A RE2 regular expression. If it contains one or more capture groups, their values will be extracted and appended together. If it contains no capture groups, the whole match is used. |
| `rules[].actions.extractions[].target` | string | yes | (option 2) The PD-CEF field that will be set with the value from the regex. |
| `rules[].actions.extractions[].template` | string | yes | (option 2) A value that will be used to populate the target PD-CEF field. You can include variables extracted from the payload by using string interpolation. |
| `rules[].actions.priority` | object \| null |  | Set the priority ID for the resulting incident. You can find the priority you want by calling the priorities endpoint. |
| `rules[].actions.priority.value` | string | yes | The priority ID. |
| `rules[].actions.severity` | object \| null |  | Set the severity of the resulting alert. |
| `rules[].actions.severity.value` | string | yes | One of: `info`, `warning`, `error`, `critical`. |
| `rules[].actions.suppress` | object |  | Set whether the resulting alert is suppressed. Can optionally be used with a threshold where resulting alerts will be suppressed until the threshold is met in a window of time. If using a threshold the rule must also set a route action. |
| `rules[].actions.suppress.value` | boolean | yes |  |
| `rules[].actions.suppress.threshold_value` | integer |  | The number of occurences needed during the window of time to trigger the theshold. |
| `rules[].actions.suppress.threshold_time_unit` | string |  | The time unit for the window of time. One of: `seconds`, `minutes`, `hours`. |
| `rules[].actions.suppress.threshold_time_amount` | integer |  | The amount of time units for the window of time. |
| `rules[].actions.suspend` | object \| null |  | Set the length of time to suspend the resulting alert before triggering. Rules with a suspend action must also set a route action, and cannot have a suppress with threshold action. |
| `rules[].actions.suspend.value` | integer | yes | The amount of time to suspend the alert in seconds. |

Example: Response Example

```json
{
  "rules": [
    {
      "id": "14e56445-ebab-4dd0-ba9d-fc28a41b7e7b",
      "position": 0,
      "disabled": false,
      "self": "https://api.pagerduty.com/service-directory/PI2KBWI/rules/14e56445-ebab-4dd0-ba9d-fc28a41b7e7b",
      "conditions": {
        "operator": "and",
        "subconditions": [
          {
            "operator": "contains",
            "parameters": {
              "value": "mysql",
              "path": "class"
            }
          }
        ]
      },
      "time_frame": {
        "active_between": {
          "start_time": 1577880000000,
          "end_time": 1580558400000
        }
      },
      "actions": {
        "severity": {
          "value": "info"
        },
        "extractions": [
          {
            "target": "dedup_key",
            "template": "{{error_level}} error on host {{host}}"
          }
        ]
      },
      "variables": [
        {
          "name": "error_level",
          "type": "regex",
          "parameters": {
            "value": ".*error level is (\\w+)\\.",
            "path": "summary"
          }
        },
        {
          "name": "host",
          "type": "regex",
          "parameters": {
            "value": "(.*)-USW2",
            "path": "source"
          }
        }
      ]
    }
  ],
  "limit": 25,
  "migrated_at": "2023-06-14T13:51:31Z",
  "migrated_by": {
    "id": "P8B9WR8",
    "self": "https://api.pagerduty.com/users/P8B9WR8",
    "type": "user_reference"
  },
  "migrated_status": "completed",
  "migrated_to": {
    "id": "PI2KBWI",
    "self": "https://api.pagerduty.com/event_orchestrations/services/PI2KBWI",
    "type": "event_orchestration_reference"
  },
  "migrated_via": "API",
  "offset": 0,
  "more": false,
  "total": null
}
```

## Response 401

Caller did not supply credentials or did not provide the correct credentials.
If you are using an API key, it may be invalid or your Authorization header may be malformed.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 403

Caller is not authorized to view the requested resource.
While your authentication is valid, the authenticated user or token does not have permission to perform this action.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 404

The requested resource was not found.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Developer Agreement

Your access to and use of the PagerDuty Developer Services is governed by the [PagerDuty Developer Agreement](https://docs.pagerduty.com/developer/pagerduty-developer-agreement).
