Document spec
The DocumentSpec that create_document takes. Blocks of headings, paragraphs, lists and tables, with real Word styles and numbering.
A DocumentSpec is a title and a list of blocks: heading, paragraph, list, table, pageBreak, toc, image, section and definitions. Headings get real heading styles, lists get Word numbering (never typed "1." or "-"), and tables get the dark header band and a totals row when asked. Page setup, header, footer, page numbers, comments and tracked changes are fields of the spec.

Smallest example
{
"filename": "expense-policy",
"spec": {
"title": "Expense policy",
"blocks": [
{ "kind": "heading", "level": 1, "text": "Purpose" },
{ "kind": "paragraph", "text": "This policy explains which costs the company pays and how to claim them." },
{ "kind": "list", "style": "number", "items": ["Keep the receipt", "Fill in the expense form within 30 days", "Send it to your manager"] }
]
}
}A full example
The spec behind the expense policy.
{
"filename": "expense-policy",
"spec": {
"lang": "en-US",
"title": "Expense policy",
"subtitle": "How to spend, approve and claim company money",
"page": {
"size": "Letter",
"orientation": "portrait"
},
"header": "Expense policy",
"footer": "Internal · Version 1.1",
"blocks": [
{
"kind": "heading",
"level": 1,
"text": "Purpose"
},
{
"kind": "paragraph",
"text": [
"This policy explains which costs the company pays and how to claim them. It applies to ",
{
"text": "every employee and contractor",
"bold": true
},
" who spends money for the company."
]
},
{
"kind": "heading",
"level": 1,
"text": "Rules"
},
{
"kind": "list",
"style": "number",
"items": [
"Spend company money only on costs for your work",
"Pick the cheaper option when two options do the same job",
"Ask your manager in writing before you spend above a limit in the table below",
"Never approve your own expense claim",
"Keep every receipt for six years"
]
},
{
"kind": "heading",
"level": 1,
"text": "Spending limits"
},
{
"kind": "table",
"columns": [
"Category",
"Limit without approval",
"Receipt needed"
],
"rows": [
[
"Travel by train or bus",
"$250 per trip",
"Yes"
],
[
"Hotel",
"$180 per night",
"Yes"
],
[
"Meals while travelling",
"$60 per day",
"Yes"
],
[
"Software and subscriptions",
"$50 per month",
"Yes"
],
[
"Office supplies",
"$100 per order",
"Above $25"
]
],
"caption": "Limits are per person and include sales tax."
},
{
"kind": "heading",
"level": 1,
"text": "How to claim"
},
{
"kind": "list",
"style": "number",
"items": [
"Fill in the expense form within 30 days of the purchase",
{
"text": "Add the project or customer the cost belongs to",
"level": 1
},
{
"text": "Attach every receipt",
"level": 1
},
"Send the form to your manager for approval",
"Finance pays approved claims with the next monthly salary"
]
},
{
"kind": "heading",
"level": 1,
"text": "What the company does not pay"
},
{
"kind": "list",
"style": "bullet",
"items": [
"Fines and parking tickets",
"Personal travel added to a business trip",
"Alcohol, unless a client meal was approved first"
]
},
{
"kind": "heading",
"level": 2,
"text": "Questions"
},
{
"kind": "paragraph",
"text": "Ask the finance team. They review this policy every year in January."
}
]
}
}Fields
Generated from the schema the tools send to the model. A field with ? is optional.
| Field | Type | Description |
|---|---|---|
version? | 1 | |
lang? | string | BCP 47 language tag of the text, for spelling and hyphenation; default from the host settings |
title | string (max 200 chars) | Document title in sentence case: the first line and the file's title property |
subtitle? | string (max 300 chars) | |
font? | string (max 64 chars) | One font for body and headings; default Calibri |
page? | object | |
header? | string (max 200 chars) | Text at the top of every page |
footer? | string (max 200 chars) | Text at the bottom of every page |
pageNumbers? | "pageOfTotal" | "page" | "none" | Page numbers at the bottom right, in the document language: "Page 2 of 5" (default), "2", or none |
firstPage? | object | A different first page (a cover): its own header and footer, blank when omitted |
comments? | object[] (at most 500) | |
trackChanges? | object | Author and date of the ins/del/change marks |
blocks | object[] (at least 1, at most 2,000) |
page
| Field | Type | Description |
|---|---|---|
size? | "A4" | "Letter" | Default: Letter for en-US, A4 for every other locale |
orientation? | "portrait" | "landscape" |
firstPage
A different first page (a cover): its own header and footer, blank when omitted
| Field | Type | Description |
|---|---|---|
header? | string (max 200 chars) | |
footer? | string (max 200 chars) |
comments[]
| Field | Type | Description |
|---|---|---|
id | string (max 40 chars) | Referenced by comment on a run or block |
author | string (max 80 chars) | |
initials? | string (max 9 chars) | Default: from the author's name |
date? | string | |
text | string (max 2,000 chars) | |
resolved? | boolean | |
replies? | object[] (at most 50) |
comments[].replies[]
| Field | Type | Description |
|---|---|---|
author | string (max 80 chars) | |
initials? | string (max 9 chars) | |
date? | string | |
text | string (max 2,000 chars) |
trackChanges
Author and date of the ins/del/change marks
| Field | Type | Description |
|---|---|---|
author | string (max 80 chars) | Author of the tracked changes |
date? | string | |
record? | boolean | Turn on Track Changes in Word, so later edits are tracked too |
blocks[] kind: "heading"
| Field | Type | Description |
|---|---|---|
kind | "heading" | |
level | 1 | 2 | 3 | |
text | string (max 200 chars) | |
change? | "insert" | "delete" | Tracked insertion or deletion of the whole block |
comment? | string (max 40 chars) | Id of a comment in comments anchored to the whole block |
bookmark? | string (max 40 chars) | Bookmark name on the block |
blocks[] kind: "paragraph"
| Field | Type | Description |
|---|---|---|
kind | "paragraph" | |
text | string | (string | object)[] | |
align? | "left" | "center" | "right" | "justify" | |
change? | "insert" | "delete" | Tracked insertion or deletion of the whole block |
comment? | string (max 40 chars) | Id of a comment in comments anchored to the whole block |
bookmark? | string (max 40 chars) | Bookmark name on the block |
blocks[] kind: "list"
| Field | Type | Description |
|---|---|---|
kind | "list" | |
style? | "bullet" | "number" | "clauses" | "clauses" numbers 1, 1.1, 1.1.1 and continues through the document |
items | (string | (string | object)[] | object)[] (at least 1, at most 200) | |
restart? | boolean | Clauses only: start again at 1 |
blocks[].items[]
| Field | Type | Description |
|---|---|---|
text | string | (string | object)[] | |
level? | integer (min 0, max 2) | 0 = top level, 1 = nested once, 2 = twice (clauses only) |
change? | "insert" | "delete" | Tracked insertion or deletion of the whole block |
comment? | string (max 40 chars) | Id of a comment in comments anchored to the whole block |
blocks[] kind: "table"
| Field | Type | Description |
|---|---|---|
kind | "table" | |
columns | string[] (at least 1, at most 12) | Header row |
rows | ((string | number | null)[])[] (at least 1, at most 500) | |
align? | ("left" | "center" | "right")[] | Per-column alignment; numbers default right |
caption? | string (max 200 chars) | One short line under the table: source, assumption or how to read it |
total? | boolean | string | Adds a totals row the compiler computes: figure columns summed, a placeholder column gets [[Total <column>]]. A string is the row label |
currency? | string (max 8 chars) | Money columns: ISO code (EUR, USD) or symbol; number cells show it in the document language's format, e.g. 1.200 € |
rowChanges? | ("insert" | "delete" | null)[] | Tracked insertion or deletion per body row, null for unchanged |
blocks[] kind: "pageBreak"
| Field | Type | Description |
|---|---|---|
kind | "pageBreak" |
blocks[] kind: "toc"
| Field | Type | Description |
|---|---|---|
kind | "toc" | |
title? | string (max 80 chars) | Heading above the table; default "Contents" in the document language |
levels? | 1 | 2 | 3 | Heading levels it lists |
blocks[] kind: "image"
| Field | Type | Description |
|---|---|---|
kind | "image" | |
src | string | data: URI (PNG, JPEG or SVG), https URL or asset:<id> the caller resolves |
alt | string (max 255 chars) | Alt text, required for accessibility |
width? | number (min 10, max 100) | Percent of the text width; default the image's own size, at most the text width |
caption? | string (max 300 chars) | Caption under the image, numbered "Figure 1: ..." |
fallback? | string | SVG only: PNG data: URI for applications that cannot show SVG; drawn from the SVG when omitted |
bookmark? | string (max 40 chars) | Id of a comment in comments anchored to the whole block |
blocks[] kind: "section"
| Field | Type | Description |
|---|---|---|
kind | "section" | |
orientation? | "portrait" | "landscape" | Default: the orientation of the section before |
header? | string (max 200 chars) | Default: the header of the section before |
footer? | string (max 200 chars) | Default: the footer of the section before |
firstPage? | object | A different first page of the section (blank when the text is omitted) |
blocks[].firstPage
A different first page of the section (blank when the text is omitted)
| Field | Type | Description |
|---|---|---|
header? | string (max 200 chars) | |
footer? | string (max 200 chars) |
blocks[] kind: "definitions"
| Field | Type | Description |
|---|---|---|
kind | "definitions" | |
items | object[] (at least 1, at most 200) |
blocks[].items[]
| Field | Type | Description |
|---|---|---|
term | string (max 120 chars) | |
text | string | (string | object)[] |