Validate a reusable email section
/v1/email/blocks/validate// Requires email_management:read permission in the target workspace.
const section =
'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr>' +
'<td lang="en" style="font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; ' +
"line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;\">" +
'<p style="margin: 0;">Offer valid until {{ expiry_date }}.</p></td></tr></tbody></table>';
const result = await bird.email.blocks.validate({
language: "en",
fragment: { serializer_version: 2, fragment_html: section },
});
console.log(result.text);# Requires email_management:read permission in the target workspace.
section = (
'<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr>'
'<td lang="en" style="font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; '
'line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;">'
'<p style="margin: 0;">Offer valid until {{ expiry_date }}.</p></td></tr></tbody></table>'
)
result = client.email.blocks.validate(
language="en",
fragment={"serializer_version": 2, "fragment_html": section},
)
print(result.text)// Requires email_management:read permission in the target workspace.
section := `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr>` +
`<td lang="en" style="font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; ` +
`line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;">` +
`<p style="margin: 0;">Offer valid until {{ expiry_date }}.</p></td></tr></tbody></table>`
client, err := bird.NewClient(option.WithAPIKey(os.Getenv("BIRD_API_KEY")))
if err != nil {
log.Fatal(err)
}
result, err := client.Email.Blocks.Validate(context.Background(), bird.EmailBlocksValidateParams{
Language: "en",
Fragment: bird.EmailBlockFragment{SerializerVersion: 2, FragmentHtml: section},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Text)// Requires email_management:read permission in the target workspace.
$section = '<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr>'
. '<td lang="en" style="font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; '
. 'line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;">'
. '<p style="margin: 0;">Offer valid until {{ expiry_date }}.</p></td></tr></tbody></table>';
$params = (new \MessageBird\Wire\Model\EmailBlockFragmentValidationRequest())
->setLanguage('en')
->setFragment((new \MessageBird\Wire\Model\EmailBlockFragment())
->setSerializerVersion(2)
->setFragmentHtml($section));
$result = $bird->email->blocks->validate($params);
echo $result->getText();bird email blocks validate --body-file - <<'JSON'
{
"language": "en",
"fragment": {
"serializer_version": 2,
"fragment_html": "<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tbody><tr><td lang=\"en\" style=\"font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;\"><p style=\"margin: 0;\">Your disclosure text.</p></td></tr></tbody></table>"
}
}
JSONcurl -X POST "https://us1.platform.bird.com/v1/email/blocks/validate" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"language": "en",
"fragment": {
"serializer_version": 2,
"fragment_html": "<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tbody><tr><td lang=\"en\" style=\"font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;\"><p style=\"margin: 0;\">Your disclosure text.</p></td></tr></tbody></table>"
}
}'Checks a section against the rules applied when it is published: its structure and the content cell's typography, balanced Liquid, and registered contact properties. Contact properties are checked only for a caller with contact read access; without it, validation says nothing about them, and publication still refuses a property that is not registered or is archived. Returns the plain text derived from the section, or a 422 validation_error naming each field to correct. Nothing is saved or published. Each call computes a fresh result: an Idempotency-Key header is accepted but does not replay an earlier result.
Corps de la requête
languageA language tag in BCP-47 form, for example en or pt-BR.
fragmentOne self-contained email section. Version 2 is a section written as HTML and sends fragment_html alone; the API, SDKs, CLI and MCP write version 2. Version 1 is reserved for sections built in the Bird dashboard's visual editor, and only the dashboard saves it. A block language keeps the version it was created with.
Contenu de la réponse
textPlain text derived from this section's HTML.
Ressources associées
Poursuivez avec la documentation, les guides et les exemples sur ce sujet.