Document apiReferenceTemplates

templates.apply

Apply detected DOCX template/substrate (styles, numbering, settings, theme, font table, web settings, headers/footers, section defaults) from a source package onto the current document, preserving body content. Scopes are auto-detected from source package evidence.

mutates documentdry runconditional
await doc.templates.apply(…)

Expected result

Returns a TemplatesApplyReceipt with detected/applied/skipped scopes, unsupported items, changed parts, id mappings, and warnings.

Inputs

sourcepath | base64required
path
kind"path"required
pathstringrequired
base64
kind"base64"required
datastringrequired
filenamestring
1 additional input field
bodyPolicy"preserve"

Result

Output fields
true
successtruerequired
changedbooleanrequired
dryRunbooleanrequired
bodyPolicy"preserve"required
sourceobjectrequired
Fields
kind"path" | "base64"required
fingerprintstringrequired
partCountintegerrequired
detectedScopesobject[]required
appliedScopesobject[]required
skippedScopesobject[]required
unsupportedItemsobject[]required
changedPartsobject[]required
idMappingsobjectrequired
Fields
stylesobject[]
numberingobject[]
relationshipsobject[]
warningsobject[]required
false
successfalserequired
failureobjectrequired
Fields
code"UNSUPPORTED_SOURCE" | "INVALID_PACKAGE" | "CAPABILITY_UNAVAILABLE" | "UNSUPPORTED_TEMPLATE_CONTENT"required
messagestringrequired

Failures

Pre-apply throws

  • INVALID_INPUT
  • CAPABILITY_UNAVAILABLE
  • REVISION_MISMATCH

Non-applied receipt codes

  • UNSUPPORTED_SOURCE
  • INVALID_PACKAGE
  • CAPABILITY_UNAVAILABLE
1 more codes
  • UNSUPPORTED_TEMPLATE_CONTENT

Raw schemas

Open the generated JSON artifact for the exact input, output, success, and failure schemas represented by this contract version.

View raw JSON schemas