defaults.styles object. It does not
introduce a second preset type: typography, element styles, page styles, and
reusable header/footer regions stay in one style bundle.
Legacy documents remain valid and are not modified when opened or rendered.
Root contract
The current root fields are all-or-nothing. A partial object such as
{ "pages": [] }
is rejected, which prevents ambiguous mixed versions.
Page entries and master variants
Each page entry is identified by the pair(id, variant). Dynamic object keys
and recursive inheritance are deliberately avoided.
The deterministic cascade is:
- global
default/default; - global odd/even or blank;
- global section-first;
- global document-first;
- selected page ID
default; - selected ID odd/even or blank;
- selected ID section-first;
- selected ID document-first;
- local section overrides.
null
explicitly clears a nullable value. A missing property inherits.
Geometry
Page entries support:- A3, A4, A5, Letter, Legal, and custom width/height;
- portrait and landscape;
- fixed or mirrored margins with an optional gutter;
- bleed;
- one to twelve columns, gap, divider, and balancing;
- top, center, or bottom content alignment;
- solid, image, linear-gradient, or radial-gradient backgrounds.
format: "custom".
For Office exports, page size, orientation, margins, columns, bleed, and
vertical content alignment are section geometry. Therefore an odd/even/first
variant may change the master content (headerRegionId, footerRegionId,
background, and page objects), but it may not silently change section geometry.
Use mirrored margins for binding-aware odd/even pages. Use a named page style
assigned to a dedicated section for a cover, landscape appendix, or genuinely
different first-page margins. HTML can apply variant geometry directly.
Office export rejects PDF bleed boxes because DOCX/ODT cannot preserve them.
This is reported as an unsupported capability instead of producing a
misleading PDF.
Repeating page objects
objects places reusable design elements behind or in front of document
content:
shape, line, image, text, and field.
A frame requires exactly two horizontal and two vertical constraints:
left + width,right + width, orleft + right;top + height,bottom + height, ortop + bottom.
allowClip or allowOverlap only when cropping or overlay is intentional.
Free text is wrapped inside its frame; insufficient height is rejected unless
intentional clipping is enabled.
Reusable header and footer regions
A region uses a bounded grid. Cells can span tracks and contain multiple blocks, so a header can contain several images, multiple text lines, fields, rules, and a background without a recursive layout tree.
Regions and cells also support fills, padding, and per-edge borders. A
traditional Word-style separator is a bottom border on the region or a
horizontal
rule block.
For Office output, column tracks may mix mm, %, auto, and fr. Their
fixed share must fit the available physical width. Row tracks are auto or
fixed mm; relative row heights are rejected because Word cannot preserve
them reliably. A fixed region height or maxHeight is checked against both
the configured blocks and the resolved runtime text/variables before the file
is written.
Section assignment
Both page and flow sections can select a page style:pageStart accepts auto, next, odd, and even. Number formats are
decimal, lowerRoman, upperRoman, lowerAlpha, and upperAlpha.
Validation layers
Autype validates a style in five layers:- structural Zod/JSON Schema validation;
- semantic references, unique IDs, grids, constraints, gradients, and tokens;
- asset authorization and copy-on-apply traversal;
- renderer capabilities (
native,rasterized,approximated,unsupported); - deterministic layout geometry and header/footer collision checks.
- a non-positive content area;
- region content exceeding
heightormaxHeight; - fixed grid tracks that do not fit or cannot resolve to 100%;
- a page object outside the physical page without
allowClip; - a foreground object over the content area without
allowOverlap; - free page text that cannot fit its frame.
minHeight or maxHeight to make collision
checking deterministic. New atomic style operations run these layout checks
before committing. The renderer repeats capability and layout validation so a
direct JSON request cannot bypass them.
In compatible export mode, non-native decisions are returned as warnings. In
strict mode, any unsupported decision rejects the target export.
Atomic style operations
Small edits do not require replacing the complete JSON:upsertPage, removePage, upsertRegion,
removeRegion, duplicatePage, duplicateRegion, addPageObject,
updatePageObject, removePageObject, duplicatePageObject,
movePageObject, moveRegionBlock, assignSection, setToken, removeToken,
setElementStyle, and resetElementStyle. Passing null as
assignSection.pageStyleId removes the explicit page-style assignment.
The batch is atomic: structural, semantic, token-reference, capability, or
physical-layout failure leaves the stored style unchanged. Document writes can
provide expectedSnapshotId; preset writes can provide expectedVersion.
Document writes are additionally committed in a serializable database
transaction, so a concurrent snapshot created between validation and commit
also returns HTTP 409.
Clients that require a faithful target can request a strict renderer gate:
UNSUPPORTED_STYLE_CAPABILITY. Images referenced by
legacy header/footer fields or current pages, regions, fills, and blocks are copied
as one unit. A failed copy or a later transaction conflict rolls those copies
back before the request fails.
Legacy migration
The read path normalizes legacy page settings and three-slot headers/footers in memory. It does not mutate a document. An explicit upgrade is copy-on-write:- preview the generated current bundle;
- optionally persist it;
- create a new immutable document snapshot;
- keep legacy fields for rollback and compatibility.
excludeFirstPage. Features that cannot be
downgraded losslessly return explicit warnings.
Focused schemas for agents
Use the smallest applicable generated schema:style-bundle.schema.jsonpage-style-entry.schema.jsonpage-region.schema.jsonregion-block.schema.jsonstyle-operations.schema.json
