> ## Documentation Index
> Fetch the complete documentation index at: https://docs.incident.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Closing incidents via the API

Incidents in a post-incident status can be closed via [our API](https://docs.incident.io/api-reference/).

This is particularly useful for teams that carry out follow-up actions from incidents in external tools, and want to automatically close the incident in incident.io once those tasks are complete.

### Prerequisites

To use this feature, you must use an API Key with a specific scope. This ensures that incidents aren't accidentally closed without a proper review unless explicitly authorized.

1. Navigate to **Settings > Integrations > API Keys**
2. Create a new API Key
3. Ensure the key has the **Close incidents by opting out of the post-incident flow** permission enabled

### How to use it

You can transition the incident by using the [Edit Incident endpoint](https://docs.incident.io/api-reference/incidents-v2/edit) (`PATCH /v2/incidents/{id}`).

* **From:** The incident must currently be in a valid post-incident status (e.g., `Resolved`, `Fixing`)
* **To:** The target status must be `Closed`

When you successfully close an incident via the API:

* The incident status moves to **Closed**
* The incident is marked as "opted out" of the post-incident flow

### Resolving incidents

You can resolve active incidents using the same [Edit Incident endpoint](https://docs.incident.io/api-reference/incidents-v2/edit) by setting the status to a post-incident or closed status:

* **To a post-incident status** (e.g. `Resolved`): the incident enters the post-incident flow and tasks are created as normal. The status must belong to the post-incident flow that applies to this incident.
* **Directly to closed**: any configured post-incident flow is skipped entirely. This requires the same **Close incidents by opting out of the post-incident flow** permission described above.

<Warning>
  Once an incident is in the post-incident flow, its status is managed automatically based on task completion. Moving between post-incident statuses via the API is not recommended, as the system will recalculate the correct status when tasks are updated.
</Warning>
