Preview a Target Template
A POST to the /targets/preview endpoint processes a Twig template against a chosen
resource and returns the rendered payload. The template is rendered, then parsed as JSON, so
data.result is the decoded JSON object (not a string) and data.context is the resource
context the template was rendered against.
Provide either an inline template or a target_id (one is required). If both are sent, the
inline template takes precedence.
If the Twig fails to render, or its output is not valid JSON, the request returns 422 with a
captured error object (stage, message, line). When the failure is a JSON-parse error
(stage is json), the raw rendered output is also returned as rendered_raw so you can see
what the template produced.
Body
- PreviewTarget
- PreviewTarget
Provide either an inline template or a target_id. One of the two is required; if both are sent, the inline template takes precedence.
The resource type to render the template against.
profile, transaction, transaction_item, order, order_item, reward The ID of the resource record to render against.
An inline Twig template to render. Required when target_id is omitted.
The ID of an existing Target whose template to render. Required when template is omitted.
Response
The rendered, JSON-decoded template and the context it was rendered against.