Sign inGet Started

Validate a reusable email section

POST
/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);

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.

Anfrage-Nutzlast

language
string
erforderlich

A language tag in BCP-47 form, for example en or pt-BR.

fragment
object
erforderlich

One 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.

Untergeordnete Parameter anzeigen
fragment.serializer_version
integer
erforderlich

How this section is written. 2 is HTML written directly, and is the value to send from the API, SDKs, CLI and MCP. 1 is reserved for the Bird dashboard's visual editor; other callers get a 422 for it.

fragment.fragment_html
string
erforderlich

Section HTML. Unfinished markup can be saved as a draft; validation checks readiness separately. A version 2 section is one presentation table with one tbody, tr and td, and all layout stays inside that cell. The cell sets lang to the block language and its own typography: font-family, a font-size in pixels, font-style, font-weight, line-height, letter-spacing, text-align (not start or end), text-transform, color, margin and padding. Root-relative units such as rem are refused; use px, em or percentages. Liquid stays balanced inside the cell, cannot use assign, capture, increment or decrement, and puts no control tag inside an attribute or style value. {{ bird.unsubscribe_url }} appears only as bare text or as the entire href of an <a>, and never inside an if !mso conditional comment, which Outlook skips. No document wrapper, <style>, script, form, class or id attribute. A table nested in the cell needs its own <tbody>. Inside a complete Outlook conditional comment, prefixed Office and VML elements such as v:fill may self-close, and a balanced if !mso conditional comment that shows its content outside Outlook is accepted when it holds no other conditional comment.

Antwort-Payload

text
string
erforderlich

Plain text derived from this section's HTML.

Weiter mit der Dokumentation, Anleitungen und Beispielen zu diesem Thema.