# Incidents
(*incidents*)

## Overview

### Available Operations

* [list](#list) - List Incidents V2
* [create](#create) - Create Incidents V2
* [get](#get) - Show Incidents V2
* [update](#update) - Edit Incidents V2

## list

List all incidents for an organisation.

This endpoint supports a number of filters, which can help find incidents matching certain
criteria.

Filters are provided as query parameters, but due to the dynamic nature of what you can
query by (different accounts have different custom fields, statuses, etc) they are more
complex than most.

To help, here are some exemplar curl requests with a human description of what they search
for.

Note that:
- Filters may be used together, and the result will be incidents that match all filters.
- IDs are normally in UUID format, but have been replaced with shorter strings to improve
readability.
- All query parameters must be URI encoded.

### By status

With status of id=ABC, find all incidents that are set to that status:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'status[one_of]=ABC'

Or all incidents that are not set to status with id=ABC:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'status[not_in]=ABC'

### By created_at or updated_at

Find all incidents that follow specified date parameters for created_at and updated_at fields.
Possible values are "gte" (greater than or equal to) and "lte" (less than or equal to). The
following example finds all incidents created before or on 2021-01-02T00:00:00Z:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'created_at[lte]=2021-01-02'

### By status category

Find all incidents that are in a status category. Possible values are "triage",
"declined", "merged", "canceled", "live", "learning" and "closed":

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'status_category[one_of]=live'

Or all incidents that are not in a status category:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'status_category[not_in]=live'


### By severity

With severity of id=ABC, find all incidents that are set to that severity:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'severity[one_of]=ABC'

Or all incidents where severity rank is greater-than-or-equal-to the rank of severity
id=ABC:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'severity[gte]=ABC'

Or all incidents where severity rank is less-than-or-equal-to the rank of severity id=ABC:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'severity[lte]=ABC'

### By incident type

With incident type of id=ABC, find all incidents that are of that type:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'incident_type[one_of]=ABC'

Or all incidents not of that type:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'incident_type[not_in]=ABC'

### By incident mode

By default, we return standard and retrospective incidents. This means that test and
tutorial incidents are filtered out. To override this behaviour, you can use the
mode filter to specify which modes you want to get.

To find incidents of all modes:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'mode[one_of]=standard&mode[one_of]=retrospective&mode[one_of]=test&mode[one_of]=tutorial'

To find just test incidents:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'mode[one_of]=test'


### By incident role

Roles and custom fields have another nested layer in the query parameter, to account for
operations against any of the roles or custom fields created in the account.

With incident role id=ABC, find all incidents where that role is unset:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'incident_role[ABC][is_blank]=true'

Or where the role has been set:

		curl --get 'https://api.incident.io/v2/incidents' \
			--data 'incident_role[ABC][is_blank]=false'

### By option custom fields

With an option custom field id=ABC, all incidents that have field ABC set to the custom
field option of id=XYZ:

		curl \
			--get 'https://api.incident.io/v2/incidents' \
			--data 'custom_field[ABC][one_of]=XYZ'

Or all incidents that do not have custom field id=ABC set to option id=XYZ:

		curl \
			--get 'https://api.incident.io/v2/incidents' \
			--data 'custom_field[ABC][not_in]=XYZ'


### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.incidents.list({
    pageSize: 25,
    after: "01FDAG4SAP5TYPT98WGR2N7W91",
    status: {
      "one_of": [
        "01GBSQF3FHF7FWZQNWGHAVQ804",
      ],
    },
    statusCategory: {
      "one_of": [
        "active",
      ],
    },
    createdAt: {
      "created_at[gte]": [
        "2024-05-01",
      ],
    },
    updatedAt: {
      "updated_at[gte]": [
        "2024-05-01",
      ],
    },
    severity: {
      "one_of": [
        "01GBSQF3FHF7FWZQNWGHAVQ804",
      ],
    },
    incidentType: {
      "one_of": [
        "01GBSQF3FHF7FWZQNWGHAVQ804",
      ],
    },
    incidentRole: {
      "01GBSQF3FHF7FWZQNWGHAVQ804": {
        "one_of": [
          "01GBSQF3FHF7FWZQNWGHAVQ804",
          "01ET65M7ZARSFZ6TFDFVQDN9AA",
        ],
      },
    },
    customField: {
      "01GBSQF3FHF7FWZQNWGHAVQ804": {
        "one_of": [
          "01GBSQF3FHF7FWZQNWGHAVQ804",
          "01ET65M7ZARSFZ6TFDFVQDN9AA",
        ],
      },
    },
    mode: {
      "one_of": [
        "retrospective",
      ],
    },
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { incidentsList } from "incidentio/funcs/incidentsList.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await incidentsList(incidentio, {
    pageSize: 25,
    after: "01FDAG4SAP5TYPT98WGR2N7W91",
    status: {
      "one_of": [
        "01GBSQF3FHF7FWZQNWGHAVQ804",
      ],
    },
    statusCategory: {
      "one_of": [
        "active",
      ],
    },
    createdAt: {
      "created_at[gte]": [
        "2024-05-01",
      ],
    },
    updatedAt: {
      "updated_at[gte]": [
        "2024-05-01",
      ],
    },
    severity: {
      "one_of": [
        "01GBSQF3FHF7FWZQNWGHAVQ804",
      ],
    },
    incidentType: {
      "one_of": [
        "01GBSQF3FHF7FWZQNWGHAVQ804",
      ],
    },
    incidentRole: {
      "01GBSQF3FHF7FWZQNWGHAVQ804": {
        "one_of": [
          "01GBSQF3FHF7FWZQNWGHAVQ804",
          "01ET65M7ZARSFZ6TFDFVQDN9AA",
        ],
      },
    },
    customField: {
      "01GBSQF3FHF7FWZQNWGHAVQ804": {
        "one_of": [
          "01GBSQF3FHF7FWZQNWGHAVQ804",
          "01ET65M7ZARSFZ6TFDFVQDN9AA",
        ],
      },
    },
    mode: {
      "one_of": [
        "retrospective",
      ],
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.IncidentsV2NumberListRequest](../../models/operations/incidentsv2numberlistrequest.md)                                                                             | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ListResponseBody15](../../models/components/listresponsebody15.md)\>**

### Errors

| Error Object    | Status Code     | Content Type    |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx         | */*             |


## create

Create a new incident.

Note that if the incident mode is set to "retrospective" then the new incident
will not be announced in Slack.


### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.incidents.create({
    customFieldEntries: [
      {
        customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0",
        values: [
          {
            id: "01FCNDV6P870EA6S7TK1DSYDG0",
            valueCatalogEntryId: "01FCNDV6P870EA6S7TK1DSYDG0",
            valueLink: "https://google.com/",
            valueNumeric: "123.456",
            valueOptionId: "01FCNDV6P870EA6S7TK1DSYDG0",
            valueText: "This is my text field, I hope you like it",
            valueTimestamp: "",
          },
        ],
      },
    ],
    id: "01FDAG4SAP5TYPT98WGR2N7W91",
    idempotencyKey: "alert-uuid",
    incidentRoleAssignments: [
      {
        assignee: {
          email: "bob@example.com",
          id: "01G0J1EXE7AXZ2C93K61WBPYEH",
          slackUserId: "USER123",
        },
        incidentRoleId: "01FH5TZRWMNAFB0DZ23FD1TV96",
      },
    ],
    incidentStatusId: "01G0J1EXE7AXZ2C93K61WBPYEH",
    incidentTimestampValues: [
      {
        incidentTimestampId: "01FCNDV6P870EA6S7TK1DSYD5H",
        value: new Date("2021-08-17T13:28:57.801578Z"),
      },
    ],
    incidentTypeId: "01FH5TZRWMNAFB0DZ23FD1TV96",
    mode: "standard",
    name: "Our database is sad",
    retrospectiveIncidentOptions: {
      postmortemDocumentUrl: "https://docs.google.com/my_doc_id",
      slackChannelId: "abc123",
    },
    severityId: "01FH5TZRWMNAFB0DZ23FD1TV96",
    slackChannelNameOverride: "inc-123-database-down",
    slackTeamId: "T02A1FSLE8J",
    summary: "Our database is really really sad, and we don't know why yet.",
    visibility: "public",
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { incidentsCreate } from "incidentio/funcs/incidentsCreate.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await incidentsCreate(incidentio, {
    customFieldEntries: [
      {
        customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0",
        values: [
          {
            id: "01FCNDV6P870EA6S7TK1DSYDG0",
            valueCatalogEntryId: "01FCNDV6P870EA6S7TK1DSYDG0",
            valueLink: "https://google.com/",
            valueNumeric: "123.456",
            valueOptionId: "01FCNDV6P870EA6S7TK1DSYDG0",
            valueText: "This is my text field, I hope you like it",
            valueTimestamp: "",
          },
        ],
      },
    ],
    id: "01FDAG4SAP5TYPT98WGR2N7W91",
    idempotencyKey: "alert-uuid",
    incidentRoleAssignments: [
      {
        assignee: {
          email: "bob@example.com",
          id: "01G0J1EXE7AXZ2C93K61WBPYEH",
          slackUserId: "USER123",
        },
        incidentRoleId: "01FH5TZRWMNAFB0DZ23FD1TV96",
      },
    ],
    incidentStatusId: "01G0J1EXE7AXZ2C93K61WBPYEH",
    incidentTimestampValues: [
      {
        incidentTimestampId: "01FCNDV6P870EA6S7TK1DSYD5H",
        value: new Date("2021-08-17T13:28:57.801578Z"),
      },
    ],
    incidentTypeId: "01FH5TZRWMNAFB0DZ23FD1TV96",
    mode: "standard",
    name: "Our database is sad",
    retrospectiveIncidentOptions: {
      postmortemDocumentUrl: "https://docs.google.com/my_doc_id",
      slackChannelId: "abc123",
    },
    severityId: "01FH5TZRWMNAFB0DZ23FD1TV96",
    slackChannelNameOverride: "inc-123-database-down",
    slackTeamId: "T02A1FSLE8J",
    summary: "Our database is really really sad, and we don't know why yet.",
    visibility: "public",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [components.CreateRequestBody11](../../models/components/createrequestbody11.md)                                                                                               | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ShowResponseBody13](../../models/components/showresponsebody13.md)\>**

### Errors

| Error Object    | Status Code     | Content Type    |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx         | */*             |


## get

Get a single incident.

The ID supplied can be either the incident's full ID, or the numeric part of its
reference. For example, to get INC-123, you could use either its full ID or:

		curl \
			--get 'https://api.incident.io/v2/incidents/123


### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.incidents.get({
    id: "01FDAG4SAP5TYPT98WGR2N7W91",
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { incidentsGet } from "incidentio/funcs/incidentsGet.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await incidentsGet(incidentio, {
    id: "01FDAG4SAP5TYPT98WGR2N7W91",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.IncidentsV2NumberShowRequest](../../models/operations/incidentsv2numbershowrequest.md)                                                                             | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ShowResponseBody13](../../models/components/showresponsebody13.md)\>**

### Errors

| Error Object    | Status Code     | Content Type    |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx         | */*             |


## update

Edit an existing incident.

This endpoint allows you to edit the properties of an existing incident: e.g. set the severity or update custom fields.

When using this endpoint, only fields that are provided will be edited (omitted fields
will be ignored).


### Example Usage

```typescript
import { Incidentio } from "incidentio";

const incidentio = new Incidentio();

async function run() {
  const result = await incidentio.incidents.update({
    id: "01G18REBY9AYH6CMWCJ2CVCYCH",
    editRequestBody: {
      incident: {
        callUrl: "https://zoom.us/foo",
        customFieldEntries: [
          {
            customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0",
            values: [
              {
                id: "01FCNDV6P870EA6S7TK1DSYDG0",
                valueCatalogEntryId: "01FCNDV6P870EA6S7TK1DSYDG0",
                valueLink: "https://google.com/",
                valueNumeric: "123.456",
                valueOptionId: "01FCNDV6P870EA6S7TK1DSYDG0",
                valueText: "This is my text field, I hope you like it",
                valueTimestamp: "",
              },
            ],
          },
        ],
        incidentRoleAssignments: [
          {
            assignee: {
              email: "bob@example.com",
              id: "01G0J1EXE7AXZ2C93K61WBPYEH",
              slackUserId: "USER123",
            },
            incidentRoleId: "01FH5TZRWMNAFB0DZ23FD1TV96",
          },
        ],
        incidentStatusId: "01FH5TZRWMNAFB0DZ23FD1TV96",
        incidentTimestampValues: [
          {
            incidentTimestampId: "01FCNDV6P870EA6S7TK1DSYD5H",
            value: new Date("2021-08-17T13:28:57.801578Z"),
          },
        ],
        name: "Our database is sad",
        severityId: "01FH5TZRWMNAFB0DZ23FD1TV96",
        slackChannelNameOverride: "inc-123-database-down",
        summary: "Our database is really really sad, and we don't know why yet.",
      },
      notifyIncidentChannel: true,
    },
  });
  
  // Handle the result
  console.log(result)
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { IncidentioCore } from "incidentio/core.js";
import { incidentsUpdate } from "incidentio/funcs/incidentsUpdate.js";

// Use `IncidentioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const incidentio = new IncidentioCore();

async function run() {
  const res = await incidentsUpdate(incidentio, {
    id: "01G18REBY9AYH6CMWCJ2CVCYCH",
    editRequestBody: {
      incident: {
        callUrl: "https://zoom.us/foo",
        customFieldEntries: [
          {
            customFieldId: "01FCNDV6P870EA6S7TK1DSYDG0",
            values: [
              {
                id: "01FCNDV6P870EA6S7TK1DSYDG0",
                valueCatalogEntryId: "01FCNDV6P870EA6S7TK1DSYDG0",
                valueLink: "https://google.com/",
                valueNumeric: "123.456",
                valueOptionId: "01FCNDV6P870EA6S7TK1DSYDG0",
                valueText: "This is my text field, I hope you like it",
                valueTimestamp: "",
              },
            ],
          },
        ],
        incidentRoleAssignments: [
          {
            assignee: {
              email: "bob@example.com",
              id: "01G0J1EXE7AXZ2C93K61WBPYEH",
              slackUserId: "USER123",
            },
            incidentRoleId: "01FH5TZRWMNAFB0DZ23FD1TV96",
          },
        ],
        incidentStatusId: "01FH5TZRWMNAFB0DZ23FD1TV96",
        incidentTimestampValues: [
          {
            incidentTimestampId: "01FCNDV6P870EA6S7TK1DSYD5H",
            value: new Date("2021-08-17T13:28:57.801578Z"),
          },
        ],
        name: "Our database is sad",
        severityId: "01FH5TZRWMNAFB0DZ23FD1TV96",
        slackChannelNameOverride: "inc-123-database-down",
        summary: "Our database is really really sad, and we don't know why yet.",
      },
      notifyIncidentChannel: true,
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [operations.IncidentsV2NumberEditRequest](../../models/operations/incidentsv2numbereditrequest.md)                                                                             | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[components.ShowResponseBody13](../../models/components/showresponsebody13.md)\>**

### Errors

| Error Object    | Status Code     | Content Type    |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx         | */*             |
