STEP 2 OF 2 after `draft_user_template`. Two ways to call it:
SIGNED-OFF (the normal path): pass `draft_id` and the `variant_id` the user chose
from the previews. The EXACT treatment they looked at is stored — no second
adaptation pass that could produce something they never saw. `template`,
`template_type` and `anchor` are taken from the draft and may be omitted. A 404
means the draft expired (24h) or the variant does not exist: draft again.
DIRECT (no previews): pass `template` + `template_type` (+ `anchor` for an
add_on) — only when the user explicitly wants to skip the previews. An add_on
saved this way still gets an unreviewed harmonise pass, so prefer the signed-off
path for anything visual. HTML only: markdown is rejected with a 422.
ONE TEMPLATE PER USER — this is an UPSERT: saving replaces whatever was saved
before, with no history. Call `get_user_template` first and confirm with the user
before overwriting an existing format. To change a saved format afterwards, use
`update_user_template` (any field, or none to recompile it as stored).
WHAT CHANGES AFTERWARDS: the backend renders every PDF it builds for this user —
`get_latest_report` renders of fresh plans, `generate_report_for_stock` rebuilds
(standard and custom) and scheduled reports — through the saved format. The template is a blueprint (stylesheet, page chrome, one
pattern per content kind) applied to the document's own content: nothing is
filled in by hand, and no other call changes. When you compose a PDF yourself
from Flexreport data, `get_user_template` returns the markup to lay it out in.
Asynchronous: returns {"task_id", "status": "PENDING", "next_step"}. Poll
`get_task_status(task_id)`; the finished result is {"status": "SAVED",
"template_type", "anchor", "bytes", "patterns": [content kinds the design styles],
"tones": {positive | negative | neutral | accent: css class}, "warnings"}. Tell
the user which content kinds their design styles. A warning "keeping the
previously compiled blueprint" means the new compile was rejected and the
previous blueprint stays in force; the markup itself is still saved. Validation
failures are a 422 with `detail.errors` listing each problem.
Requires auth (your MCP client attaches the OAuth bearer automatically).
Rate-limited 100/min.