> ## 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.

# Incident templates

> Reuse a single set of incident defaults across every alert route.

Incident templates define how an alert becomes an incident: the name, summary, severity, incident type, custom fields, and whether it starts in triage. Instead of configuring these values inside each alert route, you manage templates as standalone objects and point your routes at them, so one change updates every route that uses the template.

<Note>
  An incident template is not the same as an [incident type](/incidents/incident-types) or an [incident
  form](/admin/incident-forms). Incident types categorize incidents; incident forms control which fields responders see
  when declaring. An incident template maps alert data onto the incident that gets created.
</Note>

## Managing templates

Find your templates in **Settings**, alongside **Alert Slack messages** and **Alert Teams messages**. From here you can create, edit, and delete templates, and see which alert routes use each one.

Editing a template applies to every route that references it, so a change to a shared template updates incident creation everywhere it's used.

### The default template

Every organization has exactly one default template. It's used whenever a more specific template isn't set.

You can't delete the default, because you always need at least one template. To retire a template that's currently the default, first set another template as the default, then delete it.

## Using a template in an alert route

When you configure incident creation on an [alert route](/alerts/escalations-from-alerts#creating-incidents), you choose the template the route applies. There are two ways to set it:

* **Pick a template**: apply the same template to every incident the route creates.
* **Set it with an expression**: choose the template per alert, for example by team or severity.

<Note>
  Older Terraform-managed alert routes may still have inline incident templates, which are deprecated. See [Migrating
  off inline templates](#migrating-off-inline-templates).
</Note>

## Managing templates as code

Incident templates are available in the [public API](/api-reference/introduction) and the [Terraform provider](/admin/terraform) as the `incident_incident_template` resource.

## Migrating off inline templates

Previously, incident templates were defined inline within an alert route's configuration. Now that they're standalone objects that routes reference, existing routes move off their inline template. What that takes depends on how you manage the route.

### Routes managed in the dashboard

Alert routes you manage in the dashboard are migrated for you. We create a shared template from each route's inline configuration and repoint the route at it, with no change to the incidents the route declares.

You don't need to do anything. After migration your templates appear alongside your other templates, and your routes reference them.

### Routes managed with Terraform

Alert routes managed by Terraform keep their inline template and carry on working. To avoid forcing a migration, we don't migrate them automatically, so you migrate these in your Terraform configuration when you're ready.

Running `terraform plan` or `terraform apply` against a route that still has an inline template shows a deprecation warning linking here. The warning is a nudge, not a breaking change: inline templates on existing routes stay supported.

<Warning>
  Exporting a Terraform-managed route from the dashboard still emits an inline template, so re-exporting won't perform
  this migration. Follow the steps below to move to a shared template.
</Warning>

Migrating a route is a two-step change.

<Steps>
  <Step title="Create a standalone template">
    Move the route's inline template into an `incident_incident_template` resource. Keep the `template` block the same.
  </Step>

  <Step title="Reference it from the route">
    Replace the route's inline `incident_config.template` with `incident_config.incident_template`, referencing the new
    resource by ID.
  </Step>
</Steps>

#### Before

The template is defined inline on the route:

```hcl theme={null}
resource "incident_alert_route" "payments" {
  name    = "Payments"
  enabled = true

  # ...alert sources, grouping and escalation config...

  incident_config = {
    enabled = true

    template = {
      name = {
        autogenerated = true
      }
      summary = {
        autogenerated = true
      }
      severity = {
        merge_strategy = "max"
      }
      custom_fields = [
        {
          custom_field_id = data.incident_custom_field.affected_team.id
          merge_strategy  = "first-wins"
          binding = {
            value = {
              reference = "expressions[\"team\"]"
            }
          }
        },
      ]
    }
  }
}
```

#### After

The template becomes its own resource, and the route references it:

```hcl theme={null}
resource "incident_incident_template" "payments" {
  name = "Payments"

  template = {
    name = {
      autogenerated = true
    }
    summary = {
      autogenerated = true
    }
    severity = {
      merge_strategy = "max"
    }
    custom_fields = [
      {
        custom_field_id = data.incident_custom_field.affected_team.id
        merge_strategy  = "first-wins"
        binding = {
          value = {
            reference = "expressions[\"team\"]"
          }
        }
      },
    ]
  }
}

resource "incident_alert_route" "payments" {
  name    = "Payments"
  enabled = true

  # ...alert sources, grouping and escalation config...

  incident_config = {
    enabled = true

    incident_template = {
      value = {
        literal = incident_incident_template.payments.id
      }
    }
  }
}
```

Move any [expressions](/alerts/dynamic-escalation) the template's bindings reference onto the `incident_incident_template` resource, so its bindings resolve against the alert.

Run `terraform plan` and check it reports no change to how incidents are declared before applying.

<Note>
  A route that references a shared template can't move back to an inline template. Setting both
  `incident_config.template` and `incident_config.incident_template` on the same route is rejected.
</Note>

For the full resource and attribute reference, see the [Terraform registry](https://registry.terraform.io/providers/incident-io/incident/latest/docs).
