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

# Terraform

> Manage Rootly resources using infrastructure as code with the official Terraform provider for services, severities, workflows, and more.

## Overview

The Rootly Terraform provider lets you manage your entire Rootly configuration as code — severities, services, workflows, on-call schedules, escalation policies, form fields, alert routes, and more. With over 200 resources and 59 data sources, virtually every Rootly configuration object can be declared, versioned, and reviewed through your existing IaC pipeline.

* **Provider**: [rootlyhq/rootly](https://registry.terraform.io/providers/rootlyhq/rootly/latest) on the Terraform Registry
* **Current version**: 5.10.0
* **Minimum Terraform version**: 1.0
* **Downloads**: 1.1M+

## Authentication

The provider authenticates using a Rootly API token. Generate one from **Account > API Tokens** in your Rootly dashboard.

You can supply credentials via the provider block or environment variables. The environment variable approach is recommended to avoid committing secrets.

**Environment variables (recommended):**

```bash theme={null}
export ROOTLY_API_TOKEN="your-api-token"
export ROOTLY_API_URL="https://api.rootly.com"  # optional, defaults to https://api.rootly.com
```

**Provider block:**

```hcl theme={null}
provider "rootly" {
  api_token = var.rootly_api_token  # or set ROOTLY_API_TOKEN env var
  api_host  = "https://api.rootly.com"  # optional
}
```

| Parameter   | Env var            | Required                 | Default                  |
| ----------- | ------------------ | ------------------------ | ------------------------ |
| `api_token` | `ROOTLY_API_TOKEN` | Yes (if env var not set) | —                        |
| `api_host`  | `ROOTLY_API_URL`   | No                       | `https://api.rootly.com` |

## Installation

Declare the provider in your Terraform configuration and run `terraform init`:

```hcl theme={null}
terraform {
  required_providers {
    rootly = {
      source  = "rootlyhq/rootly"
      version = "~> 5.10"
    }
  }
}

provider "rootly" {
  # Uses ROOTLY_API_TOKEN env var by default
}
```

## Supported Resources

The provider covers 200+ resources across all major Rootly configuration areas.

<AccordionGroup>
  <Accordion title="Incidents & On-Call" icon="bell">
    Manage the building blocks of incident response and on-call operations.

    | Resource                              | Description                         |
    | ------------------------------------- | ----------------------------------- |
    | `rootly_severity`                     | Incident severity levels            |
    | `rootly_incident_type`                | Incident types                      |
    | `rootly_incident_role`                | Incident roles and task assignments |
    | `rootly_incident_sub_status`          | Custom sub-statuses                 |
    | `rootly_incident_permission_set`      | Permission sets for incident fields |
    | `rootly_cause`                        | Incident causes                     |
    | `rootly_environment`                  | Environments                        |
    | `rootly_on_call_role`                 | On-call roles                       |
    | `rootly_schedule`                     | On-call schedules                   |
    | `rootly_schedule_rotation`            | Schedule rotations                  |
    | `rootly_schedule_rotation_active_day` | Active days within rotations        |
    | `rootly_schedule_rotation_user`       | Users assigned to rotations         |
    | `rootly_on_call_shadow`               | Shadow assignments for learning     |
    | `rootly_override_shift`               | Schedule override shifts            |
    | `rootly_escalation_policy`            | Escalation policies                 |
    | `rootly_escalation_level`             | Escalation levels within a policy   |
    | `rootly_escalation_path`              | Escalation paths                    |
    | `rootly_team`                         | Teams                               |
  </Accordion>

  <Accordion title="Alerts" icon="triangle-exclamation">
    Configure alert routing, sources, urgencies, and grouping rules.

    | Resource                    | Description                          |
    | --------------------------- | ------------------------------------ |
    | `rootly_alerts_source`      | Alert sources (inbound integrations) |
    | `rootly_alert_route`        | Alert routing rules                  |
    | `rootly_alert_routing_rule` | Conditions within an alert route     |
    | `rootly_alert_group`        | Alert grouping configuration         |
    | `rootly_alert_urgency`      | Alert urgency levels                 |
    | `rootly_alert_field`        | Custom alert fields                  |
    | `rootly_heartbeat`          | Heartbeat monitors                   |
  </Accordion>

  <Accordion title="Workflows" icon="diagram-project">
    Automate incident response with workflows triggered by incidents, alerts, pulses, and more.

    | Resource                                 | Description                               |
    | ---------------------------------------- | ----------------------------------------- |
    | `rootly_workflow_incident`               | Workflows triggered by incident events    |
    | `rootly_workflow_alert`                  | Workflows triggered by alert events       |
    | `rootly_workflow_pulse`                  | Workflows triggered by pulses             |
    | `rootly_workflow_post_mortem`            | Workflows triggered by post-mortem events |
    | `rootly_workflow_simple`                 | Simple scheduled or manual workflows      |
    | `rootly_workflow_group`                  | Workflow groups for organization          |
    | `rootly_workflow_action_item`            | Action item automation within workflows   |
    | `rootly_workflow_custom_field_selection` | Custom field conditions on workflows      |
    | `rootly_workflow_form_field_condition`   | Form field conditions on workflows        |

    **132 workflow task types** are available as individual resources, covering integrations with Slack, Jira, PagerDuty, Datadog, GitHub, Notion, and many more. See the [full resource list](https://registry.terraform.io/providers/rootlyhq/rootly/latest/docs) in the Terraform Registry.
  </Accordion>

  <Accordion title="Services & Catalog" icon="server">
    Manage your service catalog, functionalities, and custom catalog entities.

    | Resource                            | Description                              |
    | ----------------------------------- | ---------------------------------------- |
    | `rootly_service`                    | Services in your catalog                 |
    | `rootly_functionality`              | Functionalities                          |
    | `rootly_catalog`                    | Custom catalogs                          |
    | `rootly_catalog_entity`             | Entities within a catalog                |
    | `rootly_catalog_property`           | Properties on catalog entities           |
    | `rootly_catalog_checklist_template` | Checklist templates for catalog entities |
  </Accordion>

  <Accordion title="Forms & Custom Fields" icon="list-check">
    Declare form fields, options, and placement rules for incident forms.

    | Resource                                | Description                                  |
    | --------------------------------------- | -------------------------------------------- |
    | `rootly_form_field`                     | Custom form fields                           |
    | `rootly_form_field_option`              | Options for multi-select and dropdown fields |
    | `rootly_form_field_placement`           | Field placement on incident forms            |
    | `rootly_form_field_placement_condition` | Conditions controlling field visibility      |
    | `rootly_form_field_position`            | Field ordering within a form                 |
    | `rootly_form_set`                       | Sets of form fields                          |
    | `rootly_form_set_condition`             | Conditions for form set activation           |
    | `rootly_custom_field`                   | Additional custom fields                     |
    | `rootly_custom_field_option`            | Options for custom fields                    |
    | `rootly_custom_form`                    | Custom form configurations                   |
  </Accordion>

  <Accordion title="Retrospectives & Post-Mortems" icon="magnifying-glass">
    Manage retrospective templates and processes.

    | Resource                                  | Description                       |
    | ----------------------------------------- | --------------------------------- |
    | `rootly_post_mortem_template`             | Post-mortem document templates    |
    | `rootly_retrospective_configuration`      | Retrospective configuration       |
    | `rootly_retrospective_process`            | Retrospective process definitions |
    | `rootly_retrospective_process_group`      | Process groups                    |
    | `rootly_retrospective_process_group_step` | Steps within process groups       |
    | `rootly_retrospective_step`               | Individual retrospective steps    |
  </Accordion>

  <Accordion title="Status Pages" icon="signal">
    Manage status pages and their templates.

    | Resource                      | Description                  |
    | ----------------------------- | ---------------------------- |
    | `rootly_status_page`          | Status pages                 |
    | `rootly_status_page_template` | Status page update templates |
  </Accordion>

  <Accordion title="Communications & Roles" icon="comments">
    Manage communication templates, channels, and RBAC roles.

    | Resource                         | Description                     |
    | -------------------------------- | ------------------------------- |
    | `rootly_role`                    | RBAC roles                      |
    | `rootly_authorization`           | Role-based authorizations       |
    | `rootly_communications_template` | Communication message templates |
    | `rootly_communications_type`     | Communication types             |
    | `rootly_communications_stage`    | Communication stages            |
    | `rootly_communications_group`    | Communication groups            |
    | `rootly_webhooks_endpoint`       | Outbound webhook endpoints      |
    | `rootly_secret`                  | Secrets for use in workflows    |
    | `rootly_dashboard`               | Dashboards                      |
    | `rootly_dashboard_panel`         | Dashboard panels                |
    | `rootly_playbook`                | Playbooks                       |
    | `rootly_playbook_task`           | Tasks within a playbook         |
    | `rootly_live_call_router`        | Live call router configuration  |
  </Accordion>
</AccordionGroup>

## Data Sources

59 data sources let you reference existing Rootly resources in your configuration without managing them through Terraform.

```hcl theme={null}
# Look up an existing service
data "rootly_service" "payments" {
  slug = "payments"
}

# Look up an existing team
data "rootly_team" "platform" {
  slug = "platform"
}

# Reference them in a resource
resource "rootly_escalation_policy" "platform" {
  name    = "Platform On-Call"
  team_id = data.rootly_team.platform.id
}
```

Available data sources include: `service`, `services`, `team`, `teams`, `severity`, `severities`, `environment`, `environments`, `functionality`, `functionalities`, `schedule`, `user`, `role`, `incident`, `workflow`, `alert_route`, `escalation_policy`, `on_call_role`, and more.

## Examples

### Severities and services

```hcl theme={null}
resource "rootly_severity" "sev0" {
  name  = "SEV0"
  color = "#FF0000"
}

resource "rootly_severity" "sev1" {
  name  = "SEV1"
  color = "#FFA500"
}

resource "rootly_service" "payments_prod" {
  name  = "payments-prod"
  color = "#800080"
}
```

### On-call schedule with rotation

```hcl theme={null}
resource "rootly_schedule" "platform_oncall" {
  name = "Platform On-Call"
}

resource "rootly_schedule_rotation" "weekly" {
  schedule_id = rootly_schedule.platform_oncall.id
  name        = "Weekly Rotation"
}

resource "rootly_schedule_rotation_user" "alice" {
  schedule_rotation_id = rootly_schedule_rotation.weekly.id
  user_id              = "alice-user-id"
  position             = 0
}
```

### Workflow with Jira task

```hcl theme={null}
resource "rootly_workflow_incident" "jira" {
  name        = "Create a Jira Issue"
  description = "Open Jira ticket whenever incident starts"
  trigger_params {
    triggers                  = ["incident_created"]
    incident_condition_kind   = "IS"
    incident_kinds            = ["normal"]
    incident_condition_status = "IS"
    incident_statuses         = ["started"]
  }
  enabled = true
}

resource "rootly_workflow_task_create_jira_issue" "jira" {
  workflow_id = rootly_workflow_incident.jira.id
  task_params {
    title       = "{{ incident.title }}"
    description = "{{ incident.summary }}"
    project_key = "ROOT"
    issue_type = {
      id   = "10001"
      name = "Task"
    }
    status = {
      id   = "10000"
      name = "To Do"
    }
    labels = "{{ incident.environment_slugs | concat: incident.service_slugs | join: \",\" }}"
  }
}
```

### Custom form field

```hcl theme={null}
resource "rootly_form_field" "regions_affected" {
  name       = "Regions affected"
  kind       = "custom"
  input_kind = "multi_select"
  shown      = ["web_new_incident_form", "web_update_incident_form"]
  required   = ["web_new_incident_form"]
}

resource "rootly_form_field_option" "us_east" {
  form_field_id = rootly_form_field.regions_affected.id
  value         = "US East"
}

resource "rootly_form_field_option" "eu_west" {
  form_field_id = rootly_form_field.regions_affected.id
  value         = "EU West"
}
```

## Importing Existing Resources

Resources already configured in Rootly can be imported into Terraform state without recreating them:

```bash theme={null}
terraform import rootly_severity.sev0 <severity-id>
terraform import rootly_service.payments_prod <service-id>
terraform import rootly_workflow_incident.jira <workflow-id>
```

Resource IDs can be found in the Rootly API or in the URL when viewing a resource in the dashboard.

## Related Pages

<CardGroup cols={2}>
  <Card title="Pulumi" icon="https://mintcdn.com/rootly/Elm2B9K1HrybvGWA/images/integrations/logos/pulumi.svg?fit=max&auto=format&n=Elm2B9K1HrybvGWA&q=85&s=ea1b2c5e0de58bc7e32b6b2c33231094" href="/integrations/pulumi" width="300" height="300" data-path="images/integrations/logos/pulumi.svg">
    Manage Rootly resources with Pulumi using JavaScript or TypeScript.
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference">
    Explore the full Rootly REST API that powers the Terraform provider.
  </Card>
</CardGroup>
