Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / createRcmlDocumentElement

Function: createRcmlDocumentElement()

createRcmlDocumentElement(options): RcmlDocument

Defined in: rcml/src/email/create-rcml-element.ts:1173

Build the <rcml> document root — wraps a pre-built <rc-head> + <rc-body> pair into the top-level document shape.

Name deliberately disambiguated from the legacy createRCMLDocument in ../elements.ts: this factory takes an explicit head + body (no brand-style / sections shorthand).

Parameters

options

RcmlDocumentElementOptions

options.head and options.body are the two document children in order. Both must be produced by createHeadElement / createBodyElement.

Returns

RcmlDocument

A typed RcmlDocument node, ready for rcmlToXml or validateEmailTemplate.

Throws

When the supplied head/body nodes are not structurally valid children of <rcml>.

Example

ts
createRcmlDocumentElement({
  head: createHeadElement({ children: [] }),
  body: createBodyElement({ children: [createSectionElement({ children: [...] })] }),
})