---
title: "Preview an alert template"
method: POST
path: "/api/{org_id}/alerts/templates/preview"
tags: ["Templates"]
---

# Preview an alert template

`POST /api/{org_id}/alerts/templates/preview`

## Request

- Base URL: `https://api.openobserve.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.openobserve.ai/api/{org_id}/alerts/templates/preview`
- Auth: API key in header `Authorization`
- TypeScript: <https://skmtc.dev/openobserve/apis/openobserve-api-http/docs/api/:org_id/alerts/templates/preview/post.ts> (a function with typed inputs; its response is checked against the schema)

Renders a draft content-template definition for a chosen channel against a deterministic synthetic sample, returning both the real wire payload the send path would produce and a normalized preview model for card rendering. Uses the exact same resolve/render code path as sending a live notification, so the preview is guaranteed to match production output for the same input.

## Path parameters

- `org_id` string, required

## Request body

- object
  - `channel` string, required: "slack" | "teams_adaptivecard" | "teams_messagecard" | "email" | "webhook" | "discord" | "pagerduty" | "opsgenie" | "servicenow" | "sns"
  - `definition` ContentSpec, required
    - `body` string: Markdown with {var} placeholders.
    - `chart` ChartSpec
      - `enabled` boolean
    - `fields` ContentField[]
      - `label` string
      - `show_when` SeverityFilter
        - `levels` AlertLevel[]
      - `value` string
    - `links` ContentLink[]
      - `label` string
      - `show_when` SeverityFilter
        - `levels` AlertLevel[]
      - `url` string
    - `rows` RowsSpec
      - `columns` string[], nullable: Column names to include; None = all columns in table column order.
      - `enabled` boolean: Whether to render rows in the notification.
      - `format` string, nullable: Per-row line template over selected row columns; operates on full row regardless of columns selection.
      - `max` integer: Maximum number of rows to include in the notification (default 5).
    - `title` string: Templated one-liner: Slack headline, email subject, PagerDuty summary.
    - `title_overrides` object: Per-channel title overrides keyed by channel family ("slack", "teams", "email", ...). Unknown keys ignored on read (mixed-version rule).
  - `kind` 'alert' | 'incident' | 'anomaly' | 'synthetics' | 'downtime' | 'on_call'
  - `sample` unknown
  - `severity` string, nullable: "critical" | "warning" | "ok" | "no_data" | "single_level" (default)

## Response `200`

Success

- TemplatePreviewResponse
  - `empty_variables` string[], required: Variables the draft uses that render blank in the previewed kind's sample.
  - `payload` unknown, required
  - `preview_model` PreviewModel, required
    - `body_html` string, required: Server-rendered markdown; the FE sanitizes with dompurify.
    - `chart_placeholder` boolean, required
    - `color` string, required: Severity color hex.
    - `fields` PreviewKv[], required
      - `label` string, required
      - `value` string, required
    - `footer` string, required
    - `links` PreviewLink[], required
      - `label` string, required
      - `url` string, required
    - `severity` string, nullable
    - `title` string, required
  - `unknown_variables` string[], required
  - `variable_groups` VariableGroup[], required: `common` and one group per kind whose producer renders templates in this release.
    - `name` string, required
    - `variables` string[], required
  - `variables` string[], required: Every variable a template of the requested kind can use.

## Other responses

- `400`: Error

---

[API](https://skmtc.dev/openobserve/apis/openobserve-api-http.md) - [All operations](https://skmtc.dev/openobserve/apis/openobserve-api-http/llms.txt) - [OpenAPI document](https://skmtc.dev/openobserve/apis/openobserve-api-http/revisions/0529b8a10252?raw)
