Skip to content

Instantly share code, notes, and snippets.

@steverice
Created October 10, 2016 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steverice/956f25b0d2c3f064c278529fc475da18 to your computer and use it in GitHub Desktop.
Save steverice/956f25b0d2c3f064c278529fc475da18 to your computer and use it in GitHub Desktop.
Incidents list documentation from v1 devdocs
---
title: PagerDuty Developer
layout: main
---
<ul class="breadcrumb">
<li>
<a href="/documentation/rest/">REST API</a>
</li>
<li style="list-style: none">
<span class="divider">/</span>
</li>
<li>
<a href="/documentation/rest/incidents/">Incidents</a>
</li>
<li style="list-style: none">
<span class="divider">/</span>
</li>
<li>List
</li>
</ul>
<div class='section'>
<h1 class="title">
GET incidents
</h1>
<p>
The PagerDuty incidents query API can be used to query current and historical PagerDuty incidents over a date range, letting you build custom dashboards or incident reports. The API allows for searching for incidents with multiple filters or query parameters, various sorts, and also supports the pagination of results.
</p>
<h3>
Resource URL
</h3>
<div class="prism action-url language-bash">
<pre>
GET https://<span class="base_url contenteditable persist" contenteditable="true">&lt;subdomain&gt;</span>.pagerduty.com/api/v1/incidents
</pre>
</div>
<h3>
Parameters
</h3>
<div class="alert alert-warning">
This action is paginated. See the <a href="/documentation/rest/pagination">pagination documentation</a> for details.
</div>
<div class="table-container">
<table class="table table-striped">
<thead>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Required
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
since
</td>
<td>
<a href="/documentation/rest/types#datetime">Date</a>
</td>
<td>
No
</td>
<td>
The start of the date range over which you want to search.
</td>
</tr>
<tr>
<td>
until
</td>
<td>
<a href="/documentation/rest/types#datetime">Date</a>
</td>
<td>
No
</td>
<td>
<p>
The end of the date range over which you want to search.
</p>
<p>
<strong>NOTE:</strong> If you leave off either <code>since</code> or <code>until</code>, a 30 day default range is applied to your open ended range. Not including the <code>since</code> parameter will set the date range to <code>until</code> - 30 days. Likewise, if you leave off <code>until</code>, it is set to <code>since</code> + 30 days. Defaults to the last 30 days if you leave off both. The size of the date range must be less than 180 days.
</p>
</td>
</tr>
<tr>
<td>
date_range
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
When set to <code>all</code>, the <code>since</code> and <code>until</code> parameters and defaults are ignored. Use this to get all incidents since the account was created.
</td>
</tr>
<tr>
<td>
fields
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
Used to restrict the properties of each incident returned to a set of pre-defined fields. If omitted, returned incidents have the majority of fields present. See below for a list of possible fields.
</td>
</tr>
<tr>
<td>
status
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
<p>
Returns only the incidents currently in the passed status(es). Valid status options are <code>triggered</code>, <code>acknowledged</code>, and <code>resolved</code>. More status codes may be introduced in the future.
</p>
<p>
Separate multiple statuses with a comma.
</p>
</td>
</tr>
<tr>
<td>
incident_key
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
Returns only the incidents with the passed de-duplication key. See the <a href="/documentation/integration/events">PagerDuty Events API</a> docs for further details.
</td>
</tr>
<tr>
<td>
service
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
<p>
Returns only the incidents associated with the passed service(s). This expects one or more service IDs.
</p>
<p>
Separate multiple ids with a comma.
</p>
</td>
</tr>
<tr>
<td>
teams
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
A comma-separated list of team IDs, specifying teams whose maintenance windows will be returned.
</td>
</tr>
<tr>
<td>
assigned_to_user
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
<p>
Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs. Please see below for more info on how to find your users' IDs.
</p>
<p>
Note: When using the <code>assigned_to_user</code> filter, you will only receive incidents with statuses of <code>triggered</code> or <code>acknowledged</code>. This is because <code>resolved</code> incidents are not assigned to any user.
</p>
<p>
Separate multiple ids with a comma.
</p>
</td>
</tr>
<tr>
<td>
urgency
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
Comma-separated list of the urgencies of the incidents to be returned. Defaults to <code>high,low</code>.
</td>
</tr>
<tr>
<td>
time_zone
</td>
<td>
<a href="/documentation/rest/types#timezone">Time Zone</a>
</td>
<td>
No
</td>
<td>
Time zone in which dates in the result will be rendered. Defaults to <code>UTC</code>.
</td>
</tr>
<tr>
<td>
sort_by
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
No
</td>
<td>
Used to specify both the field you wish to sort the results on, as well as the direction (ascending/descending) of the results.
<ul>
<li>
<code>incident_number</code> The number of the incident.
</li>
<li>
<code>created_on</code> The date/time the incident was triggered.
</li>
<li>
<code>resolved_on</code> The date/time the incident was resolved.
</li>
<li>
<code>urgency</code> The urgency of the incident. (Low-urgency incidents are ordered before high-urgency incidents.)
</li>
</ul>
<p>
Valid values for the <code>sort_by</code> direction are:
</p>
<ul>
<li>
<code>asc</code> This sorts ascending (default if omitted).
</li>
<li>
<code>desc</code> This sorts descending.
</li>
</ul>
<p>
The <code>sort_by</code> field and direction should be separated by a colon. Multiple fields can be included, separated by a comma.
</p>
<p>
Example: to sort by the most-recently-created incidents, include the query parameter:
</p>
<pre>
<code class="language-javascript prettyprint linenums">?sort_by=created_on:desc</code>
</pre>
<p>
Example: to sort incidents by urgency (showing low-urgency incidents first) and secondarily sort by <code>incident_number</code>, include the query parameter:
</p>
<pre>
<code class="language-javascript prettyprint linenums">?sort_by=urgency:asc,incident_number:desc</code>
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<h3>
Response Fields
</h3>
<div class="table-container">
<table class="table table-striped">
<thead>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
incident_number
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
The number of the incident. This is unique across your account.
</td>
</tr>
<tr>
<td>
status
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
The current status of the incident. Valid statuses are:
<ul>
<li>
<code>triggered</code> The incident is in alarm and is assigned to a user, and is not currently acknowledged.
</li>
<li>
<code>acknowledged</code> The incident is in alarm and is assigned to a user, but has been already acknowledged (via phone, SMS, or PagerDuty website).
</li>
<li>
<code>resolved</code> The incident is no longer in alarm and has been resolved (manually or automatically).
</li>
</ul>
<p>
<strong>NOTE:</strong> We anticipate the need for introducing new status codes in the future. Please build your client code to handle unknown status codes gracefully.
</p>
</td>
</tr>
<tr>
<td>
urgency
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
The current urgency of the incident. Valid urgencies are:
<ul>
<li>
<code>high</code> High-urgency incidents escalate according to escalation policies and alert users via their high-urgency notification rules.
</li>
<li>
<code>low</code> Low-urgency incidents do not escalate, and alert users via their low-urgency notification rules.
</li>
</ul>
<p>
<strong>NOTE:</strong> Some pricing plans may not have access to the <code>urgency</code> parameter and related features. If the <code>urgency</code> field is omitted from an API response, the incident behaves as a <code>high</code>-urgency incident.
</p>
</td>
</tr>
<tr>
<td>
pending_actions
</td>
<td>
<a href="/documentation/rest/types#array">Array</a>
</td>
<td>
<p>
The list of <code>pending_actions</code> on the incident. The <code>pending_actions</code> array contains all of the <code>pending_action</code> objects for the incident at the current time. This list is empty if the status of the incident is <code>resolved</code>.
</p>
<p>
A pending_action object contains a <code>type</code> of action. <code>type</code> can be <code>escalate</code>, <code>unacknowledge</code>, <code>resolve</code> or <code>urgency_change</code>. A pending_action object contains <code>at</code>, the time at which the action will take place.
</p>
<p>
Example: <code>pending_actions</code> field for an incident.
</p>
<pre>
<code class="language-javascript prettyprint linenums">{
"pending_actions": [
{
"type": "escalate",
"at": "2014-01-01T08:00:00Z"
},
{
"type": "unacknowledge",
"at": "2014-01-01T10:00:00Z"
},
{
"type": "resolve",
"at": "2014-01-01T11:00:00Z"
},
{
"type": "urgency_change",
"at": "2014-01-01T10:30:00Z",
"to": "high"
}
]
}</code>
</pre>
</td>
</tr>
<tr>
<td>
created_on
</td>
<td>
<a href="/documentation/rest/types#datetime">Date</a>
</td>
<td>
The date/time the incident was triggered.
</td>
</tr>
<tr>
<td>
html_url
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
The PagerDuty website URL where the incident can be viewed and further actions taken. This is <strong>not</strong> the resource URL.
</td>
</tr>
<tr>
<td>
incident_key
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
The incident's de-duplication key. See the <a href="/documentation/integration/events">PagerDuty Events API</a> docs for further details.
</td>
</tr>
<tr>
<td>
service
</td>
<td>
<a href="/documentation/rest/types#object">Object</a>
</td>
<td>
The PagerDuty <a href="/documentation/rest/services/">service</a> that the incident belongs to. The service will contain fields of its own.
</td>
</tr>
<tr>
<td>
escalation_policy
</td>
<td>
<a href="/documentation/rest/types#object">Object</a>
</td>
<td>
The <a href="/documentation/rest/escalation_policies/">escalation policy</a> that the incident belongs to. The policy will contain fields of its own.
</td>
</tr>
<tr>
<td>
teams
</td>
<td>
<a href="/documentation/rest/types#array">Array</a>
</td>
<td>
<p>
The <a href="/documentation/rest/teams/">teams</a> involved in the incident’s lifecycle. The teams will contain fields of their own.
</p>
<p>
<strong>NOTE:</strong> You must explicitly include <code>teams</code> in the <code>fields</code> parameter in order to include it in the response.
</p>
</td>
</tr>
<tr>
<td>
assigned_to
</td>
<td>
<a href="/documentation/rest/types#array">Array</a>
</td>
<td>
<p>
The list of <i>assignments</i> of the incident. An <i>assignment</i> is an object containing the assigned user as well as the date/time the incident was assigned to that user. The user will contain fields of its own. This list is empty if the status of the incident is <code>resolved</code>.
</p>
<p>
<strong>NOTE:</strong> The assigned user of an <i>assignment</i> is accessible through the <code>object</code> field, which will have the fields of the user plus a <code>type</code> field. Currently, the <code>type</code> field will always be <code>user</code>. We may add new <code>type</code>s in the future. Please build your client code to handle unknown types gracefully.
</p>
<p>
Example: <code>assigned_to</code> field for an incident assigned to two users.
</p>
<pre>
<code class="language-javascript prettyprint linenums">{
"assigned_to": [
{
"at": "2014-01-01T08:00:00Z",
"object": {
"id": "PMI6007",
"name": "James",
"email": "james@acme.com",
"html_url": "https://acme.pagerduty.com/users/PMI6007",
"type": "user"
}
},
{
"at": "2014-01-01T08:00:00Z",
"object": {
"id": "BH90210",
"name": "Dylan",
"email": "dylan@acme.com",
"html_url": "https://acme.pagerduty.com/users/BH90210",
"type": "user"
}
}
]
}</code>
</pre>
</td>
</tr>
<tr>
<td>
assigned_to_user
</td>
<td>
<a href="/documentation/rest/types#object">Object</a>
</td>
<td>
<div>
<strong>This field is deprecated. See <i>assigned_to</i> instead.</strong>
</div>A user that the incident is currently assigned to, if the incident is not currently in the resolved state and is assigned to a user. The user will have fields of its own. If an incident is assigned to multiple users, this field will contain only the first assigned user.
</td>
</tr>
<tr>
<td>
acknowledgers
</td>
<td>
<a href="/documentation/rest/types#array">Array</a>
</td>
<td>
<p>
The list of <i>acknowledgements</i> of the incident. An <i>acknowledgement</i> is an object containing the acknowleding object (either a user or the Events API) as well as the date/time the incident was acknowledged. This field is only present if the status of the incident is <code>acknowledged</code>. This field is sorted in ascending order by acknowledgement time.
</p>
<p>
Example: <code>acknowledgers</code> field for an incident first acknowledged by a user, then by the Events API.
</p>
<pre>
<code class="language-javascript prettyprint linenums">{
"acknowledgers": [
{
"at": "2014-01-01T09:00:00Z",
"object": {
"id": "PEO3O45",
"name": "John",
"email": "john@acme.com",
"html_url": "https://acme.pagerduty.com/users/PEO3O45",
"type": "user"
}
},
{
"at": "2014-01-01T10:05:00Z",
"object": {
"type": "api"
}
}
]
}</code>
</pre>
</td>
</tr>
<tr>
<td>
last_status_change_by
</td>
<td>
<a href="/documentation/rest/types#object">Object</a>
</td>
<td>
The user who is responsible for the incident's last status change. If the incident is in the acknowledged or resolved status, this will be the user that took the first acknowledged or resolved action. If the incident was automatically resolved (say through the Events API), or if the incident is in the triggered state, this will be null. User fields are the same as in the assigned_to_user field above.
</td>
</tr>
<tr>
<td>
last_status_change_on
</td>
<td>
<a href="/documentation/rest/types#datetime">Date</a>
</td>
<td>
The date/time the incident's status last changed.
</td>
</tr>
<tr>
<td>
trigger_summary_data
</td>
<td>
<a href="/documentation/rest/types#object">Object</a>
</td>
<td>
<p>
Some condensed information regarding the initial event that triggered this incident. This data will be a set of key/value pairs that vary depending on what sort of event triggered the incident (email, Event API request, etc). For instance, if an email triggered the incident, then the <code>trigger_summary_data</code> will likely contain a <code>subject</code>. There are no guarantees on the full presence of this data for every incident.
</p>
</td>
</tr>
<tr>
<td>
trigger_details_html_url
</td>
<td>
<a href="/documentation/rest/types#string">String</a>
</td>
<td>
The PagerDuty website URL where the full details regarding the initial event that triggered this incident can be found. (This is <strong>not</strong> the resource URL.)
</td>
</tr>
</tbody>
</table>
</div>
<h2>
Examples
</h2>
<h4>
Get all triggered and acknowledged incidents
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "status=<span class='curl_params-status contenteditable' contenteditable='true'>triggered,acknowledged</span>" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<p class="content-type-warning clearfix">
Note: <code>Content-type</code> of the request <strong>must</strong> be <code>application/json</code>
</p>
<div class="clearfix"></div>
<h4>
Response <span class="response-status">Status: 200 OK <a href="/documentation/rest/errors#http_codes"></a></span>
</h4>
<div class="response">
<pre>
<code class="language-javascript prettyprint linenums">{
"incidents": [
{
"incident_number": 1,
"created_on": "2012-09-11T22:49:21Z",
"status": "triggered",
"html_url": "https://acme.pagerduty.com/incidents/P2A6J96",
"incident_key": null,
"pending_actions": [
{
"type": "escalate",
"at": "2012-09-11T22:59:21Z"
}
],
"service": {
"id": "PBF77WY",
"name": "Generic Api",
"description": "Description for Generic Api Service.",
"html_url": "https://acme.pagerduty.com/services/PBF77WY"
},
"assigned_to_user": {
"id": "PEO3O45",
"name": "John",
"email": "john@acme.com",
"html_url": "https://acme.pagerduty.com/users/PEO3O45"
},
"assigned_to": [
{
"at": "2012-09-11T22:49:21Z",
"object": {
"id": "PEO3O45",
"name": "John",
"email": "john@acme.com",
"html_url": "https://acme.pagerduty.com/users/PEO3O45",
"type": "user"
}
}
],
"trigger_summary_data": {
"subject": "Opened on the web ui"
},
"trigger_details_html_url": "https://acme.pagerduty.com/incidents/P2A6J96/log_entries/P2NQP6P",
"last_status_change_on": "2012-09-11T22:49:21Z",
"last_status_change_by": null,
"urgency": "high"
},
{
"incident_number": 3,
"created_on": "2012-09-11T22:54:08Z",
"status": "acknowledged",
"html_url": "https://acme.pagerduty.com/incidents/PBXG6JS",
"incident_key": "=?UTF-8?B?SnVzdCBhbiBlbWFpbCBmcm9tIOWvjOWjq+WxsSBhbmQg8J2EnvCdlaXwnZ+2IPCggoo=?=",
"pending_actions": [
{
"type": "unacknowledge",
"at": "2012-09-12T00:25:49Z"
}
],
"service": {
"id": "PFRV88L",
"name": "Generic Email",
"description": "Description for Generic Email Service.",
"html_url": "https://acme.pagerduty.com/services/PFRV88L"
},
"assigned_to_user": {
"id": "PEO3O45",
"name": "John",
"email": "john@acme.com",
"html_url": "https://acme.pagerduty.com/users/PEO3O45"
},
"assigned_to": [
{
"at": "2012-09-11T22:54:08Z",
"object": {
"id": "PEO3O45",
"name": "John",
"email": "john@acme.com",
"html_url": "https://acme.pagerduty.com/users/PEO3O45",
"type": "user"
}
},
{
"at": "2012-09-11T22:54:08Z",
"object": {
"id": "PMI6007",
"name": "James",
"email": "james@acme.com",
"html_url": "https://acme.pagerduty.com/users/PMI6007",
"type": "user"
}
}
],
"acknowledgers": [
{
"at": "2012-09-11T22:55:01Z",
"object": {
"id": "PMI6007",
"name": "James",
"email": "james@acme.com",
"html_url": "https://acme.pagerduty.com/users/PMI6007",
"type": "user"
}
},
{
"at": "2012-09-11T22:55:32Z",
"object": {
"type": "api"
}
},
{
"at": "2012-09-11T23:25:49Z",
"object": {
"id": "PMI6007",
"name": "James",
"email": "james@acme.com",
"html_url": "https://acme.pagerduty.com/users/PMI6007",
"type": "user"
}
}
],
"trigger_summary_data": {
"subject": "Just an email from 富士山 and 𝄞𝕥𝟶 𠂊"
},
"trigger_details_html_url": "https://acme.pagerduty.com/incidents/PBXG6JS/log_entries/P30IVAT",
"last_status_change_on": "2012-09-11T22:55:01Z",
"last_status_change_by": {
"id": "PMI6007",
"name": "James",
"email": "james@acme.com",
"html_url": "https://acme.pagerduty.com/users/PMI6007"
},
"urgency": "high"
}
],
"limit": 100,
"offset": 0,
"total": 2
}</code>
</pre>
</div>
<h4>
Get only the incident_number and the status of all incidents.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "fields=<span class='curl_params-fields contenteditable' contenteditable='true'>incident_number,status</span>" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
Response <span class="response-status">Status: 200 OK <a href="/documentation/rest/errors#http_codes"></a></span>
</h4>
<div class="response">
<pre>
<code class="language-javascript prettyprint linenums">{
"incidents": [
{
"incident_number": 1,
"status": "resolved"
},
{
"incident_number": 2,
"status": "triggered"
},
{
"incident_number": 3,
"status": "resolved"
},
{
"incident_number": 4,
"status": "triggered"
},
{
"incident_number": 5,
"status": "triggered"
}
],
"limit": 100,
"offset": 0,
"total": 5
}</code>
</pre>
</div>
<p>
Below are some examples of Incident Query API requests.
</p>
<p>
In all examples, the (fake) PagerDuty account subdomain used is <code>acme</code> and the current date is 2011-05-01.
</p>
<h4>
Fetch the 100 most recent incidents triggered across the entire <code>acme</code> account within the last 3 months.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "since=<span class='curl_params-since contenteditable' contenteditable='true'>2011-02-01</span>" \
--data-urlencode "until=<span class='curl_params-until contenteditable' contenteditable='true'>2011-05-01</span>" \
--data-urlencode "sort_by=<span class='curl_params-sort_by contenteditable' contenteditable='true'>created_on:desc</span>" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
Fetch the 50 most recent incidents triggered within the last 3 months on team ID <code>P4QLGMN</code> or <code>P6XL8LK</code>.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "since=<span class='curl_params-since contenteditable' contenteditable='true'>2011-02-01</span>" \
--data-urlencode "until=<span class='curl_params-until contenteditable' contenteditable='true'>2011-05-01</span>" \
--data-urlencode "teams=<span class='curl_params-until contenteditable' contenteditable='true'>P4QLGMN,P6XL8LK</span>" \
--data-urlencode "sort_by=<span class='curl_params-sort_by contenteditable' contenteditable='true'>created_on:desc</span>" \
--data-urlencode "limit=50" \
--data-urlencode "offset=0" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
Fetch the 50 most recent low-urgency incidents.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "sort_by=<span class='curl_params-sort_by contenteditable' contenteditable='true'>created_on:desc</span>" \
--data-urlencode "urgency=low" \
--data-urlencode "limit=50" \
--data-urlencode "offset=0" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
Fetch the second page of 50 most recent incidents triggered within the last 3 months and include their <code>teams</code> in the response.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "since=<span class='curl_params-since contenteditable' contenteditable='true'>2011-02-01</span>" \
--data-urlencode "until=<span class='curl_params-until contenteditable' contenteditable='true'>2011-05-01</span>" \
--data-urlencode "sort_by=<span class='curl_params-sort_by contenteditable' contenteditable='true'>created_on:desc</span>" \
--data-urlencode "fields=<span class='curl_params-sort_by contenteditable' contenteditable='true'>teams</span>" \
--data-urlencode "limit=50" \
--data-urlencode "offset=50" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
Fetch the first page of incidents for service ID <code>PWP4EBH</code> within the last month.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "since=<span class='curl_params-since contenteditable' contenteditable='true'>2011-04-01</span>" \
--data-urlencode "until=<span class='curl_params-until contenteditable' contenteditable='true'>2011-05-01</span>" \
--data-urlencode "service=<span class='curl_params-service contenteditable' contenteditable='true'>PWP4EBH</span>" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
Fetch the first page of resolved incidents that were triggered within the last month.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "since=<span class='curl_params-since contenteditable' contenteditable='true'>2011-04-01</span>" \
--data-urlencode "until=<span class='curl_params-until contenteditable' contenteditable='true'>2011-05-01</span>" \
--data-urlencode "status=<span class='curl_params-status contenteditable' contenteditable='true'>resolved</span>" \
--data-urlencode "sort_by=<span class='curl_params-sort_by contenteditable' contenteditable='true'>resolved_on:asc</span>" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
Fetch the first page of incidents that are not yet resolved but are greater than 1 week old.
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "since=<span class='curl_params-since contenteditable' contenteditable='true'>2011-01-01</span>" \
--data-urlencode "until=<span class='curl_params-until contenteditable' contenteditable='true'>2011-04-24</span>" \
--data-urlencode "status=<span class='curl_params-status contenteditable' contenteditable='true'>triggered,acknowledged</span>" \
--data-urlencode "sort_by=<span class='curl_params-sort_by contenteditable' contenteditable='true'>created_on:asc</span>" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
<h4>
For the 20 most recent still-unresolved incidents this last month, fetch just the list of users whom they're assigned to and the corresponding incident HTML URLs (so, for instance, you can email them and remind them about their open incidents and link to them).
</h4>
<pre>
<code class="prettyprint language-bash curl">curl -H "Content-type: application/json" -H "Authorization: Token token=<span class="base_auth_token contenteditable persist" contenteditable="true">E7px6VVr3PVHZPJq51oa</span>" -X GET -G \
--data-urlencode "since=<span class='curl_params-since contenteditable' contenteditable='true'>2011-04-01</span>" \
--data-urlencode "until=<span class='curl_params-until contenteditable' contenteditable='true'>2011-05-01</span>" \
--data-urlencode "status=<span class='curl_params-status contenteditable' contenteditable='true'>triggered,acknowledged</span>" \
--data-urlencode "sort_by=<span class='curl_params-sort_by contenteditable' contenteditable='true'>created_on:desc</span>" \
--data-urlencode "limit=20" \
"https://<span class="base_url contenteditable persist" contenteditable="true">acme</span>.pagerduty.com/api/v1/incidents"</code>
</pre>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment