Update a Word template

Markdown
PATCH /v1/document-templates/{template_id}

Edit a saved template’s text, paragraph structure, or report formatting. Read the current template first, then send expected_revision and the changes you want to apply. A successful save creates a new revision and returns its updated paragraph IDs and formatting.

A stale revision returns 409 without applying your changes. Read the latest template and review how to combine the edits before retrying. Paragraph IDs and text offsets must come from the revision you are editing.

Replace text precisely

edits contains a paragraph id, start, end, and replacement text. Text-edit offsets count Unicode characters; end is exclusive. For example, start 0 and end 5 replace the first five characters. Use equal start and end to insert text, or an empty replacement string to remove selected text. JavaScript string indexes count UTF-16 code units, so convert indexes when text includes characters outside the basic multilingual plane.

Delete, move, or remove a break

operations can delete eligible paragraphs, move a paragraph before another within its safe move_group, or remove page and column breaks. A move with before_id omitted or null places the paragraph at the end of its group. Break offsets refer to the original revision; page_break_before has no offset. Text edits are applied before structural operations. The whole update is rejected if an operation is invalid.

Save report formatting

Omitted spacing keeps the saved formatting. A supplied spacing object replaces the formatting options: include the saved values you want to preserve. Blank-paragraph options accept true or false. Bold, underline, italic, and bullet options accept true, false, or null to inherit the template. An omitted option inside a supplied spacing object resets to its default.

Formatting applies to generated Findings and Impression text. Headings, surrounding text, images, and other document formatting retain their existing appearance. The API examples below show formatting-only changes as well as text edits and paragraph operations.

Working with Word templates

Authentication

Create a named API key in your workspace’s API keys tab, then send it in the Authorization header on each API request. Your key connects the integration to that workspace’s saved settings and Word templates. Signing into the website does not replace this header in an API integration.

Authorization: Bearer <API_KEY>

Keep the key in your application’s server-side secret configuration. It is shown only once when created, so save it securely then. Do not place it in browser code, logs, version control, or a prompt sent to your coding agent. You can revoke an integration’s key from the workspace without changing the other keys.

Parameters

NameTypeRequiredConstraintsDescription
template_idpath: stringYespattern="^[a-f0-9]{32}$"—

Request

application/json
NameTypeRequiredConstraintsDescription
expected_revisionintegerYesminimum=1.0Current revision returned by reading the template. Prevents overwriting another saved edit.
editsarray<ParagraphEdit>NomaxItems=2000Text replacements using paragraph IDs and Unicode-character offsets from the expected revision. end is exclusive.
operationsarray<DeleteParagraph | MoveParagraph | RemoveBreak>NomaxItems=2000Ordered paragraph deletions, moves, or page/column break removals applied after text edits.
spacingReportFormatting | nullNo—Report formatting overrides. Omit to preserve saved controls. A supplied object replaces all controls; include values you want to keep. The object cannot be null.

Request examples

{
  "expected_revision": 1,
  "spacing": {
    "findings_blank_paragraph": false,
    "findings_bold": true,
    "impression_blank_paragraph": false,
    "impression_bold": true
  }
}
{
  "edits": [
    {
      "end": 0,
      "id": "word/document.xml#0",
      "start": 0,
      "text": "{{ exam_title }}"
    }
  ],
  "expected_revision": 1
}
{
  "expected_revision": 1,
  "operations": [
    {
      "id": "word/document.xml#1",
      "operation": "delete"
    }
  ]
}
{
  "expected_revision": 1,
  "operations": [
    {
      "before_id": "word/document.xml#1",
      "id": "word/document.xml#2",
      "operation": "move"
    }
  ]
}
{
  "expected_revision": 1,
  "operations": [
    {
      "id": "word/document.xml#1",
      "kind": "page_break",
      "offset": 12,
      "operation": "remove_break"
    }
  ]
}

Example

BASE_URL=https://radiologydictation.com

curl --request PATCH "$BASE_URL/v1/document-templates/$TEMPLATE_ID" \
  --header "Authorization: Bearer $API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"expected_revision": 1, "spacing": {"findings_blank_paragraph": false, "findings_bold": true, "impression_blank_paragraph": false, "impression_bold": true}}'

Responses

StatusDescriptionType
200Successful ResponseTemplateDetail · application/json
401Invalid or missing API keyobject · application/json
429Too many attempts. Please try again later.object · application/json
503Service is unavailable. Please try again.object · application/json
404Template not found.object · application/json
409Template changed. Reload it before saving.object · application/json
413Word template exceeds the configured limits.object · application/json
422Invalid Word template.object · application/json
415JSON request required.object · application/json

Response headers · 429

HeaderTypeDescription
Retry-Afterstring—

Schemas

DeleteParagraph

NameTypeRequiredConstraintsDescription
operationstringYes——
idstringYesmaxLength=200—

MoveParagraph

NameTypeRequiredConstraintsDescription
operationstringYes——
idstringYesmaxLength=200—
before_idstring | nullNo——

Paragraph

NameTypeRequiredConstraintsDescription
idstringYes——
textstringYes——
editablebooleanYes——
deletablebooleanNodefault=false—
move_groupstring | nullNo——
markersarray<ParagraphMarker>No——

ParagraphEdit

NameTypeRequiredConstraintsDescription
idstringYesmaxLength=200—
startintegerYesminimum=0.0—
endintegerYesminimum=0.0—
textstringYesmaxLength=20000—

ParagraphMarker

NameTypeRequiredConstraintsDescription
kindstringYesenum=["page_break", "page_break_before", "column_break", "section_break", "image", "field", "anchor", "table_cell", "protected_structure"]—
positionstringYesenum=["before", "within", "after"]—
offsetinteger | nullNo——
section_typestring | nullNo——

RemoveBreak

NameTypeRequiredConstraintsDescription
operationstringYes——
idstringYesmaxLength=200—
kindstringYesenum=["page_break", "column_break", "page_break_before"]—
offsetinteger | nullNo——

ReportFormatting

NameTypeRequiredConstraintsDescription
findings_blank_paragraphbooleanNodefault=false—
impression_blank_paragraphbooleanNodefault=false—
findings_bulletedboolean | nullNo——
impression_bulletedboolean | nullNo——
findings_boldboolean | nullNo——
findings_underlineboolean | nullNo——
findings_italicboolean | nullNo——
impression_boldboolean | nullNo——
impression_underlineboolean | nullNo——
impression_italicboolean | nullNo——

TemplateDetail

NameTypeRequiredConstraintsDescription
idstringYes——
namestringYes——
revisionintegerYes——
created_atstring (date-time)Yes——
updated_atstring (date-time)Yes——
paragraphsarray<Paragraph>Yes——
placeholdersarray<string>Yes——
spacingReportFormattingNo——
bulleted_placeholdersarray<string>No——
placeholder_formattingobjectNo——

TemplateUpdate

NameTypeRequiredConstraintsDescription
expected_revisionintegerYesminimum=1.0Current revision returned by reading the template. Prevents overwriting another saved edit.
editsarray<ParagraphEdit>NomaxItems=2000Text replacements using paragraph IDs and Unicode-character offsets from the expected revision. end is exclusive.
operationsarray<DeleteParagraph | MoveParagraph | RemoveBreak>NomaxItems=2000Ordered paragraph deletions, moves, or page/column break removals applied after text edits.
spacingReportFormatting | nullNo—Report formatting overrides. Omit to preserve saved controls. A supplied object replaces all controls; include values you want to keep. The object cannot be null.

TextFormatting

NameTypeRequiredConstraintsDescription
boldbooleanNodefault=false—
underlinebooleanNodefault=false—
italicbooleanNodefault=false—

Select and copy