---
title: "Export monitors, destinations, routes, templates and status pages as Terraform HCL"
method: GET
path: "/api/v1/export/terraform"
tags: ["Export"]
---

# Export monitors, destinations, routes, templates and status pages as Terraform HCL

`GET /api/v1/export/terraform`

## Request

- Base URL: `https://app.lastping.dev`
- URL: `https://app.lastping.dev/api/v1/export/terraform`
- Auth: API key in header `X-Api-Key`

Renders the authenticated project's resources as ready-to-commit
Terraform HCL, with an `import {}` block paired to every resource so
it is **adopted** rather than recreated. This is the primary way to
bring monitors created imperatively — via the dashboard or the MCP
server — under Terraform management.

**Secrets are never exported.** The API never returns channel
secrets (webhook URLs, bot tokens, etc.), so the corresponding HCL
attribute is emitted as a `var.<kind>_<attr>_<label>` reference
instead of an empty string, together with a matching `variable`
block (`sensitive = true`) and a `# Set this` comment. Omitting the
secret silently would ship a broken destination; the variable
indirection makes the gap visible and forces it to be filled in
before `terraform apply`.

**Query parameters:**
- `tag` — optional. Only export monitors carrying this tag (and
  their routes/templates).
- `monitor_slug` — optional. Narrows the export to the single
  monitor with this exact slug. If `tag` is also given, `tag` is
  applied first and `monitor_slug` filters *within* that
  tag-filtered set — the two combine as an AND, not an override. If
  the named monitor doesn't carry the given tag, the result is an
  empty export, not an error.
- `include` — optional comma-separated subset of
  `monitors,destinations,routes,templates,status_pages`. Omit to
  export everything.

A route, alert template, or status page referencing a monitor or
destination that was excluded from the export (by `include`, or
because it just isn't in this project) is skipped rather than
emitted with a dangling reference.

## Query parameters

- `tag` string
- `monitor_slug` string
- `include` string

## Response `200`

Terraform HCL as plain text. Content-Type is
`text/plain; charset=utf-8`.

## Other responses

- `400`: Unrecognised `include` value.
- `401`: Missing or invalid API key.
- `429`: Too many requests. The per-principal fixed-window rate limit has been exceeded. Retry after the number of seconds indicated by the `Retry-After` response header. The problem body's `code` is `RATE_LIMITED`. It names this limiter specifically, so a client can tell it apart from the application-level throttles that also answer 429 with their own codes and their own, much longer, `Retry-After` values (`TEST_PING_RATE_LIMITED`, `TOO_MANY_ATTEMPTS`). Back off globally on `RATE_LIMITED`; back off on the one operation for the others. The principal is the API key for a key-authenticated request and the USER for a browser session, so every tab one person has open shares one budget.

---

[API](https://skmtc.dev/lastping/apis/lastping-management-api.md) · [All operations](https://skmtc.dev/lastping/apis/lastping-management-api/llms.txt) · [OpenAPI document](https://skmtc.dev/lastping/apis/lastping-management-api/revisions/bbc6eda91c46?raw)
