{
  "components": {
    "schemas": {
      "BindSnippetBody": {
        "description": "Bind a composition snippet to a document (mirrors `cmd_bind_snippet`'s\npayload). `entityBindings` maps a role to an entity id; `ordinal` omitted \u2192\nappended after the current last binding.",
        "properties": {
          "entityBindings": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Entitybindings"
          },
          "ordinal": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ordinal"
          },
          "snippetId": {
            "title": "Snippetid",
            "type": "string"
          }
        },
        "required": [
          "snippetId"
        ],
        "title": "BindSnippetBody",
        "type": "object"
      },
      "CreateDocumentBody": {
        "properties": {
          "fields": {
            "additionalProperties": true,
            "title": "Fields",
            "type": "object"
          },
          "templateId": {
            "title": "Templateid",
            "type": "string"
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Title"
          }
        },
        "required": [
          "templateId"
        ],
        "title": "CreateDocumentBody",
        "type": "object"
      },
      "CreateRiskBlockBody": {
        "description": "A new org-scoped Risk Block (approval-gated Section-III analysis unit).\n\n`key` / `heading` / `template` are required (the bridge rejects blanks with a\n422); `status` defaults to `draft` (only `draft` | `approved` are valid).\n`statutoryRef` / `appliesTo` are optional metadata.",
        "properties": {
          "appliesTo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Appliesto"
          },
          "heading": {
            "title": "Heading",
            "type": "string"
          },
          "key": {
            "title": "Key",
            "type": "string"
          },
          "status": {
            "default": "draft",
            "title": "Status",
            "type": "string"
          },
          "statutoryRef": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statutoryref"
          },
          "template": {
            "title": "Template",
            "type": "string"
          }
        },
        "required": [
          "key",
          "heading",
          "template"
        ],
        "title": "CreateRiskBlockBody",
        "type": "object"
      },
      "CreateSectionBody": {
        "description": "New-section fields (mirrors `cmd_create_section`'s payload keys).\n\n`title` is required. Only the keys the caller sends are forwarded \u2014 omitted\nkeys fall back to the section defaults (`render_mode='synthesized'`,\n`output_type='string'`). A title-only body routes to the legacy\n`cmd_create_section_title` command; any config field present routes to the\nfull `cmd_create_section`.",
        "properties": {
          "output_template": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Output Template"
          },
          "output_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Output Type"
          },
          "prompt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt"
          },
          "render_mode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Render Mode"
          },
          "title": {
            "title": "Title",
            "type": "string"
          }
        },
        "required": [
          "title"
        ],
        "title": "CreateSectionBody",
        "type": "object"
      },
      "CreateSnapshotBody": {
        "description": "Optional label for a manual snapshot; omit for an auto `Version N`.",
        "properties": {
          "label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Label"
          }
        },
        "title": "CreateSnapshotBody",
        "type": "object"
      },
      "CreateTextBody": {
        "description": "A new Text (phrase atom). `key` + `value` are required; `valueType`\ndefaults to a plain string, and the R2 structured-content fields\n(heading/narrative templates, bullets, entity roles) are optional.",
        "properties": {
          "bullets": {
            "items": {
              "type": "string"
            },
            "title": "Bullets",
            "type": "array"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "entityRolesUsed": {
            "items": {
              "type": "string"
            },
            "title": "Entityrolesused",
            "type": "array"
          },
          "headingTemplate": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Headingtemplate"
          },
          "key": {
            "title": "Key",
            "type": "string"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "narrativeTemplate": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Narrativetemplate"
          },
          "value": {
            "title": "Value",
            "type": "string"
          },
          "valueType": {
            "default": "string",
            "title": "Valuetype",
            "type": "string"
          }
        },
        "required": [
          "key",
          "value"
        ],
        "title": "CreateTextBody",
        "type": "object"
      },
      "CreateToolRegistrationBody": {
        "description": "A tool registration to persist for the active org. Credentials are NEVER\naccepted or stored (T-decision-9) \u2014 `configJson` is non-secret config only;\nsolutions inject secrets as constructor kwargs at register time.",
        "properties": {
          "category": {
            "title": "Category",
            "type": "string"
          },
          "classPath": {
            "title": "Classpath",
            "type": "string"
          },
          "configJson": {
            "additionalProperties": true,
            "title": "Configjson",
            "type": "object"
          },
          "name": {
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "name",
          "category",
          "classPath"
        ],
        "title": "CreateToolRegistrationBody",
        "type": "object"
      },
      "CreateVoiceBody": {
        "description": "A new org-scoped writing-style Voice. `name` is required and unique per\norg; `description` is the human-authored style rubric; `samples` are optional\nexample passages. Mirrors `cmd_create_voice`'s payload shape.",
        "properties": {
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "name": {
            "title": "Name",
            "type": "string"
          },
          "samples": {
            "items": {
              "type": "string"
            },
            "title": "Samples",
            "type": "array"
          }
        },
        "required": [
          "name"
        ],
        "title": "CreateVoiceBody",
        "type": "object"
      },
      "DataNeedCreateBody": {
        "description": "A new data-need's fields (mirrors `cmd_create_data_need`'s payload).\n\n`kind` + `output_key` are required (the command rejects a payload without\nthem); the rest are kind-specific and optional. Only non-null keys are\nforwarded, so omitted optionals fall to the command/model defaults.",
        "properties": {
          "args_json": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Args Json"
          },
          "depends_on": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Depends On"
          },
          "kind": {
            "title": "Kind",
            "type": "string"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "output_key": {
            "title": "Output Key",
            "type": "string"
          },
          "prompt_body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt Body"
          },
          "tool_ref": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tool Ref"
          },
          "tools_available": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tools Available"
          }
        },
        "required": [
          "kind",
          "output_key"
        ],
        "title": "DataNeedCreateBody",
        "type": "object"
      },
      "DataNeedUpdateBody": {
        "description": "Mutable data-need fields (mirrors `cmd_update_data_need`'s payload). Only\nthe keys the caller sends are forwarded \u2014 omitted keys are left untouched.",
        "properties": {
          "args_json": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Args Json"
          },
          "depends_on": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Depends On"
          },
          "kind": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Kind"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "output_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Output Key"
          },
          "prompt_body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt Body"
          },
          "tool_ref": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tool Ref"
          },
          "tools_available": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tools Available"
          }
        },
        "title": "DataNeedUpdateBody",
        "type": "object"
      },
      "DeleteFieldResponse": {
        "description": "The `DELETE \u2026/fields/{field_id}` body \u2014 mirrors `cmd_delete_field`'s\n`{'ok': True}` return.",
        "properties": {
          "ok": {
            "title": "Ok",
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "DeleteFieldResponse",
        "type": "object"
      },
      "DeleteSnapshotResponse": {
        "description": "The `200` body for a snapshot delete \u2014 mirrors `cmd_delete_snapshot`'s\n``{'ok': True}`` return.",
        "properties": {
          "ok": {
            "title": "Ok",
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "DeleteSnapshotResponse",
        "type": "object"
      },
      "FieldModel": {
        "description": "One per-document field row as returned by `cmd_list_fields`.\n\nMirrors `docgen.specs.FieldSummary`'s serialized shape (camelCase aliases\nalready applied by the bridge payload), so this is a faithful no-op filter.",
        "properties": {
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "id": {
            "title": "Id",
            "type": "string"
          },
          "isRequired": {
            "default": false,
            "title": "Isrequired",
            "type": "boolean"
          },
          "key": {
            "title": "Key",
            "type": "string"
          },
          "label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Label"
          },
          "value": {
            "title": "Value",
            "type": "string"
          },
          "valueType": {
            "default": "string",
            "title": "Valuetype",
            "type": "string"
          }
        },
        "required": [
          "id",
          "key",
          "value"
        ],
        "title": "FieldModel",
        "type": "object"
      },
      "FieldsBody": {
        "properties": {
          "fields": {
            "additionalProperties": true,
            "title": "Fields",
            "type": "object"
          }
        },
        "required": [
          "fields"
        ],
        "title": "FieldsBody",
        "type": "object"
      },
      "FieldsResponse": {
        "description": "The `GET \u2026/fields` body \u2014 the document's field rows (keyed, with a\nstable `id` a client targets for delete). Empty list when the document has\nno fields.",
        "properties": {
          "fields": {
            "items": {
              "$ref": "#/components/schemas/FieldModel"
            },
            "title": "Fields",
            "type": "array"
          }
        },
        "title": "FieldsResponse",
        "type": "object"
      },
      "GatherBody": {
        "properties": {
          "refresh": {
            "default": false,
            "title": "Refresh",
            "type": "boolean"
          },
          "variables": {
            "additionalProperties": true,
            "title": "Variables",
            "type": "object"
          }
        },
        "title": "GatherBody",
        "type": "object"
      },
      "GenerateBody": {
        "properties": {
          "force": {
            "default": false,
            "title": "Force",
            "type": "boolean"
          },
          "preserveEdited": {
            "default": false,
            "title": "Preserveedited",
            "type": "boolean"
          },
          "variables": {
            "additionalProperties": true,
            "title": "Variables",
            "type": "object"
          }
        },
        "title": "GenerateBody",
        "type": "object"
      },
      "GenerateConflictDetail": {
        "description": "The `detail` payload of the generate `409` (confirm-before-overwrite).\n\nMirrors exactly what the handler raises when a document has hand-edited\nsections and the caller omitted both `force` and `preserveEdited`. Carries\nthe edited section titles so a client can name them in a confirm prompt.",
        "properties": {
          "blockedEdited": {
            "description": "Always `true`: the run was blocked to protect hand edits.",
            "title": "Blockededited",
            "type": "boolean"
          },
          "editedSectionTitles": {
            "description": "Titles of the hand-edited sections a run would overwrite.",
            "items": {
              "type": "string"
            },
            "title": "Editedsectiontitles",
            "type": "array"
          }
        },
        "required": [
          "blockedEdited"
        ],
        "title": "GenerateConflictDetail",
        "type": "object"
      },
      "GenerateConflictResponse": {
        "description": "The `409` body for `generate` \u2014 a FastAPI `HTTPException` wraps the raised\ndetail under a top-level `detail` key.",
        "properties": {
          "detail": {
            "$ref": "#/components/schemas/GenerateConflictDetail"
          }
        },
        "required": [
          "detail"
        ],
        "title": "GenerateConflictResponse",
        "type": "object"
      },
      "GenerateResponse": {
        "properties": {
          "alreadyRunning": {
            "title": "Alreadyrunning",
            "type": "boolean"
          },
          "documentId": {
            "title": "Documentid",
            "type": "string"
          },
          "progressUrl": {
            "title": "Progressurl",
            "type": "string"
          },
          "started": {
            "title": "Started",
            "type": "boolean"
          }
        },
        "required": [
          "started",
          "alreadyRunning",
          "documentId",
          "progressUrl"
        ],
        "title": "GenerateResponse",
        "type": "object"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "title": "Detail",
            "type": "array"
          }
        },
        "title": "HTTPValidationError",
        "type": "object"
      },
      "LlmStatusResponse": {
        "properties": {
          "gatherModel": {
            "title": "Gathermodel",
            "type": "string"
          },
          "mode": {
            "title": "Mode",
            "type": "string"
          },
          "model": {
            "title": "Model",
            "type": "string"
          },
          "synthesisModel": {
            "title": "Synthesismodel",
            "type": "string"
          }
        },
        "required": [
          "mode",
          "model",
          "gatherModel",
          "synthesisModel"
        ],
        "title": "LlmStatusResponse",
        "type": "object"
      },
      "OrchestrateBody": {
        "description": "The input source (e.g. an instruction letter) to orchestrate from.",
        "properties": {
          "source_text": {
            "title": "Source Text",
            "type": "string"
          }
        },
        "required": [
          "source_text"
        ],
        "title": "OrchestrateBody",
        "type": "object"
      },
      "OrgSummary": {
        "properties": {
          "active": {
            "title": "Active",
            "type": "boolean"
          },
          "displayName": {
            "title": "Displayname",
            "type": "string"
          },
          "slug": {
            "title": "Slug",
            "type": "string"
          }
        },
        "required": [
          "slug",
          "displayName",
          "active"
        ],
        "title": "OrgSummary",
        "type": "object"
      },
      "OrgsResponse": {
        "properties": {
          "activeSlug": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Activeslug"
          },
          "orgs": {
            "items": {
              "$ref": "#/components/schemas/OrgSummary"
            },
            "title": "Orgs",
            "type": "array"
          }
        },
        "title": "OrgsResponse",
        "type": "object"
      },
      "PromptAssistBody": {
        "description": "Input to POST /v1/prompt-assist. A blank prompt is a 422 (the underlying\ncmd raises ValidationError); topic optionally frames the rewrite.",
        "properties": {
          "prompt": {
            "title": "Prompt",
            "type": "string"
          },
          "topic": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Topic"
          }
        },
        "required": [
          "prompt"
        ],
        "title": "PromptAssistBody",
        "type": "object"
      },
      "PromptAssistResponse": {
        "properties": {
          "mode": {
            "title": "Mode",
            "type": "string"
          },
          "prompt": {
            "title": "Prompt",
            "type": "string"
          }
        },
        "required": [
          "prompt",
          "mode"
        ],
        "title": "PromptAssistResponse",
        "type": "object"
      },
      "RegenerateBody": {
        "properties": {
          "variables": {
            "additionalProperties": true,
            "title": "Variables",
            "type": "object"
          }
        },
        "title": "RegenerateBody",
        "type": "object"
      },
      "ReorderSectionsBody": {
        "description": "The complete, deduplicated ordering of a document's section ids. Must\ncover the document's sections exactly once (the cmd rejects a partial or\nforeign set with a 422).",
        "properties": {
          "sectionIds": {
            "items": {
              "type": "string"
            },
            "title": "Sectionids",
            "type": "array"
          }
        },
        "required": [
          "sectionIds"
        ],
        "title": "ReorderSectionsBody",
        "type": "object"
      },
      "SectionEditBody": {
        "description": "Mutable section fields (mirrors `cmd_update_section`'s payload). Only the\nkeys the caller sends are forwarded \u2014 omitted keys are left untouched.",
        "properties": {
          "content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content"
          },
          "output_template": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Output Template"
          },
          "output_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Output Type"
          },
          "prompt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt"
          },
          "render_mode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Render Mode"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Title"
          }
        },
        "title": "SectionEditBody",
        "type": "object"
      },
      "SectionOutputBody": {
        "description": "A hand-edited rendered output body for one section. Applying it sets the\nsection status to `edited` and records a new section-output version.",
        "properties": {
          "content": {
            "title": "Content",
            "type": "string"
          }
        },
        "required": [
          "content"
        ],
        "title": "SectionOutputBody",
        "type": "object"
      },
      "SetSnippetItemsBody": {
        "description": "Replace the snippet's items with this ordered list (ordinals assigned\n0..N-1 in array order). An empty list clears the snippet's items.",
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/SnippetItemInput"
            },
            "title": "Items",
            "type": "array"
          }
        },
        "title": "SetSnippetItemsBody",
        "type": "object"
      },
      "SnippetCreateBody": {
        "description": "Create a composition Snippet. A snippet is metadata + ordered items\n(R2 A3b) \u2014 there is no flat body here; membership is set via\n`PUT /v1/snippets/{id}/items`.",
        "properties": {
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "key": {
            "title": "Key",
            "type": "string"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "phaseOrder": {
            "default": 0,
            "title": "Phaseorder",
            "type": "integer"
          }
        },
        "required": [
          "key"
        ],
        "title": "SnippetCreateBody",
        "type": "object"
      },
      "SnippetItemInput": {
        "description": "One ordered member of a composition snippet. `itemType` is `'text'` or\n`'risk_block'` (validated in `cmd_set_snippet_items`).",
        "properties": {
          "itemKey": {
            "title": "Itemkey",
            "type": "string"
          },
          "itemType": {
            "title": "Itemtype",
            "type": "string"
          }
        },
        "required": [
          "itemType",
          "itemKey"
        ],
        "title": "SnippetItemInput",
        "type": "object"
      },
      "SnippetUpdateBody": {
        "description": "Mutable snippet metadata (mirrors `cmd_update_snippet`'s payload). Only the\nkeys the caller sends are forwarded \u2014 omitted keys are left untouched.",
        "properties": {
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Key"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "phaseOrder": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phaseorder"
          }
        },
        "title": "SnippetUpdateBody",
        "type": "object"
      },
      "StateBody": {
        "properties": {
          "state": {
            "title": "State",
            "type": "string"
          }
        },
        "required": [
          "state"
        ],
        "title": "StateBody",
        "type": "object"
      },
      "SynthesisHistoryResponse": {
        "description": "`GET \u2026/synthesis/history` \u2014 every synthesized context for the document,\nnewest first (one entry per synthesize run).",
        "properties": {
          "synthesizedContexts": {
            "items": {
              "$ref": "#/components/schemas/SynthesizedContext"
            },
            "title": "Synthesizedcontexts",
            "type": "array"
          }
        },
        "title": "SynthesisHistoryResponse",
        "type": "object"
      },
      "SynthesisResponse": {
        "description": "`GET \u2026/synthesis` \u2014 the latest synthesized context, or `null` when the\ndocument has not been synthesized yet.",
        "properties": {
          "synthesizedContext": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SynthesizedContext"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "title": "SynthesisResponse",
        "type": "object"
      },
      "SynthesizedContext": {
        "description": "One `synthesized_context` row as returned by `cmd_get_synthesis` /\n`cmd_list_synthesis`.\n\nMirrors `docgen.specs.SynthesizedContextSummary` dumped with `by_alias=True`:\nthe keys are ALREADY camelCase on the wire, so the fields are named to match\nand carry no alias. `model` is a bare field name (no `model_` protected-\nnamespace clash \u2014 `SynthesizedContextSummary` uses it the same way).",
        "properties": {
          "createdAt": {
            "title": "Createdat",
            "type": "string"
          },
          "id": {
            "title": "Id",
            "type": "string"
          },
          "mode": {
            "title": "Mode",
            "type": "string"
          },
          "model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Model"
          },
          "payloadJson": {
            "title": "Payloadjson"
          },
          "schemaPath": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Schemapath"
          }
        },
        "required": [
          "id",
          "mode",
          "createdAt"
        ],
        "title": "SynthesizedContext",
        "type": "object"
      },
      "TidyTemplateBody": {
        "description": "Input to POST /v1/jinja/tidy - the raw Jinja template text to indent.",
        "properties": {
          "template": {
            "title": "Template",
            "type": "string"
          }
        },
        "required": [
          "template"
        ],
        "title": "TidyTemplateBody",
        "type": "object"
      },
      "TidyTemplateResponse": {
        "properties": {
          "tidied": {
            "title": "Tidied",
            "type": "string"
          }
        },
        "required": [
          "tidied"
        ],
        "title": "TidyTemplateResponse",
        "type": "object"
      },
      "UpdateDocumentBody": {
        "description": "Partial update of a document's mutable header/lifecycle fields (PATCH).\n\nOnly the keys the caller SENDS are applied \u2014 an omitted key is left\nuntouched (PATCH semantics via ``exclude_unset``); this is why every field\ndefaults to ``None`` yet a bare ``None`` is not conflated with \"omitted\".\n``title`` must be a non-empty string (the bridge rejects blank/whitespace\nwith a 422); ``description`` may be sent as ``null`` to clear it;\n``isTemplate`` promotes (``true``) or demotes (``false``) the row between\ntemplate and instance. Mirrors the mutable fields owned by\n``cmd_update_document_title`` / ``cmd_update_document_description`` /\n``cmd_set_document_template``.",
        "properties": {
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "isTemplate": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Istemplate"
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Title"
          }
        },
        "title": "UpdateDocumentBody",
        "type": "object"
      },
      "UpdateDocumentSnippetBody": {
        "description": "Mutable binding fields (mirrors `cmd_update_document_snippet`). Only the\nkeys the caller sends are forwarded \u2014 omitted keys are left untouched.",
        "properties": {
          "entityBindings": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Entitybindings"
          },
          "ordinal": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ordinal"
          }
        },
        "title": "UpdateDocumentSnippetBody",
        "type": "object"
      },
      "UpdateRiskBlockBody": {
        "description": "Mutable Risk Block fields (mirrors `cmd_update_risk_block`'s payload). Only\nthe keys the caller sends are forwarded \u2014 omitted keys are left untouched.",
        "properties": {
          "appliesTo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Appliesto"
          },
          "heading": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Heading"
          },
          "key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Key"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "statutoryRef": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statutoryref"
          },
          "template": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Template"
          }
        },
        "title": "UpdateRiskBlockBody",
        "type": "object"
      },
      "UpdateTextBody": {
        "description": "Mutable Text fields \u2014 a partial patch. Only the keys the caller sends\nare forwarded to `cmd_update_text`; omitted keys are left untouched\n(mirrors the bridge command's per-key `if k in payload` semantics, so an\nexplicit `null` on a nullable field clears it while an absent field does\nnot).",
        "properties": {
          "bullets": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Bullets"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "entityRolesUsed": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Entityrolesused"
          },
          "headingTemplate": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Headingtemplate"
          },
          "key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Key"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "narrativeTemplate": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Narrativetemplate"
          },
          "value": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Value"
          },
          "valueType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Valuetype"
          }
        },
        "title": "UpdateTextBody",
        "type": "object"
      },
      "UpdateVoiceBody": {
        "description": "Partial patch for a Voice (mirrors `cmd_update_voice`). Only the keys the\ncaller actually sends are forwarded \u2014 omitted keys are left untouched.\n`description` may be sent as `null` to clear it (distinct from omitting it).",
        "properties": {
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "samples": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Samples"
          }
        },
        "title": "UpdateVoiceBody",
        "type": "object"
      },
      "ValidationError": {
        "properties": {
          "ctx": {
            "title": "Context",
            "type": "object"
          },
          "input": {
            "title": "Input"
          },
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "title": "Location",
            "type": "array"
          },
          "msg": {
            "title": "Message",
            "type": "string"
          },
          "type": {
            "title": "Error Type",
            "type": "string"
          }
        },
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError",
        "type": "object"
      },
      "WhoamiResponse": {
        "properties": {
          "activeOrg": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Activeorg"
          },
          "user": {
            "$ref": "#/components/schemas/WhoamiUser"
          }
        },
        "required": [
          "user"
        ],
        "title": "WhoamiResponse",
        "type": "object"
      },
      "WhoamiUser": {
        "properties": {
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "organizations": {
            "items": {
              "type": "string"
            },
            "title": "Organizations",
            "type": "array"
          }
        },
        "title": "WhoamiUser",
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "bearerFormat": "JWT",
        "description": "Bearer JWT required on every `/v1` request. Deployed: an Azure-AD (Entra) user token. Local dev: a real RS256 token from `POST /auth/dev-login`. See docs/reference/v1-api.md#authentication.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "The headless DocGen Platform API. A thin, versioned REST layer over the DocGen engine: instantiate templates, configure documents, generate, stream progress, and export `.docx`. See `docs/reference/v1-api.md` for the integrator guide and `docs/reference/versioning.md` for the stability policy.",
    "title": "AltaForge DocGen Platform API",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/config-schema": {
      "get": {
        "description": "The authoring spec's JSON schema (for `POST`/`PUT /templates`, `PUT \u2026/spec`)\nplus the `PUT \u2026/config` object's group keys \u2014 so an agent or UX discovers\nevery configurable field and allowed value without reading source.",
        "operationId": "config_schema_v1_config_schema_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Config Schema V1 Config Schema Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Self-describing config surface \u2014 spec JSON schema + config groups",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents": {
      "get": {
        "operationId": "list_documents_v1_documents_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Documents V1 Documents Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List the caller-org document instances (+ field values)",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_document_v1_documents_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Document V1 Documents Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Instantiate a template into a new document",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}": {
      "delete": {
        "description": "Delete a document and everything it owns (sections + data-needs cascade in\nthe data layer). Returns ``{'ok': True}``. A missing/out-of-scope id is a\n404 (never 403 \u2014 no org enumeration), mapped from the bridge cmd's\n``NotFoundError`` by ``_run``.",
        "operationId": "delete_document_v1_documents__document_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Document V1 Documents  Document Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete a document (cascades to its sections + data needs)",
        "tags": [
          "v1"
        ]
      },
      "get": {
        "operationId": "get_document_v1_documents__document_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Document V1 Documents  Document Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "One document: header + sections (+ sources)",
        "tags": [
          "v1"
        ]
      },
      "patch": {
        "description": "Partially update a document's header/lifecycle fields. Only the keys the\ncaller sends are applied (PATCH semantics via ``exclude_unset``); an omitted\nkey is untouched, while an explicit ``null`` description clears it. Composes\nthe three single-field bridge cmds under one scoped context in a stable\norder, then returns the refreshed document (mirrors ``put_fields``). An\nempty body is a 422; an invalid value (e.g. a blank ``title``, mapped from\nthe bridge's ``ValidationError``) is a 422; a missing/out-of-scope document\nis a 404 \u2014 all via ``_run``'s domain-error mapping.",
        "operationId": "update_document_v1_documents__document_id__patch",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Document V1 Documents  Document Id  Patch"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Update a document (title / description / isTemplate; partial)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/computed": {
      "get": {
        "description": "Rebuild the compute stage from PERSISTED gathered rows (never dispatches a\ntool \u2014 a page load must not trigger web-search) and return\n`{computed, readiness, fns}`. A missing document is a 404: the command\nsignals it with an `{'error': ...}` dict, which `_unwrap` maps to 404.",
        "operationId": "inspect_computed_v1_documents__document_id__computed_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Inspect Computed V1 Documents  Document Id  Computed Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "The read-only Computed pipeline-stage panel (no tool dispatch)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/config": {
      "get": {
        "description": "The whole configurable state \u2014 models per step, synthesis/coordination,\nbrief, voice, verify, render options, tools, fields, sections \u2014 for a\ndocument or template. The read half of headless config.",
        "operationId": "get_config_v1_documents__document_id__config_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Config V1 Documents  Document Id  Config Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Read the full document/template config object",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "description": "Apply a partial config patch \u2014 only the groups/keys in the body change \u2014\nand return the resolved config. Works on templates and instances; the next\ngenerate run reads the written fields.",
        "operationId": "put_config_v1_documents__document_id__config_put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "title": "Body",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Put Config V1 Documents  Document Id  Config Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Patch the document/template config (atomic, partial)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/data-needs": {
      "get": {
        "operationId": "list_data_needs_v1_documents__document_id__data_needs_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Data Needs V1 Documents  Document Id  Data Needs Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "List the document data-needs (source actions), in ordinal order",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_data_need_v1_documents__document_id__data_needs_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataNeedCreateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Data Need V1 Documents  Document Id  Data Needs Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Create a data-need on a document",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/data-needs/{need_id}": {
      "delete": {
        "operationId": "delete_data_need_v1_documents__document_id__data_needs__need_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "need_id",
            "required": true,
            "schema": {
              "title": "Need Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Data Need V1 Documents  Document Id  Data Needs  Need Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete a data-need",
        "tags": [
          "v1"
        ]
      },
      "get": {
        "operationId": "get_data_need_v1_documents__document_id__data_needs__need_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "need_id",
            "required": true,
            "schema": {
              "title": "Need Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Data Need V1 Documents  Document Id  Data Needs  Need Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Get one data-need by id",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "operationId": "update_data_need_v1_documents__document_id__data_needs__need_id__put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "need_id",
            "required": true,
            "schema": {
              "title": "Need Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataNeedUpdateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Data Need V1 Documents  Document Id  Data Needs  Need Id  Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Patch a data-need (partial; omitted keys untouched)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/data-needs/{need_id}/gather": {
      "post": {
        "description": "Run the source lane for ONE data-need only (no synthesize/render LLM step)\nand return the gathered payload. Reuses `_scoped`, so in per-user MCP mode the\ncaller's identity forwards to the source servers \u2014 the returned payloads then\ncarry the server's per-user marker. `cmd_gather_for_data_need` signals a\nmissing need with an `{'error': ...}` dict, so `_unwrap` maps it to a 404.",
        "operationId": "gather_data_need_v1_documents__document_id__data_needs__need_id__gather_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "need_id",
            "required": true,
            "schema": {
              "title": "Need Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GatherBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Gather Data Need V1 Documents  Document Id  Data Needs  Need Id  Gather Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Run gather for a single data-need; return its source data (no LLM synth)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/export.docx": {
      "get": {
        "operationId": "export_docx_v1_documents__document_id__export_docx_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The composed document as a binary `.docx` file."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Download the composed .docx",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/export.md": {
      "get": {
        "description": "Compose the whole document to Markdown. A missing document is a 404\n(cmd_download_markdown signals not-found with an {'error': ...} dict, which\n_unwrap maps, exactly like export.docx).",
        "operationId": "export_markdown_v1_documents__document_id__export_md_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The composed document as a Markdown text file."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Download the composed document as Markdown",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/fields": {
      "get": {
        "description": "The read half of the fields surface: every field row for the document,\neach with its stable `id` for a subsequent `DELETE \u2026/fields/{field_id}`.",
        "operationId": "list_document_fields_v1_documents__document_id__fields_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldsResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "List a document's field values",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "operationId": "put_fields_v1_documents__document_id__fields_put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FieldsBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Put Fields V1 Documents  Document Id  Fields Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Set/patch field values on a document",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/fields/{field_id}": {
      "delete": {
        "description": "Delete a single field by id. `document_id` scopes the route in the URL\nfor REST symmetry; the delete keys off `field_id` alone (as `cmd_delete_field`\ntakes only the field id \u2014 mirroring how `update_section` keys off the section\nid). A missing/out-of-org id is a 404 via `_run`'s `NotFoundError` mapping.",
        "operationId": "delete_document_field_v1_documents__document_id__fields__field_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "field_id",
            "required": true,
            "schema": {
              "title": "Field Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteFieldResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete one field from a document",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/gather": {
      "post": {
        "description": "Run the source lane only (no synthesize/render LLM step) and return the\ngathered payloads. Reuses `_scoped`, so in per-user MCP mode the caller's\nidentity forwards to the source servers \u2014 the returned payloads then carry\nthe server's per-user marker (e.g. DealDesk `_served_for_user`), which is\nhow a client proves identity reached the data source, not just DocGen.\n\n`refresh: true` bypasses the args-hash cache: it DELETES the document's\ngathered rows, re-fetches every source concurrently (with progress events\non the `\u2026/progress` feed), then re-synthesizes so everything derived from\nthe sources is current \u2014 the explicit \"go get fresh data\" intent\n(`cmd_refresh_gather`). Sections still only re-render via generate. Default\n(`false`) reuses cached rows (`cmd_gather_for_document`).",
        "operationId": "gather_v1_documents__document_id__gather_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GatherBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Gather V1 Documents  Document Id  Gather Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Run gather; return source data (no LLM)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/gathered": {
      "get": {
        "description": "Read-only: return the document's existing `gathered_data` rows WITHOUT\ninvoking any source tool. Backs a document-detail server render so initial\npage load is fast \u2014 the caller then POSTs `\u2026/gather` (optionally\n`refresh: true`) to actually (re-)fetch. A missing document is a 404: the\ncmd signals it with an `{'error': ...}` dict, and `_unwrap` raises it so\n`_run` maps it, matching how every other /v1 route reports not-found.",
        "operationId": "list_gathered_v1_documents__document_id__gathered_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Gathered V1 Documents  Document Id  Gathered Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Read the stored gathered source data (no tool run)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/generate": {
      "post": {
        "operationId": "generate_v1_documents__document_id__generate_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateConflictResponse"
                }
              }
            },
            "description": "Confirm before overwrite: the document has hand-edited sections and neither `force` nor `preserveEdited` was set. Re-issue with `force: true` (overwrite all) or `preserveEdited: true` (keep edits, regenerate the rest)."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Start async generation (progress via SSE)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/generation-snapshots": {
      "get": {
        "operationId": "list_generation_snapshots_v1_documents__document_id__generation_snapshots_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Generation Snapshots V1 Documents  Document Id  Generation Snapshots Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "List the document generation snapshots (per-render pins), newest first",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/generation-snapshots/{snapshot_id}": {
      "get": {
        "operationId": "get_generation_snapshot_v1_documents__document_id__generation_snapshots__snapshot_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "snapshot_id",
            "required": true,
            "schema": {
              "title": "Snapshot Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Generation Snapshot V1 Documents  Document Id  Generation Snapshots  Snapshot Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Get one generation snapshot with its full manifest + output",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/generation-snapshots/{snapshot_id}/reproduce": {
      "post": {
        "operationId": "reproduce_generation_snapshot_v1_documents__document_id__generation_snapshots__snapshot_id__reproduce_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "snapshot_id",
            "required": true,
            "schema": {
              "title": "Snapshot Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Reproduce Generation Snapshot V1 Documents  Document Id  Generation Snapshots  Snapshot Id  Reproduce Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Re-render from the snapshot manifest (templated \u2192 byte-identical)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/orchestrate": {
      "post": {
        "description": "Run the registered orchestrator hook over ``source_text`` \u2014 the first-class\n/v1 door to what was previously only reachable as a bridge command. Returns the\ndetected plan, bound molecules, entity names, and set field values for review.",
        "operationId": "orchestrate_v1_documents__document_id__orchestrate_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrchestrateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Orchestrate V1 Documents  Document Id  Orchestrate Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Orchestrate a document from a source (extract -> decide -> set fields)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/progress": {
      "get": {
        "description": "Versioned alias of the existing `/progress/{id}` SSE \u2014 streams the same\nDB-backed `docgen.progress` events so a `/v1`-only client needs one base\nURL.\n\nCodex #364 B3: `docgen.progress` itself performs no org scoping (keyed by\nthe opaque `document_id` alone), so document OWNERSHIP is verified here,\nagainst the REQUESTING caller's own org/permitted orgs, before the stream\nopens \u2014 a cross-org or nonexistent id is a 404 (never 403 \u2014 matches\n`_request_org`'s no-enumeration convention) and no event is streamed.",
        "operationId": "progress_v1_documents__document_id__progress_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Server-sent event stream of progress events."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "SSE feed of generate-pipeline progress",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/readiness": {
      "get": {
        "operationId": "readiness_v1_documents__document_id__readiness_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Readiness V1 Documents  Document Id  Readiness Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Readiness verdict + gaps",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections": {
      "post": {
        "description": "Author a new section. A title-only body uses the legacy\n`cmd_create_section_title`; a body carrying any config field\n(render_mode / prompt / output_template / output_type) uses the full\n`cmd_create_section`. Both return `{'section': ...}`. A missing/out-of-scope\ndocument is a 404 (the underlying `create_section` raises `NotFoundError`).",
        "operationId": "create_section_v1_documents__document_id__sections_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSectionBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Section V1 Documents  Document Id  Sections Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Create a section under a document",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/order": {
      "put": {
        "description": "Rewrite section `position` to match `sectionIds` (1..N). The id set must\ncover the document exactly once \u2014 a duplicate/partial/foreign set is a 422\n(the cmd raises `ValidationError`). Returns the reordered `{'sections': [...]}`.\nNote: `cmd_reorder_sections` takes a Python list positionally (not a JSON\nstring), unlike most cmds \u2014 pass `body.sectionIds` directly.",
        "operationId": "reorder_sections_v1_documents__document_id__sections_order_put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderSectionsBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Reorder Sections V1 Documents  Document Id  Sections Order Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Reorder the document's sections",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/{section_id}": {
      "delete": {
        "description": "Delete a section. Returns `{'ok': True}`. A missing/out-of-scope id is a\n404 (the underlying `delete_section` raises `NotFoundError`).",
        "operationId": "delete_section_v1_documents__document_id__sections__section_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Section V1 Documents  Document Id  Sections  Section Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete a section",
        "tags": [
          "v1"
        ]
      },
      "get": {
        "description": "Read a single section. `cmd_get_section` returns `{'section': None}` for a\nmissing/out-of-scope id (it does not raise), so \u2014 mirroring `get_document` \u2014\nwe raise `NotFoundError` to render the standard 404.",
        "operationId": "get_section_v1_documents__document_id__sections__section_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Section V1 Documents  Document Id  Sections  Section Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Get one section",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "operationId": "update_section_v1_documents__document_id__sections__section_id__put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SectionEditBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Section V1 Documents  Document Id  Sections  Section Id  Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Edit one section",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/{section_id}/output": {
      "put": {
        "description": "Apply a hand-edited rendered output: sets the section status to `edited`\nand records a new section-output version (the manual-edit half of the\nversion history that `.../sections/{sid}/versions` lists). Distinct from\n`PUT .../sections/{sid}` which edits *config* fields. Missing id \u2192 404.",
        "operationId": "edit_section_output_v1_documents__document_id__sections__section_id__output_put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SectionOutputBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Edit Section Output V1 Documents  Document Id  Sections  Section Id  Output Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Hand-edit a section output (sets edited + records a version)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/{section_id}/promote": {
      "post": {
        "description": "Copy an instance section's config up to the template it was created from.\nReturns `{status, templateSectionId, templateTitle, missingOrdinal}`. A\nmissing section / document / source template is a 404 (the underlying\n`promote_section_to_template` raises `NotFoundError`).",
        "operationId": "promote_section_v1_documents__document_id__sections__section_id__promote_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Promote Section V1 Documents  Document Id  Sections  Section Id  Promote Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Promote an instance section's config up to its source template",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/{section_id}/provenance": {
      "get": {
        "description": "Return `{sectionId, catalogManifest}` \u2014 the `{entity_type, entity_id,\nentity_key, version_num}` list consumed by the section's latest render.\n`catalogManifest` is `[]` when the section has no output version yet (or the\nlatest render carried no manifest, e.g. a non-`composed` mode). `document_id`\nscopes the URL only, matching the section-version routes which likewise pass\nonly `section_id` to the command.\n\n`cmd_section_catalog_provenance` cannot itself signal not-found \u2014 it returns\nan empty manifest whether the section is missing, cross-org, or merely\nunrendered. So compose a `cmd_get_section` existence check first (which\nreturns `{'section': None}` for a missing/out-of-scope id \u2014 the org-scoped\nsession makes a cross-tenant id look absent) and raise `NotFoundError` \u2192 404,\nmirroring `get_section`. This enforces tenant isolation: a section that lives\nonly in another org is a 404 here (never 403; no cross-org read).",
        "operationId": "section_provenance_v1_documents__document_id__sections__section_id__provenance_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Section Provenance V1 Documents  Document Id  Sections  Section Id  Provenance Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "A section's catalog provenance manifest (version-pinning, VP4)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/{section_id}/regenerate": {
      "post": {
        "operationId": "regenerate_section_v1_documents__document_id__sections__section_id__regenerate_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegenerateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Regenerate Section V1 Documents  Document Id  Sections  Section Id  Regenerate Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Regenerate one section",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/{section_id}/versions": {
      "get": {
        "operationId": "list_section_versions_v1_documents__document_id__sections__section_id__versions_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Section Versions V1 Documents  Document Id  Sections  Section Id  Versions Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "List a section's output version history, newest first",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/sections/{section_id}/versions/{version_num}/restore": {
      "post": {
        "operationId": "restore_section_version_v1_documents__document_id__sections__section_id__versions__version_num__restore_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "section_id",
            "required": true,
            "schema": {
              "title": "Section Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "version_num",
            "required": true,
            "schema": {
              "title": "Version Num",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Restore Section Version V1 Documents  Document Id  Sections  Section Id  Versions  Version Num  Restore Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Restore a past section output version",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/snapshots": {
      "get": {
        "operationId": "list_snapshots_v1_documents__document_id__snapshots_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Snapshots V1 Documents  Document Id  Snapshots Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "List the document snapshots (version history), newest first",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_snapshot_v1_documents__document_id__snapshots_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSnapshotBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Snapshot V1 Documents  Document Id  Snapshots Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Capture the current rendered output as a new snapshot",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/snapshots/{snapshot_id}": {
      "delete": {
        "description": "Remove one snapshot from a document's version history. Resolved by id in\nthe caller's org-scoped session; `cmd_delete_snapshot` raises `NotFoundError`\nfor an unknown id (or one owned by another tenant), which `_run` maps to 404\n\u2014 no cross-org delete, no enumeration. Returns ``{'ok': true}`` on success.\nThe path `document_id` scopes the route RESTfully; the command keys off\n`snapshot_id` alone (mirrors the sibling `restore_snapshot` route).",
        "operationId": "delete_snapshot_v1_documents__document_id__snapshots__snapshot_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "snapshot_id",
            "required": true,
            "schema": {
              "title": "Snapshot Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteSnapshotResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete a snapshot (prune version history)",
        "tags": [
          "v1"
        ]
      },
      "get": {
        "description": "Read a single document snapshot \u2014 its header (label, origin, sectionCount)\nplus the full captured section content under `sections`, so a version-history\nUI can preview a past version before restoring it.\n\n`cmd_get_snapshot` signals not-found with a ``{'snapshot': None}`` result\n(it does not raise), so \u2014 exactly like `get_document` \u2014 this raises\n`NotFoundError` on the null result to get a uniform 404 via `_run`. The\nsnapshot is resolved by id inside the caller's org-scoped session, so an id\nthat belongs to another tenant (or does not exist) is a 404 \u2014 no cross-org\nread, no enumeration. The path `document_id` scopes the route RESTfully;\nthe underlying command keys off `snapshot_id` alone (mirrors the sibling\n`restore_snapshot` route).",
        "operationId": "get_snapshot_v1_documents__document_id__snapshots__snapshot_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "snapshot_id",
            "required": true,
            "schema": {
              "title": "Snapshot Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Snapshot V1 Documents  Document Id  Snapshots  Snapshot Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Get one snapshot: header + its captured section content",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/snapshots/{snapshot_id}/restore": {
      "post": {
        "operationId": "restore_snapshot_v1_documents__document_id__snapshots__snapshot_id__restore_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "snapshot_id",
            "required": true,
            "schema": {
              "title": "Snapshot Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Restore Snapshot V1 Documents  Document Id  Snapshots  Snapshot Id  Restore Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Restore a snapshot onto the live sections",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/snippets": {
      "get": {
        "operationId": "list_document_snippets_v1_documents__document_id__snippets_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Document Snippets V1 Documents  Document Id  Snippets Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "List the composition snippets bound to a document, by ordinal",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "bind_snippet_v1_documents__document_id__snippets_post",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BindSnippetBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Bind Snippet V1 Documents  Document Id  Snippets Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Bind a composition snippet to a document",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/snippets/{binding_id}": {
      "delete": {
        "operationId": "unbind_snippet_v1_documents__document_id__snippets__binding_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "binding_id",
            "required": true,
            "schema": {
              "title": "Binding Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Unbind Snippet V1 Documents  Document Id  Snippets  Binding Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Unbind a snippet from a document",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "operationId": "update_document_snippet_v1_documents__document_id__snippets__binding_id__put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "binding_id",
            "required": true,
            "schema": {
              "title": "Binding Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentSnippetBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Document Snippet V1 Documents  Document Id  Snippets  Binding Id  Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Patch a document-snippet binding (entityBindings and/or ordinal)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/spec": {
      "get": {
        "description": "Serialize the whole template/document (config + sections + fields +\ndata-needs + bound snippets/texts/voices) to a spec object. POSTing it to\n`/v1/templates` recreates an equivalent template \u2014 the read-modify-write\nloop, and git export of API-authored templates.",
        "operationId": "get_spec_v1_documents__document_id__spec_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Spec V1 Documents  Document Id  Spec Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Export a template/document back to canonical spec JSON",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "description": "Update an existing template from a full spec \u2014 the inverse of create.\nSections/fields/data-needs/config and the org entities the spec redefines\nare synced to match. `GET /spec` \u2192 edit \u2192 `PUT /spec` is the in-place\nread-modify-write loop; use `POST /templates` to create a new one instead.",
        "operationId": "put_spec_v1_documents__document_id__spec_put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "title": "Body",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Put Spec V1 Documents  Document Id  Spec Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Apply a spec to update a template in place (spec = desired state)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/state": {
      "put": {
        "operationId": "set_document_state_v1_documents__document_id__state_put",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Set Document State V1 Documents  Document Id  State Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Set the document lifecycle state",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/synthesis": {
      "get": {
        "description": "The most recent `synthesized_context` row \u2014 the structured brief the\nsynthesize phase produced \u2014 or `null` if the document has not been\nsynthesized yet. A missing document is a 404 (not a null body).",
        "operationId": "get_synthesis_v1_documents__document_id__synthesis_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SynthesisResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "The latest synthesized context for the document (or null)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/documents/{document_id}/synthesis/history": {
      "get": {
        "description": "Every `synthesized_context` for the document, newest first \u2014 the\nper-synthesize-run history behind a client's \"synthesis versions\" view. A\nmissing document is a 404.",
        "operationId": "list_synthesis_v1_documents__document_id__synthesis_history_get",
        "parameters": [
          {
            "in": "path",
            "name": "document_id",
            "required": true,
            "schema": {
              "title": "Document Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SynthesisHistoryResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "The document synthesized-context history, newest first",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/jinja/tidy": {
      "post": {
        "description": "Re-indent a Jinja template's block structure. Pure and output-preserving;\nrouted through _run for uniform error mapping.",
        "operationId": "tidy_template_v1_jinja_tidy_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TidyTemplateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TidyTemplateResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Pretty-indent a Jinja template's block structure",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/llm-status": {
      "get": {
        "description": "Whether DocGen resolved a real LLM client or the offline fake, plus the\nper-phase model ids - backs a client 'model' badge.",
        "operationId": "llm_status_v1_llm_status_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmStatusResponse"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "Report the resolved LLM mode + per-phase models",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/orchestration-rules": {
      "get": {
        "operationId": "list_orchestration_rules_v1_orchestration_rules_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Orchestration Rules V1 Orchestration Rules Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "The orchestration rulebook (what binds which molecule)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/orgs": {
      "get": {
        "description": "The caller's permitted orgs (slug + displayName) and the one active for\nthis request. An out-of-scope X-Org-Slug is a 404 at _scoped, like every\nother /v1 route.",
        "operationId": "list_orgs_v1_orgs_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrgsResponse"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List the orgs the caller may access + the active one",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/prompt-assist": {
      "post": {
        "description": "Rewrite/sharpen a section or synthesis prompt. In offline/fake LLM mode it\nreturns a deterministic stub (mode='fake'). A blank prompt is a 422.",
        "operationId": "prompt_assist_v1_prompt_assist_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PromptAssistBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptAssistResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Improve a prompt via the LLM (deterministic stub offline)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/risk-blocks": {
      "get": {
        "operationId": "list_risk_blocks_v1_risk_blocks_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Risk Blocks V1 Risk Blocks Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List the org-configured Risk Blocks (statutory analysis)",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_risk_block_v1_risk_blocks_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRiskBlockBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Risk Block V1 Risk Blocks Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Create an org-scoped Risk Block",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/risk-blocks/{risk_block_id}": {
      "delete": {
        "description": "Delete a Risk Block. `cmd_delete_risk_block` -> `delete_risk_block` raises\n`NotFoundError` for an unknown/out-of-scope id, which `_run` maps to 404.\nReturns `{'ok': True}` on success (200).",
        "operationId": "delete_risk_block_v1_risk_blocks__risk_block_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "risk_block_id",
            "required": true,
            "schema": {
              "title": "Risk Block Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Risk Block V1 Risk Blocks  Risk Block Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete an org-scoped Risk Block",
        "tags": [
          "v1"
        ]
      },
      "get": {
        "description": "Look up one Risk Block by id. `cmd_get_risk_block` returns\n`{'riskBlock': None}` for a miss rather than raising, so raise here to map it\nto 404 like every other not-found route (mirrors `get_document`). An id that\nlives only in another tenant is not in the caller-org session, so it is a 404\ntoo \u2014 no cross-org read.",
        "operationId": "get_risk_block_v1_risk_blocks__risk_block_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "risk_block_id",
            "required": true,
            "schema": {
              "title": "Risk Block Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Risk Block V1 Risk Blocks  Risk Block Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Resolve one org-scoped Risk Block by id",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "operationId": "update_risk_block_v1_risk_blocks__risk_block_id__put",
        "parameters": [
          {
            "in": "path",
            "name": "risk_block_id",
            "required": true,
            "schema": {
              "title": "Risk Block Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRiskBlockBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Risk Block V1 Risk Blocks  Risk Block Id  Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Update an org-scoped Risk Block (partial)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/snippets": {
      "get": {
        "operationId": "list_snippets_v1_snippets_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Snippets V1 Snippets Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List the org-configured Snippets (clause molecules)",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_snippet_v1_snippets_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SnippetCreateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Snippet V1 Snippets Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Create a composition snippet (metadata; items set separately)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/snippets/{snippet_id}": {
      "delete": {
        "description": "Delete a snippet. `cmd_delete_snippet` raises `NotFoundError` on a missing\nid (-> 404); on success it returns `{'ok': True}` (200 with body, matching the\nbridge command's return shape \u2014 no existing 204 route to mirror).",
        "operationId": "delete_snippet_v1_snippets__snippet_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "snippet_id",
            "required": true,
            "schema": {
              "title": "Snippet Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Snippet V1 Snippets  Snippet Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete a snippet",
        "tags": [
          "v1"
        ]
      },
      "get": {
        "description": "Look one snippet up by id. `cmd_get_snippet` returns `{'snippet': None}`\nfor a missing/out-of-scope id rather than raising, so wrap it to a\n`NotFoundError` -> 404, exactly like `get_document` does.",
        "operationId": "get_snippet_v1_snippets__snippet_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "snippet_id",
            "required": true,
            "schema": {
              "title": "Snippet Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Snippet V1 Snippets  Snippet Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Resolve one snippet by id",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "description": "Partial metadata patch \u2014 only the keys the caller sends are forwarded\n(`exclude_none`). `cmd_update_snippet` raises `NotFoundError` on a missing id,\nwhich `_run` maps to 404.",
        "operationId": "update_snippet_v1_snippets__snippet_id__put",
        "parameters": [
          {
            "in": "path",
            "name": "snippet_id",
            "required": true,
            "schema": {
              "title": "Snippet Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SnippetUpdateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Snippet V1 Snippets  Snippet Id  Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Patch a snippet's metadata (partial)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/snippets/{snippet_id}/items": {
      "get": {
        "operationId": "list_snippet_items_v1_snippets__snippet_id__items_get",
        "parameters": [
          {
            "in": "path",
            "name": "snippet_id",
            "required": true,
            "schema": {
              "title": "Snippet Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Snippet Items V1 Snippets  Snippet Id  Items Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "List a snippet's ordered composition items",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "description": "Replace the snippet's items with the posted ordered list (ordinals\n0..N-1). `itemType` must be `'text'` or `'risk_block'`; an invalid value or\nempty `itemKey` raises `ValidationError` -> 422 in the cmd.",
        "operationId": "set_snippet_items_v1_snippets__snippet_id__items_put",
        "parameters": [
          {
            "in": "path",
            "name": "snippet_id",
            "required": true,
            "schema": {
              "title": "Snippet Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetSnippetItemsBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Set Snippet Items V1 Snippets  Snippet Id  Items Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Replace a snippet's ordered composition items",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/templates": {
      "get": {
        "operationId": "list_templates_v1_templates_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Templates V1 Templates Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List templates the caller can instantiate",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "description": "Author a template headlessly: POST a full spec object (the same shape the\nbundled demo specs use) and it is compiled \u2014 via the platform compiler \u2014 into\na template in the active org. The spec arrives as the request body, so there\nis no server-side file read or DB write outside the compiler. Idempotent:\nexisting keys skip-with-warning. Returns the compile result + template.\n\n`?dry_run=true` validates the spec and reports what WOULD be created, writing\nnothing \u2014 for a \"check before save\" flow.",
        "operationId": "create_template_v1_templates_post",
        "parameters": [
          {
            "in": "query",
            "name": "dry_run",
            "required": false,
            "schema": {
              "default": false,
              "title": "Dry Run",
              "type": "boolean"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "title": "Body",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Template V1 Templates Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Create a template by compiling a provided spec",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/templates/{slug}": {
      "get": {
        "description": "Look a template up by its stable `slug` (#346) instead of the brittle\nexact human title. Org-scoped: a slug that exists only in another tenant is\na 404 (no cross-org read, no enumeration).",
        "operationId": "get_template_v1_templates__slug__get",
        "parameters": [
          {
            "in": "path",
            "name": "slug",
            "required": true,
            "schema": {
              "title": "Slug",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Template V1 Templates  Slug  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Resolve one template by its stable org-unique slug",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/texts": {
      "get": {
        "operationId": "list_texts_v1_texts_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Texts V1 Texts Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List the org-configured Texts (phrase atoms)",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_text_v1_texts_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTextBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Text V1 Texts Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Create a Text (phrase atom)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/texts/{text_id}": {
      "delete": {
        "description": "`cmd_delete_text` raises `NotFoundError` for an unknown/cross-org id, so\n`_run` maps a miss to 404. Returns `{'ok': True}` (passthrough).",
        "operationId": "delete_text_v1_texts__text_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "text_id",
            "required": true,
            "schema": {
              "title": "Text Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Text V1 Texts  Text Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete a Text",
        "tags": [
          "v1"
        ]
      },
      "get": {
        "description": "Resolve one Text by id, org-scoped. `cmd_get_text` returns\n`{'text': None}` for a miss (and the OrganizationScopedSession makes a\ncross-org id look absent), so wrap it to a 404 the way `get_document`\ndoes \u2014 a Text visible only in another tenant is not found here.",
        "operationId": "get_text_v1_texts__text_id__get",
        "parameters": [
          {
            "in": "path",
            "name": "text_id",
            "required": true,
            "schema": {
              "title": "Text Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Get Text V1 Texts  Text Id  Get"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Get one org-configured Text by id",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "operationId": "update_text_v1_texts__text_id__put",
        "parameters": [
          {
            "in": "path",
            "name": "text_id",
            "required": true,
            "schema": {
              "title": "Text Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTextBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Text V1 Texts  Text Id  Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Patch a Text (partial; omitted keys untouched)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/tool-registrations": {
      "get": {
        "description": "The `tools` rows for the active org \u2014 metadata only (name, category,\nclassPath, configJson, createdAt); credentials are never stored or\nreturned. Org-scoped via `_scoped`.",
        "operationId": "list_tool_registrations_v1_tool_registrations_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Tool Registrations V1 Tool Registrations Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List the org's persisted tool registrations",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_tool_registration_v1_tool_registrations_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateToolRegistrationBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Tool Registration V1 Tool Registrations Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "409": {
            "description": "A tool with this name is already registered in the active org. Delete it first or choose a different name."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Register a tool for the active org",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/tool-registrations/{name}": {
      "delete": {
        "description": "Remove the named registration from the active org. A name that is not\nregistered in this org is a 404 (the cmd raises `NotFoundError`, which\n`_run` maps). Identified by `name` \u2014 the row's org-unique key the delete cmd\ntakes \u2014 not by `id`.",
        "operationId": "delete_tool_registration_v1_tool_registrations__name__delete",
        "parameters": [
          {
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "title": "Name",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Tool Registration V1 Tool Registrations  Name  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete an org tool registration by name",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/tools": {
      "get": {
        "description": "The in-process tool registry (name + category per type) \u2014 what a config\nUI offers when choosing a tool to register. Not org data; the code-side\ncatalogue. Runs inside `_scoped` for identical auth/org enforcement (an\nout-of-scope `X-Org-Slug` is a 404 here too).",
        "operationId": "list_registered_tools_v1_tools_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Registered Tools V1 Tools Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List available tool types from the registry",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/voices": {
      "get": {
        "operationId": "list_voices_v1_voices_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response List Voices V1 Voices Get"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "List the org-configured Voices (writing-style profiles)",
        "tags": [
          "v1"
        ]
      },
      "post": {
        "operationId": "create_voice_v1_voices_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateVoiceBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Create Voice V1 Voices Post"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Create a Voice (writing-style profile)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/voices/{voice_id}": {
      "delete": {
        "operationId": "delete_voice_v1_voices__voice_id__delete",
        "parameters": [
          {
            "in": "path",
            "name": "voice_id",
            "required": true,
            "schema": {
              "title": "Voice Id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Delete Voice V1 Voices  Voice Id  Delete"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Delete a Voice",
        "tags": [
          "v1"
        ]
      },
      "put": {
        "operationId": "update_voice_v1_voices__voice_id__put",
        "parameters": [
          {
            "in": "path",
            "name": "voice_id",
            "required": true,
            "schema": {
              "title": "Voice Id",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateVoiceBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "title": "Response Update Voice V1 Voices  Voice Id  Put"
                }
              }
            },
            "description": "Successful Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            },
            "description": "Validation Error"
          }
        },
        "summary": "Patch a Voice (partial; only sent keys change)",
        "tags": [
          "v1"
        ]
      }
    },
    "/v1/whoami": {
      "get": {
        "description": "Echo the verified caller + active org. A client's proof that auth reached\nDocGen \u2014 no MCP call, no cmd; reads what `AuthMiddleware` resolved. Enforces\nthe per-org 404 so an out-of-scope `X-Org-Slug` is rejected here too.",
        "operationId": "whoami_v1_whoami_get",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WhoamiResponse"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "summary": "The caller identity DocGen verified from the token",
        "tags": [
          "v1"
        ]
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ]
}
