Render a template against a representative alert, without saving anything.
const url = 'https://example.com/api/v1/notification-channels/preview';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"body":"example","event":"fire","kind":"webhook","subject":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/notification-channels/preview \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "body": "example", "event": "fire", "kind": "webhook", "subject": "example" }'A template is code that first runs during an outage, so being able to see its output while writing it is part of the feature rather than a convenience. Takes no channel id, so a template can be checked before the channel it belongs to exists.
Problems come back in the 200 response, not as a 400: they are notes about the text being typed, and a failed request would render as “the preview is broken” instead.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”A template to render against a representative alert.
object
Which point in an alert’s life to render: fire, resolve, or suppress.
The channel kind the template is for. Decides whether the body has to be valid JSON.
Responses
Section titled “Responses”What this template would send; a template that cannot be used is reported in-band alongside the built-in text that would go instead
What the template produces, or what stopped it.
object
The rendered body, under the same rule.
Whether the rendered body parses as JSON. null when this channel kind sends the body as
plain text, where the question does not apply.
One entry per field that could not be rendered and fell back. Empty on success.
One field that could not be used.
object
subject or body.
The engine’s message, including the offending line where it knows it.
compile, render, too_large, or not_json.
The rendered subject. Yagra’s built-in wording when the subject is not overridden, or when rendering it failed — which is exactly what would be sent.
Examplegenerated
{ "body": "example", "json_valid": true, "problems": [ { "field": "example", "message": "example", "reason": "example" } ], "subject": "example"}No valid bearer token
The ADR-019 envelope every failure renders as. pub(crate) and schema-bearing so the OpenAPI
document can name one error shape for every endpoint (ADR-035) instead of leaving 4xx/5xx bodies
undescribed — a client that has to guess the failure shape ends up parsing the success shape and
reading undefined.
object
object
Stable machine-readable code. Clients branch on this, never on the message.
Operator-facing sentence. Safe to display; never carries an internal error’s own text.
Examplegenerated
{ "error": { "code": "example", "message": "example" }}Role below Admin
The ADR-019 envelope every failure renders as. pub(crate) and schema-bearing so the OpenAPI
document can name one error shape for every endpoint (ADR-035) instead of leaving 4xx/5xx bodies
undescribed — a client that has to guess the failure shape ends up parsing the success shape and
reading undefined.
object
object
Stable machine-readable code. Clients branch on this, never on the message.
Operator-facing sentence. Safe to display; never carries an internal error’s own text.
Examplegenerated
{ "error": { "code": "example", "message": "example" }}