> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Patch draft

> Apply a patch to an existing draft. The request body, content sections, field caps, and tile-addressing rules are identical to [Create draft and patch document](/api/documents-v2/create-draft-and-patch-document); this route does not accept `branchId`.

This endpoint doesn't create or publish drafts.




## OpenAPI

````yaml /api/openapi.yaml patch /v2/documents/{documentId}/draft/{draftId}
openapi: 3.1.0
info:
  title: Omni API
  description: >
    The Omni REST API provides programmatic access to your Omni instance for
    managing users, documents, queries, schedules, and more.  
  version: 1.0.0
  contact:
    name: Omni Support
    url: https://docs.omni.co
servers:
  - url: https://{instance}.omniapp.co/api
    description: Production
    variables:
      instance:
        default: blobsrus
        description: Your production Omni instance subdomain
  - url: https://{instance}.playground.exploreomni.dev/api
    description: Playground
    variables:
      instance:
        default: blobsrus
        description: Your playground Omni instance subdomain
security:
  - bearerAuth: []
  - orgApiKey: []
tags:
  - name: Who Am I
    description: Inspect your own user permissions
  - name: AI
    description: AI-powered query generation
  - name: AI Credit Controls
    description: Manage organization-level AI credit usage
  - name: AI Credit Usage
    description: Monitor AI credit usage
  - name: AI Evals
    description: >-
      Manage prompt sets and runs used to score AI quality against curated
      prompt suites.
  - name: AI Model Suggestions
    description: Manage AI-generated suggestions for shared models
  - name: AI Routines
    description: >-
      Manage Routines, which are scheduled, recurring AI-powered tasks that run
      automatically on your data
  - name: Apps
    description: Draft and publish app documents.
  - name: App downloads
    description: Download apps as PNG, PDF, XLSX, or CSV files
  - name: Branches
    description: List branches and open or close them to Viewers and Restricted Queriers
  - name: Documents v2
    description: >
      A draft-based workflow for creating and editing documents: create a
      document, patch a draft, then publish.
  - name: Documents
    description: Create, retrieve, and manage documents
  - name: API Tokens
    description: >-
      Manage API tokens (Organization keys, Personal Access Tokens, MCP OAuth
      grants)
  - name: IP Allowlist
    description: Manage the organization's IP allowlist
  - name: Connections
    description: Manage database connections
  - name: Connection environments
    description: Manage connection environments database connections
  - name: Color Palettes
    description: Manage custom chart color palettes
  - name: Content
    description: Unified content retrieval (documents and folders)
  - name: Content migration
    description: Export and import dashboards
  - name: Content validator
    description: Validate content against models and perform find/replace operations
  - name: Dashboard downloads
    description: Download dashboards and tiles as PDF, PNG, XLSX, CSV, or JSON files
  - name: Dashboard filters and controls
    description: Read and update dashboard filter and control default values
  - name: dbt
    description: Manage dbt configuration for connections
  - name: Document favorites
    description: Favorite and unfavorite documents
  - name: Document labels
    description: Apply and manage labels on documents
  - name: Document permissions
    description: Manage document-level access
  - name: Embed
    description: Manage embed sessions
  - name: Labels
    description: |
      Manage labels in the organization
  - name: Folders
    description: Create and organize content folders
  - name: Folder favorites
    description: Favorite and unfavorite folders
  - name: Folder labels
    description: Apply and manage labels on folders
  - name: Folder permissions
    description: Manage folder-level access
  - name: Jobs
    description: Check status of asynchronous jobs
  - name: Models
    description: Create and manage data models
  - name: Model branches
    description: Manage model branches and merge changes
  - name: Model git configuration
    description: Manage git configuration for shared models
  - name: Queries
    description: Execute workbook queries
  - name: Schedules
    description: Create and manage scheduled tasks
  - name: Schedule recipients
    description: Manage schedule recipients
  - name: Schema refresh schedules
    description: Manage automated schema refresh schedules for connections
  - name: Skills
    description: >-
      Manage skills, the saved slash-command instructions the Omni AI assistant
      runs
  - name: Topics
    description: Retrieve topic information from models
  - name: Uploads
    description: Manage file uploads
  - name: Users
    description: Manage users
  - name: User attributes
    description: Manage user attribute definitions
  - name: User groups
    description: Manage user groups
  - name: User model roles
    description: Manage model and connection role assignments for users
  - name: User group model roles
    description: Manage model and connection role assignments for user groups
  - name: Uploads
    description: Manage CSV and spreadsheet uploads
