Quadratic History API

Undo, redo, and atomic batches of actions.

OpenAPI Specification

quadratic-history-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Quadratic Developer Agent Connections History API
  description: 'Token-authenticated REST API for Quadratic spreadsheets. All `/v1/*` routes require an `Authorization: Bearer <token>` header where the token is a `qdx_live_…` or `qdx_test_…` value minted from the Quadratic UI.


    **Optional `Quadratic-Session-Id` header.** Clients may attach a UUID v4 to every request to correlate analytics events from a single integration run (one client instance, one CLI invocation, one CI job). Official SDKs generate one at construction and send it transparently; direct callers may omit it. Malformed values are dropped silently and never propagated to analytics.'
  contact:
    name: Quadratic
  license:
    name: Apache-2.0
  version: 0.26.9
tags:
- name: History
  description: Undo, redo, and atomic batches of actions.
paths:
  /v1/files/{file_id}/batch:
    post:
      tags:
      - History
      summary: 'Executes a batch of actions sequentially, stopping on the first error.

        Mirrors the MCP `batch` semantics. The response is an array of

        `{action, result}` objects up to and including the failed action.'
      operationId: batch
      parameters:
      - name: file_id
        in: path
        description: File UUID
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchRequest'
        required: true
      responses:
        '200':
          description: Per-action results
          content:
            application/json:
              schema: {}
        '400':
          description: Empty batch or nested batch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: Missing or invalid token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '502':
          description: Worker upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - bearer_auth: []
  /v1/files/{file_id}/redo:
    post:
      tags:
      - History
      summary: Re-applies the last `count` operations that were undone.
      operationId: redo
      parameters:
      - name: file_id
        in: path
        description: File UUID
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        description: Optional body. Defaults to `count = 1`.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UndoRedoRequest'
        required: true
      responses:
        '200':
          description: Redo applied
          content:
            application/json:
              schema: {}
        '401':
          description: Missing or invalid token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '502':
          description: Worker upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - bearer_auth: []
  /v1/files/{file_id}/undo:
    post:
      tags:
      - History
      summary: Reverts the last `count` operations on a file.
      operationId: undo
      parameters:
      - name: file_id
        in: path
        description: File UUID
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        description: Optional body. Defaults to `count = 1`.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UndoRedoRequest'
        required: true
      responses:
        '200':
          description: Undo applied
          content:
            application/json:
              schema: {}
        '401':
          description: Missing or invalid token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '502':
          description: Worker upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - bearer_auth: []
components:
  schemas:
    ErrorDetail:
      type: object
      required:
      - code
      - message
      properties:
        code:
          type: string
          description: 'Stable machine-readable error code. Clients should switch on this

            rather than parsing the human-readable `message`. See the README''s

            "Errors" section for the full list of codes.'
          example: not_found
        details:
          description: 'Optional structured context for the error (validation paths, worker

            upstream messages, etc.). Absent when no extra context is available.'
        message:
          type: string
          description: 'Human-readable description of the failure. Suitable for logs but not

            guaranteed to be stable across versions.'
          example: Sheet 'Forecast' not found
    BatchRequest:
      type: object
      required:
      - actions
      properties:
        actions:
          type: array
          items:
            $ref: '#/components/schemas/BatchItem'
          description: Ordered list of actions to execute. Stops at the first failure.
          example:
          - action: set_cell_values
            params:
              top_left_position: A1
              cell_values:
              - - Name
                - Score
              - - Alice
                - 95
          - action: add_sheet
            params:
              sheet_name: Sheet 2
    BatchItem:
      type: object
      required:
      - action
      properties:
        action:
          type: string
          description: 'Action name; matches the worker tool names exposed by individual

            REST endpoints (e.g. `set_cell_values`, `add_sheet`).'
          example: set_cell_values
        params:
          description: 'Action params object — same shape as the corresponding REST

            endpoint''s request body.'
    UndoRedoRequest:
      type: object
      properties:
        count:
          type:
          - integer
          - 'null'
          format: int64
          description: Number of operations to undo or redo. Defaults to `1`.
          example: 1
    ErrorBody:
      type: object
      description: Canonical error envelope returned by every non-2xx response.
      required:
      - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: API token (qdx_live_… or qdx_test_…)
      description: 'API tokens are minted from the Quadratic UI under Team Settings → API Tokens. Send as `Authorization: Bearer <token>`.'