{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vaquill-ai/json-schema/vaquill-ai-draft-schema.json",
  "title": "Draft",
  "description": "One draft with its body, section by section.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vaquill-ai-drafting-api-openapi.yml#/components/schemas/Draft",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "description": "Public identifier, `drf_` followed by 32 hex characters."
    },
    "matterId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Matterid",
      "description": "`mat_` identifier of the matter this draft belongs to, when it belongs to one."
    },
    "title": {
      "type": "string",
      "title": "Title",
      "description": "The draft's title."
    },
    "category": {
      "type": "string",
      "title": "Category",
      "description": "What kind of document this is, as a category slug."
    },
    "practiceArea": {
      "type": "string",
      "title": "Practicearea",
      "description": "Practice area the draft sits in."
    },
    "status": {
      "type": "string",
      "title": "Status",
      "description": "Where the DOCUMENT is in its own lifecycle: `draft`, `review`, `final` or `archived`. Set by you. This is not the same as `generationStatus`."
    },
    "source": {
      "type": "string",
      "title": "Source",
      "description": "How the draft came to exist: `generated` by the pipeline, `uploaded` from a file, `imported` from editor content, or `analysis` where an analysis produced it."
    },
    "version": {
      "type": "integer",
      "title": "Version",
      "description": "Current version number, counting from 1. Pass it as `expectedVersion` on a replace to avoid a lost update."
    },
    "generationStatus": {
      "$ref": "#/$defs/OperationStatus",
      "description": "Where the JOB that produced this draft got to, in the five public statuses. Set only by the pipeline. A draft the pipeline never touched reads `succeeded`."
    },
    "governingLawState": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Governinglawstate",
      "description": "The governing law pinned on the draft, for example `ca` or `federal`."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "title": "Createdat",
      "description": "When the draft was created (RFC 3339)."
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "title": "Updatedat",
      "description": "When the draft was last modified (RFC 3339)."
    },
    "sections": {
      "items": {
        "$ref": "#/$defs/DraftSection"
      },
      "type": "array",
      "title": "Sections",
      "description": "The draft body, section by section. Send edits back as `contentMarkdown`; request bytes from the export route."
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "id",
    "title",
    "category",
    "practiceArea",
    "status",
    "source",
    "version",
    "generationStatus",
    "createdAt",
    "updatedAt",
    "sections"
  ],
  "$defs": {
    "DraftSection": {
      "properties": {
        "heading": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Heading",
          "description": "The section's heading. Null for body text preceding the first heading, which is where a parties block or preamble lives."
        },
        "level": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Level",
          "description": "Heading depth, 1 to 6. Null when there is no heading."
        },
        "text": {
          "type": "string",
          "title": "Text",
          "description": "The text beneath this heading, as plain text."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "text"
      ],
      "title": "DraftSection",
      "description": "One heading and the text beneath it.\n\n`heading` is null for body text that precedes the first heading, which is\nwhere a parties block or a preamble lives. Dropping it because it has no\nheading would lose the first paragraph of most contracts."
    },
    "OperationStatus": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ],
      "title": "OperationStatus",
      "description": "The public five. There is no sixth, and there are no synonyms.\n\nInternal vocabularies spell terminal success `completed`, `ready`,\n`extracted`, `succeeded` and `fresh`; terminal failure `failed` and `error`;\nqueued `pending`, `queued` and `draft`. All of that is collapsed here by\n`app.workspace_api.adapters.status_map`, which refuses to guess."
    }
  }
}