Preview a broadcast for a contact
/v1/email/broadcasts/{broadcast_id}/previewconst 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);template = {
"parameters": {
"title": "Welcome",
"offer": "OCTOBER20",
"discount": 20,
"featured": False,
}
}
contact_id = "con_01krdgeqcxet5s7t44vh8rt9mg"
preview = client.broadcasts.preview(
"eb_01krdgeqcxet5s7t44vh8rt9mg", template=template, contact_id=contact_id
)
print(preview.subject, preview.preview_fingerprint)parameters := map[string]json.RawMessage{"title": json.RawMessage(`"Welcome"`), "offer": json.RawMessage(`"OCTOBER20"`), "discount": json.RawMessage(`20`), "featured": json.RawMessage(`false`)}
params := bird.BroadcastsValidateParams{Template: bird.Value(bird.BroadcastsParameterTemplate{Parameters: ¶meters})}
previewParams := bird.BroadcastsPreviewParams{BroadcastsValidateParams: params, ContactID: "con_01krdgeqcxet5s7t44vh8rt9mg"}
preview, err := client.Broadcasts.Preview(context.Background(), "eb_01krdgeqcxet5s7t44vh8rt9mg", previewParams)
if err != nil {
log.Fatal(err)
}
fmt.Println(preview.Subject, preview.PreviewFingerprint)$params = ['template' => ['parameters' => ['title' => 'Welcome', 'offer' => 'OCTOBER20', 'discount' => 20, 'featured' => false]], 'contact_id' => 'con_01krdgeqcxet5s7t44vh8rt9mg'];
$preview = $bird->broadcasts->preview('eb_01krdgeqcxet5s7t44vh8rt9mg', $params);
echo $preview->getSubject(), ' ', $preview->getPreviewFingerprint();bird email broadcasts preview <broadcast-id> \
--contact-id con_01krdgeqcxet5s7t44vh8rt9mg \
--from 'Jane Doe <jane@acme.com>' \
--header X-Campaign=spring-launchcurl -X POST "https://us1.platform.bird.com/v1/email/broadcasts/{broadcast_id}/preview" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"from": "Jane Doe <jane@acme.com>",
"headers": {
"X-Campaign": "spring-launch"
},
"contact_id": "con_01krdgeqcxet5s7t44vh8rt9mg"
}'{
"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.
Parameters
broadcast_idstringBroadcast identifier.
Verzoekpayload
templateReplaces the template, language or parameters for this request. Null removes the template for this request.
Onderliggende parameters tonen
template.idSelect this template. Changing the ID clears the old language, parameters and parameter overrides before supplied replacements. Repeating the same ID retains those values and clears the selected template version, so the next preparation uses the template's latest published version. Omit id to retain the selected template. Adding parameters to a draft created before parameters existed may clear its selected version so it uses the template's latest published version. To clear a draft's selection, set template itself to null.
template.languageThe BCP-47 language tag that goes to the whole audience, such as en or pt-BR. It must be an exact match for a language on the template's published version, so fr-CA does not select fr. Leave it out to keep the language already selected. If you change the template id in the same request, the old language is cleared with the old template. Set this to null to use the published version's default language, unless the template has language_source_required set.
template.parametersComplete template input map. Each value is a string, number, boolean or null and is used exactly as given, so text containing braces or code-like syntax is never evaluated. Objects and lists are not accepted. Use bird.contact.first_name in the template for contact data. Names must be bare input names outside the bird namespace. Omission retains the map unless the template ID changes, which clears it; an empty object clears it, and null is invalid. The compact map is limited to 16384 UTF-8 bytes and 128 names. Individual email parameters keep their own format.
template.parameter_overridesComplete map of per-language parameter values, keyed by a BCP-47 language tag of at most 35 characters such as es or pt-BR. Each language holds only the names whose value differs for that language; a name it leaves out uses the value in parameters, including later changes to it. A value that is present always applies, even when it is "", 0, false, null or equal to the parameters value. To return a name to the parameters value, send the map without it. Sending this map, even as {}, applies language rules to the broadcast: parameters must hold every input the default language's content, sender name, reply-to or headers use, and an input only the selected language uses may come from that language's entry instead. A broadcast that never sends it keeps the selected-language rules. Values for the default language, or for a language the broadcast does not send, are kept but not used. Omission retains the map unless the template ID changes, which clears it; an empty object removes every override, null is invalid and a language with no names is removed. Tags are stored in canonical BCP-47 form, so two spellings of one tag are refused. The compact map is limited to 16384 UTF-8 bytes, and parameters and every language together are limited to 128 distinct names.
fromReplaces 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.
reply_toReplaces the reply-to addresses for this request. Null removes them.
headersReplaces 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_idThe 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.
Response Payload
resolutionThe published template version and language a validation or preview checked. It does not fix the version a later send uses.
contact_idThe contact whose values personalized this preview. Absent when the request named none.
subjectThe rendered subject line.
preheaderThe 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.
htmlThe rendered HTML body. When preheader is not empty, it includes the hidden block that carries that text.
textThe rendered plain-text body.
resolved_parametersThe 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.
problemsProblems with the broadcast's inputs found while rendering this preview.
preview_fingerprintAn 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.
Gerelateerde bronnen
Ga verder met de documentatie, handleidingen en voorbeelden voor dit onderwerp.