Sign inGet Started

Preview a broadcast for a contact

POST
/v1/email/broadcasts/{broadcast_id}/preview
const params = {
  template: {
    parameters: {
      title: "Welcome",
      offer: "OCTOBER20",
      discount: 20,
      featured: false,
    },
  },
  contact_id: "con_01krdgeqcxet5s7t44vh8rt9mg",
};
const preview = await bird.broadcasts.preview(
  "eb_01krdgeqcxet5s7t44vh8rt9mg",
  params,
);
console.log(preview.subject, preview.preview_fingerprint);
Resposta200
{
  "resolution": {
    "template_id": "emt_01krdgeqcxet5s7t44vh8rt9mg",
    "observed_version_id": "emv_01krdgeqcxet5s7t44vh8rt9mg",
    "requested_language": "pt-BR",
    "effective_language": "pt-BR",
    "default_language": "pt-BR"
  },
  "contact_id": "con_01krdgeqcxet5s7t44vh8rt9mg",
  "problems": [
    {
      "code": "parameter_required",
      "phase": "validation",
      "severity": "error",
      "pointer": "/template/parameters/first_name",
      "site": "subject",
      "budget": "output_bytes",
      "contact_id": "con_01krdgeqcxet5s7t44vh8rt9mg"
    }
  ]
}

Render the template's published content using the saved broadcast, the changes supplied in this request and contact values the caller can read. Supplied fields replace the saved values for this preview only. Requires template read permission. Supply contact_id when the template uses contact data. The preview's unsubscribe link does not unsubscribe a contact. This does not send mail. Each call renders a fresh result. An Idempotency-Key header is accepted but does not replay an earlier preview.

Parâmetros

broadcast_idstring

Broadcast identifier.

Corpo da requisição

template
nullable object

Replaces the template, language or parameters for this request. Null removes the template for this request.

Mostrar parâmetros secundários
from
string or object

Replaces the sender for this request. Give it as a plain address, as Jane <jane@acme.com> to include a display name, or as an object with an address and a name.

Mostrar parâmetros secundários
reply_to
nullable array

Replaces the reply-to addresses for this request. Null removes them.

headers
object

Replaces the custom headers for this request rather than adding to them. Up to 25 of them, each value up to 998 characters. The header rules for updating a broadcast apply.

contact_id
string

The workspace contact whose values fill bird.contact. inputs. Required when the template or envelope reads contact data. Present values are used as they are, and a property's fallback applies only when the contact has no value for it.

Payload de resposta

resolution
object
obrigatório

The published template version and language a validation or preview checked. It does not fix the version a later send uses.

Mostrar atributos secundários
resolution.template_id
string
obrigatório

The template the broadcast uses.

resolution.observed_version_id
string
obrigatório

The published template version that was checked.

resolution.requested_language
string

The language selected in template.language, by the broadcast or this request. Absent when none is selected and the published version's default language is used.

resolution.effective_language
string
obrigatório

The language whose content was checked.

resolution.requirements_fingerprint
string
obrigatório

An opaque value that changes when the checked version, its content or the inputs it uses change. Compare it with an earlier value to tell whether the requirements are still the same. Do not parse it.

resolution.default_language
string

The published version's default language. When the broadcast has template.parameter_overrides, template.parameters must hold every input this language's content and the broadcast's sender name, reply-to and headers use; without it the selected language's rules apply. Read the complete lists from base_parameters and override_parameters on the validation result. Template inputs describe template content only and do not include the sender name, reply-to or headers.

contact_id
string

The contact whose values personalized this preview. Absent when the request named none.

subject
string
obrigatório

The rendered subject line.

preheader
string
obrigatório

The text of the hidden preview block that this render of html includes, which inbox clients can show beside the subject. It is empty when the template has no preview text, when the text renders empty, or when the rendered HTML does not include the block. A version published earlier can have preview text whose block its markup leaves out, escapes or removes; publishing the template again places the block. This value describes the rendered HTML and does not show how a provider or inbox displays it. Use it instead of reading the hidden block in html.

html
string
obrigatório

The rendered HTML body. When preheader is not empty, it includes the hidden block that carries that text.

text
string
obrigatório

The rendered plain-text body.

resolved_parameters
object
obrigatório

The broadcast inputs this render used, by name, each with the string, number, boolean or null value it used. It holds the values taken from template.parameters or the selected language's template.parameter_overrides entry, and only for names the rendered content or envelope uses. Contact values are never included. A number keeps the digits it was supplied with.

problems
array of object
obrigatório

Problems with the broadcast's inputs found while rendering this preview.

Mostrar atributos secundários
preview_fingerprint
string
obrigatório

An opaque value for this rendered content. It changes when the published version, an input, a contact value, a fallback or the envelope changes. To send this content as a test, repeat the same inputs with this value. Do not parse it.