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

# Diff Ontology (Dry Run)

> Report pending changes in the sandcastle's Ontology mount without authoring a change.

<Note>
  A read-only dry run: it shows what [Create Ontology
  Change](/api-reference/v2/sandbox/create-ontology-change) *would* write back,
  so an agent can decide whether there's anything to persist before authoring a
  change. It never commits and never advances the baseline.
</Note>

The diff is scoped to your `OWNERS` permissions — the library mount the session
sees was pruned at materialization, so only paths you may edit can appear here.

<Warning>
  This dry run is **best-effort, not read-after-write consistent.** Because the
  diff is computed over a shared network filesystem with attribute caching, an
  edit you just wrote can briefly read back as `has_changes: false`. Don't treat
  a single `has_changes: false` immediately after a write as authoritative — the
  authoritative result is the diff returned by [Create Ontology
  Change](/api-reference/v2/sandbox/create-ontology-change) itself.
</Warning>


## OpenAPI

````yaml GET /v2/sandcastles/{id}/ontology/diff
openapi: 3.1.0
info:
  title: TextQL v2 API
  version: '2.0'
  description: >
    REST API for TextQL platform operations. All endpoints require Bearer token
    authentication.
servers:
  - url: https://app.textql.com
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Create and manage AI chat sessions
  - name: Connectors
    description: List available data connectors
  - name: Playbooks
    description: Create, configure, and run automated playbooks
  - name: Sandcastles
    description: Manage Python sandbox environments for code execution
  - name: Changes
    description: Review, approve, and deny Ontology changes
  - name: API Keys
    description: Mint and revoke scoped platform API keys
paths:
  /v2/sandcastles/{id}/ontology/diff:
    get:
      tags:
        - Sandcastles
      summary: Diff Ontology (dry run)
      description: >
        Report the pending changes in the sandbox's Ontology mount

        (`/sandbox/files/library`) relative to its baseline snapshot —

        **without** authoring a change. Use this to decide whether there is

        anything to write back before calling

        [Create Ontology
        Change](/api-reference/v2/sandbox/create-ontology-change).


        The diff is scoped to the caller's `OWNERS` permissions: the mount the

        session sees was pruned at materialization, so only permitted paths can

        appear here.
      operationId: v2.ontologyDiff
      parameters:
        - $ref: '#/components/parameters/SandboxId'
      responses:
        '200':
          description: Pending library changes
          content:
            application/json:
              schema:
                type: object
                properties:
                  has_changes:
                    type: boolean
                    description: True when the library differs from its baseline snapshot.
                  diffs:
                    type: array
                    items:
                      $ref: '#/components/schemas/LibraryChangeDiff'
                  raw_diff:
                    type: string
                    description: >-
                      The unified git diff, normalized to library-relative
                      paths.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    SandboxId:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: Sandbox ID
  schemas:
    LibraryChangeDiff:
      type: object
      description: One changed file in an Ontology change.
      properties:
        name:
          type: string
          description: Display name for the change.
        old_path:
          type: string
        new_path:
          type: string
        additions:
          type: integer
          format: int64
        deletions:
          type: integer
          format: int64
        is_new:
          type: boolean
        is_delete:
          type: boolean
        is_rename:
          type: boolean
        is_binary:
          type: boolean
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
              enum:
                - invalid_request
                - unauthenticated
                - permission_denied
                - not_found
                - conflict
                - rate_limit_exceeded
                - internal
                - timeout
                - cancelled
                - execution_failed
                - no_report
            message:
              type: string
              description: Human-readable error message
  responses:
    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthenticated
              message: Authentication required
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: permission_denied
              message: Insufficient permissions
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: not_found
              message: Resource not found
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limit_exceeded
              message: Rate limit exceeded
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: internal
              message: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key or JWT token

````