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

# Terraform Provider

Manage your Vibe OnCall setup as code. The **Vibe OnCall Terraform provider** lets you define teams, schedules, escalation policies, services, alert sources, and alert routing in Terraform files, review changes in a pull request, and apply them to your organization. It works with both **Terraform** and **OpenTofu**.

> **Write** your on-call setup in code → **review** it like any other change → **apply** it to Vibe OnCall.

This page gets you started. The full reference for every setting lives on the [Terraform Registry](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs).

***

### What You Can Manage

| In Vibe OnCall | Terraform resource |
| - | - |
| Teams and their members | [vibeoncall\_team](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/team), [vibeoncall\_team\_membership](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/team_membership) |
| Schedules | [vibeoncall\_schedule](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/schedule) |
| Escalation policies | [vibeoncall\_escalation\_policy](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/escalation_policy), [vibeoncall\_team\_default\_escalation\_policy](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/team_default_escalation_policy) |
| Services | [vibeoncall\_service](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/service) |
| Alert sources | [vibeoncall\_alert\_source](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/alert_source) |
| Alert routing | [vibeoncall\_alert\_route](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/alert_route) |
| Maintenance windows | [vibeoncall\_maintenance\_window](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest/docs/resources/maintenance_window) |

You can also look up things that already exist without managing them: **members** by email, **teams**, **schedules**, **labels**, and **chat channels**. Each has a data source page on the Registry.

***

### Before You Start

* **Terraform 1.9 or later**, or OpenTofu.
* **Everyone you reference already has a Vibe OnCall account.** Terraform looks people up by email; it doesn't invite them. Make sure they exist before you apply, either by inviting them in the app or by provisioning them through SCIM.
* **An API key** for Terraform to use, created below.

***

### Create an API Key for Terraform

1. Navigate to **Administration → API Keys** and click **Create API Key**.

2. Name it after where it runs, such as *Terraform* or *Terraform CI*, so its changes are easy to recognize later.

3. Choose an **Access** level. **Full access** is the simplest. To limit the key to what Terraform manages, choose **Custom** and select the matching actions:

   * **Manage every team** for teams and their members.
   * **Manage services in Global and every team** for services.
   * **Manage on-call schedules** for schedules, plus **Manage schedule teams** if you change which teams own an existing schedule.
   * **Manage escalation policies**, **Manage maintenance windows**, **Manage alert sources**, and **Manage alert routing** for those settings.

   **Read-only** keys can't make changes, so they don't work for Terraform.

4. Click **Create API Key** and copy the key. Store it in your secret manager or CI secrets, not in your Terraform files.

See [API Key Management](https://docs.vibraniumlabs.ai/api/api-key-management.md) for expiration, rotation, and the request log.

***

### Quick Start

Add the provider to your configuration:

```hcl theme={null}
terraform {
  required_providers {
    vibeoncall = {
      source  = "vibraniumlabs/vibeoncall"
      version = "~> 0.1.0"
    }
  }
}

provider "vibeoncall" {}
```

The provider reads the key from the `VIBEONCALL_API_KEY` environment variable:

```shell theme={null}
export VIBEONCALL_API_KEY=vlk_...
terraform init
terraform plan
```

For a full working setup, start from the [complete example](https://github.com/vibraniumlabs/terraform-provider-vibeoncall/tree/main/examples/complete). It creates a team with admins and members, a weekly rotation, a two-tier escalation policy, a service, and an alert source with routing. Fill in your team name and member emails, then apply.

***

### Bring an Existing Setup Under Terraform

If you already configured Vibe OnCall in the app, import those settings instead of recreating them. Recreating a team creates a second team with the same name, because team names don't have to be unique.

1. Find the numeric ID of each thing you want to import. The [Public API](https://docs.vibraniumlabs.ai/api/public-api-reference.md) list endpoints return them, for example `GET /teams`, `GET /schedules?teamId=…`, or `GET /alert-sources?teamId=…`. For a single team, schedule, escalation policy, or service, the ID is also the number at the end of its page address in the app.
2. Add an `import` block for each one:

```hcl theme={null}
import {
  to = vibeoncall_team.payments
  id = "42"
}
```

3. Run `terraform plan -generate-config-out=generated.tf`. Terraform reads the current settings and writes matching configuration for you.
4. Review the generated file, then run `terraform plan` again. It should show only imports and **0 to change**. Apply, then delete the `import` blocks.

Each resource's Registry page has an **Import** section with the ID it expects.

***

### Other Details Worth Knowing

* **Terraform owns what it manages.** If someone edits a Terraform-managed schedule or policy in the app, the next `terraform apply` changes it back. Make the change in code instead.
* **Changes are attributed to the key.** The **History** tab on teams, schedules, escalation policies, services, maintenance windows, and alert routing shows the API key's name as the actor for changes Terraform made.
* **Removing a member safely.** In schedules and escalation policies, reference members through `vibeoncall_team_membership`, and set `create_before_destroy = true` on the membership. Terraform then takes someone off rotations and policies before it removes them from the team. The [complete example](https://github.com/vibraniumlabs/terraform-provider-vibeoncall/tree/main/examples/complete) does this.
* **OpenTofu works the same way.** The provider is published to the OpenTofu registry under the same `vibraniumlabs/vibeoncall` address.
* **Pin the version.** `~> 0.1.0` takes bug fixes without surprises. The [changelog](https://github.com/vibraniumlabs/terraform-provider-vibeoncall/blob/main/CHANGELOG.md) lists what each release changes.

***

### Links

* [Terraform Registry: vibraniumlabs/vibeoncall](https://registry.terraform.io/providers/vibraniumlabs/vibeoncall/latest)
* [OpenTofu Registry: vibraniumlabs/vibeoncall](https://search.opentofu.org/provider/vibraniumlabs/vibeoncall/latest)
* [Source code and issues on GitHub](https://github.com/vibraniumlabs/terraform-provider-vibeoncall)
* [Complete example](https://github.com/vibraniumlabs/terraform-provider-vibeoncall/tree/main/examples/complete)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.