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

# Compare two versions

> Compute per-file unified diffs between two versions of a shelf.



## OpenAPI

````yaml openapi.yaml get /v1/shelves/{id}/diff
openapi: 3.1.0
info:
  description: >-
    Convert documents into structured Markdown filesystems that AI agents can
    hydrate and use in sandbox runtimes.
  title: Shelv API
  version: 1.0.0
servers:
  - url: https://api.shelv.dev
security:
  - bearerApiKey: []
paths:
  /v1/shelves/{id}/diff:
    get:
      tags:
        - Shelves
      summary: Compare two versions
      description: Compute per-file unified diffs between two versions of a shelf.
      parameters:
        - in: path
          name: id
          required: true
          schema:
            $ref: '#/components/schemas/ShelfPublicIdParam'
        - in: query
          name: from
          required: true
          schema:
            exclusiveMinimum: 0
            type: integer
        - in: query
          name: to
          required: true
          schema:
            exclusiveMinimum: 0
            type: integer
        - in: query
          name: context
          required: false
          schema:
            default: 3
            maximum: 10
            minimum: 0
            type:
              - integer
              - 'null'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShelfDiffResponse'
          description: Version diff
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Validation error (e.g. from === to, or version too large)
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Payment required
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Shelf or version not found
      security:
        - bearerApiKey: []
components:
  schemas:
    ShelfPublicIdParam:
      pattern: ^shf_[0-9a-f]{24}$
      type: string
    ShelfDiffResponse:
      properties:
        files:
          items:
            properties:
              patch:
                type: string
              path:
                type: string
              status:
                enum:
                  - added
                  - modified
                  - removed
                type: string
              truncated:
                type: boolean
            required:
              - path
              - status
              - patch
            type: object
          type: array
        from:
          exclusiveMinimum: 0
          type: integer
        shelfPublicId:
          pattern: ^shf_[0-9a-f]{24}$
          type: string
        summary:
          properties:
            added:
              minimum: 0
              type: integer
            modified:
              minimum: 0
              type: integer
            removed:
              minimum: 0
              type: integer
            totalFiles:
              minimum: 0
              type: integer
            unchanged:
              minimum: 0
              type: integer
          required:
            - added
            - modified
            - removed
            - unchanged
            - totalFiles
          type: object
        to:
          exclusiveMinimum: 0
          type: integer
      required:
        - shelfPublicId
        - from
        - to
        - summary
        - files
      type: object
    ErrorResponse:
      properties:
        code:
          type: string
        details: {}
        message:
          type: string
      required:
        - code
        - message
      type: object
  securitySchemes:
    bearerApiKey:
      bearerFormat: APIKey
      scheme: bearer
      type: http

````