paths:
  /v2/documents/{documentId}/draft/{draftId}:
    patch:
      tags:
        - Documents v2
      summary: Patch draft
      description: >
        Apply a patch to an existing draft. The request body, content sections,
        field caps, and tile-addressing rules are identical to [Create draft and
        patch document](/api/documents-v2/create-draft-and-patch-document); this
        route does not accept `branchId`.


        This endpoint doesn't create or publish drafts.
      operationId: documentsV2PatchDraftByIdentifier
      parameters:
        - name: documentId
          in: path
          required: true
          schema:
            type: string
          description: >-
            The published document's URL slug (e.g. `abc123`) or its canonical
            workbook UUID.
        - name: draftId
          in: path
          required: true
          schema:
            type: string
          description: The draft workbook identifier the patch is applied to.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              description: >-
                The content/metadata diff applied to a draft. All fields
                optional; only the sections present are changed.
              properties:
                modelId:
                  type: string
                  format: uuid
                  description: >-
                    Immutable model identifier. Must match the document's
                    current base model or the API will return a 400 error.
                workbookModelId:
                  type: string
                  format: uuid
                  description: >-
                    Immutable model identifier. Must match the document's
                    current workbook model or the API will return a 400 error.
                name:
                  type: string
                  minLength: 1
                  maxLength: 254
                  description: Document name.
                description:
                  type:
                    - string
                    - 'null'
                  description: Document description.
                summary:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    Caller-supplied description of what this patch changes,
                    written to the history audit trail. When omitted, Omni
                    auto-generates one from the updated sections.
                queryPresentations:
                  $ref: '#/components/schemas/DocumentsV2QueryPresentationsPatch'
                controls:
                  $ref: '#/components/schemas/DocumentsV2ControlsPatch'
                settings:
                  $ref: '#/components/schemas/DocumentsV2SettingsPatch'
                containers:
                  allOf:
                    - $ref: '#/components/schemas/DocumentsV2Containers'
                    - description: >-
                        Container layout. When present, fully replaces the
                        existing layout.
                app:
                  $ref: '#/components/schemas/DocumentsAppReadOnly'
                draftOf:
                  type: object
                  additionalProperties: false
                  description: >
                    **Currently read-only**. The identifier of the published
                    document that the draft belongs to. 
                  properties:
                    identifier:
                      type: string
            examples:
              contentOnly:
                summary: Update a tile's subtitle
                value:
                  queryPresentations:
                    data:
                      '2':
                        type: query
                        name: Revenue by month
                        subTitle: Trailing 12 months
                        topicName: order_items
                        query:
                          fields:
                            - order_items.created_at[month]
                            - order_items.sale_price_sum
      responses:
        '200':
          description: Patch applied to draft successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentsV2PatchDraftResponse'
        '400':
          description: >
            Invalid request body or schema validation error. Potential causes:


            - An unknown top-level field

            - A length cap exceeded

            - query-presentation cap exceeded (`A single patch may carry at most
            48 query presentations.`). 

            - `modelId` doesn't match the document's current base model

            - `fileUploadId` is provided on a non-csv/spreadsheet tab type

            - The upload ID doesn't correspond to an upload in the caller's
            organization

            - `foreign` tab names the document's own model or is missing
            `foreignModelId`/`query`

            - `foreignModelId` is supplied on a non-`foreign` tab

            - An existing tab is converted to or from `foreign`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            Insufficient permissions to update the draft, or the target is an
            app draft and the organization has apps disabled. Also returned when
            a new `foreign` tab's `foreignModelId` names a model you can't build
            workbooks on — this includes an unknown, deleted, or inaccessible
            model, so the error doesn't reveal which models exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            Document or draft not found. Also returned when `documentId` names a
            draft rather than a published document — drafts only attach to
            published documents.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '405':
          $ref: '#/components/responses/MethodNotAllowed'
        '409':
          description: >
            - A concurrent request just created the layout for this document

            - Document doesn't have an app but an app was supplied (`app` is
            currently read-only)

            - An app was supplied but its URL doesn't address the provided
            document's app

            - A `draftOf` was supplied naming a document other than the route's
            target (`draftOf` is currently read-only)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >
            The document cannot satisfy the patch: 


            - A classic layout dashboard. [Upgrade to the new
            layout](/api/documents/upgrade-dashboard-layout).

            - A workbook-only document patched with dashboard-scoped fields but
            no `containers` payload, or an empty one

            - An app document patched with dashboard-scoped fields. A document
            can have a dashboard or an app, but not both.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    DocumentsV2QueryPresentationsPatch:
      type: object
      description: Query presentations (tabs/tiles) keyed by record key.
      properties:
        data:
          type: object
          description: >
            Tabs keyed by record key (a positive-integer string, e.g. `"1"`,
            `"2"`). Shallow-merged by key — omitted keys are untouched; set a
            key to `null` to delete that tab. Capped at 48 non-null entries per
            patch.
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/DocumentsV2QueryPresentation'
              - type: 'null'
        order:
          type: array
          description: Tab display order. When present, replaces the existing order.
          items:
            type: string
            pattern: ^[1-9][0-9]*$
    DocumentsV2ControlsPatch:
      type: object
      description: Dashboard filters/controls keyed by control ID.
      properties:
        data:
          type: object
          description: >-
            Controls keyed by control ID. Shallow-merged by key — omitted keys
            are untouched; set to `null` to delete.
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/DocumentsV2Control'
              - type: 'null'
        order:
          type: array
          description: >-
            Display order for controls. When present, replaces the existing
            order.
          items:
            type: string
    DocumentsV2SettingsPatch:
      type: object
      description: Document settings. Shallow-merged with the existing settings.
      properties:
        controlBar:
          type: object
          additionalProperties: false
          description: >-
            Control bar presentation. Merged field by field — omitted fields
            keep their current value.
          properties:
            collapsible:
              type: boolean
              description: >-
                When `true`, filters that do not fit in a single row are hidden
                behind a toggle. When `false`, every filter is shown.
            defaultExpanded:
              type: boolean
              description: >-
                When `true`, a collapsible control bar starts expanded, showing
                every filter. Only meaningful when `collapsible` is `true`.
            fixed:
              type: boolean
              description: >-
                When `true`, the control bar stays at the top of the dashboard
                while scrolling.
        crossfilterEnabled:
          type: boolean
          description: >-
            When `true`, clicking a value in one tile filters all other tiles on
            the dashboard.
        customText:
          type:
            - object
            - 'null'
          description: Custom text replacing default UI strings on the dashboard.
          properties:
            queryError:
              type: string
              description: >-
                Custom text shown when a query errors, replacing the default
                error text.
            queryNoResults:
              type: string
              description: >-
                Custom text shown when a query returns no results, replacing the
                default empty state.
        facetFilters:
          type: boolean
          description: >-
            When true, dashboard filters are applied per-facet when faceting is
            active.
        refreshInterval:
          type:
            - number
            - 'null'
          description: Auto-refresh interval in seconds. Null disables auto-refresh.
        runQueriesOn:
          type:
            - string
            - 'null'
          enum:
            - current-page
            - all-pages
            - null
          description: >-
            Controls whether dashboard queries execute on the visible page or
            across all pages.
    DocumentsV2Containers:
      type: array
      description: >
        Container layout array (grid / stack / page / reference containers,
        recursively nested). On a patch, when present this **fully replaces**
        the existing layout. The server validates the full structure on apply;
        container `instanceKey` / `referenceKey` values round-trip unchanged.
        See the dashboard layout reference for the complete grammar.
      items:
        type: object
        additionalProperties: true
    DocumentsAppReadOnly:
      type: object
      additionalProperties: false
      description: |
        **Currently read-only**. Will be used in future releases.
      properties:
        url:
          type: string
    DocumentsV2PatchDraftResponse:
      type: object
      required:
        - description
        - draftIdentifier
        - identifier
        - name
      properties:
        identifier:
          type: string
          description: Published document identifier the draft targets.
          example: def456
        draftIdentifier:
          type: string
          description: Identifier of the draft the patch was applied to.
          example: abc123
        name:
          type: string
          description: Document name.
          example: Blob Sales
        description:
          type:
            - string
            - 'null'
          description: Document description.
          example: Overview of daily Blobs R Us Sales
    Error:
      type: object
      properties:
        error:
          type: string
          description: HTTP response code for the error
          example: <response_code>
        message:
          type: string
          description: Detailed error description
          example: <error_reason>
    DocumentsV2QueryPresentation:
      type: object
      required:
        - type
      description: >
        A single tab/tile. The server owns internal tile identity — callers
        never send `miniUuid`; tiles are addressed by their record key in
        `queryPresentations.data`.
      properties:
        type:
          type: string
          enum:
            - blank
            - csv
            - query
            - dataset
            - spreadsheet
            - sql
            - dbt
            - query-view
            - linked
            - foreign
            - app
          description: >
            The query presentation type:


            - `query` is a semantic query

            - `sql` is raw SQL

            - `linked` reuses another tile's query (see
            `sourceQueryPresentationKey`)

            - `foreign` is a cross-model tab whose query runs against a shared
            model other than the document's own (see `foreignModelId`). A new
            tab may be created as `foreign`; an existing tab can't be converted
            to or from `foreign`.
        name:
          type: string
          minLength: 1
          maxLength: 144
          description: User-provided tab name.
        subTitle:
          type:
            - string
            - 'null'
          maxLength: 250
          description: User-provided tab subtitle.
        description:
          type:
            - string
            - 'null'
          maxLength: 500
          description: User-provided tab description.
        sourceQueryPresentationKey:
          type:
            - string
            - 'null'
          pattern: ^[1-9][0-9]*$
          description: >
            For `linked`-type tabs, the record key — the same identifier used as
            a `queryPresentations.data` key — of the source tile whose query
            this tab reuses. Null for all other tab types. This is a tile record
            key, **not** a positional index into `order`.
        topicName:
          type:
            - string
            - 'null'
          description: The topic (explore) this query is built on.
        isSql:
          type:
            - boolean
            - 'null'
          description: Whether this tab is in raw SQL mode.
        prefersChart:
          type: boolean
          description: >-
            When true, the chart view is shown by default instead of the data
            table.
        automaticVis:
          type:
            - boolean
            - 'null'
          description: >-
            When true, the system automatically selects the best visualization
            type.
        filterOrder:
          type: array
          items:
            type: string
          description: >-
            Ordered list of filter field names controlling display order on this
            tab.
        editingModelObjectName:
          type:
            - string
            - 'null'
          description: >-
            Model object (view/topic) currently being edited via the
            dataset/query-view editor. Applies only to `dataset` / `query-view`
            tabs — omitted from reads and rejected on patches for other tab
            types.
        editingModelObjectNameChange:
          type:
            - string
            - 'null'
          description: >-
            Pending rename of the model object being edited. Applies only to
            `dataset` / `query-view` tabs — omitted from reads and rejected on
            patches for other tab types.
        fileUploadId:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The ID of the upload (from POST /v1/uploads) backing this tab's
            data. Applies only to `csv` and `spreadsheet` tabs — omitted from
            reads and rejected on patches for other tab types. On patch,
            providing it on a new tab key binds that upload as the tab's Source;
            changing it on an existing key repoints the tab at a different
            upload (regenerating the tab, same semantics as any other content
            change).
        query:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: >-
            The semantic query for this tab (fields, filters, sorts, limits,
            etc.), minus the server-owned workbook model anchors. Omitted on a
            no-op replay; the server anchors new/changed tiles to the draft.
        visConfig:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: Visualization configuration for the tile.
        resultConfig:
          type: object
          additionalProperties: true
          description: >-
            Result display configuration (column widths, frozen columns,
            conditional formatting, number formatting, etc.).
        aiConfig:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: >-
            AI-generated metadata config (subtitle/description auto-generation
            settings).
        model_extension_id:
          type:
            - string
            - 'null'
          description: >
            Identifies the query model bound to this tile. Returned on read
            (omitted for `linked`-type tiles, whose query resolves from the
            source tile). This value is read-only and managed by Omni - any
            value provided in write requests will be ignored.
        foreignModelId:
          type:
            - string
            - 'null'
          description: >
            Present only on `foreign` tabs: the shared model this tab's query
            runs against (a model other than the document's own). 


            Required when creating a new `foreign` tab, where it must name a
            [shared model you can build workbooks
            on](/analyze-explore/cross-model-tabs), other than the document's
            own base model. On an existing `foreign` tab this value is read-only
            — a supplied value is ignored and the tab keeps its stored execution
            model. Rejected on every other tab type.
    DocumentsV2Control:
      type: object
      additionalProperties: true
      description: >
        A dashboard control (filter). The full config grammar — control type,
        field bindings, filter values, and (for multi-field filters) the
        recursive composite-filter grammar — is validated by the server on
        apply. See the dashboard filters & controls reference for the complete
        structure.
  responses:
    MethodNotAllowed:
      description: Method Not Allowed - Invalid HTTP method for this endpoint
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Can be either an [Organization API
        Key](/api/authentication#organization-api-keys) or [Personal Access
        Token (PAT)](/api/authentication#token-types).


        Include in the `Authorization` header as: `Bearer YOUR_TOKEN`
    orgApiKey:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Requires an [Organization API
        Key](/api/authentication#organization-api-keys). Personal Access Tokens
        (PATs) are not supported for this endpoint.


        Include in the `Authorization` header as: `Bearer ORGANIZATION_API_KEY`

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.