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

# Merge a saved edit with regenerated content

> Merge a saved content edit with the generated baseline for one file.

The merge preserves user framing while incorporating new facts, saves the
result as a content edit, and returns the updated tree.

Available for completed or published trees that have an active content edit
and a generated baseline for the path.



## OpenAPI

````yaml https://api.hyperspell.com/openapi.json post /context-documents/tree/{tree_id}/files/automerge
openapi: 3.1.0
info:
  title: Hyperspell API
  summary: >-
    Hyperspell is the memory layer for AI apps and agents. Through the API, you
    can add memories, connect data sources to index them in real-time, and
    search memories with our natural language query engine.
  termsOfService: https://hyperspell.com/blog/tos
  contact:
    name: Hyperspell
    url: https://hyperspell.com/
    email: hello@hyperspell.com
  version: 0.32.1
servers:
  - url: https://api.hyperspell.com
    description: Production
security: []
paths:
  /context-documents/tree/{tree_id}/files/automerge:
    post:
      tags:
        - Context Documents
      summary: Merge a saved edit with regenerated content
      description: >-
        Merge a saved content edit with the generated baseline for one file.


        The merge preserves user framing while incorporating new facts, saves
        the

        result as a content edit, and returns the updated tree.


        Available for completed or published trees that have an active content
        edit

        and a generated baseline for the path.
      operationId: automerge_file_context_documents_tree__tree_id__files_automerge_post
      parameters:
        - name: tree_id
          in: path
          required: true
          schema:
            type: string
            title: Tree Id
        - name: X-As-User
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Optionally set this header to act as a specific user when using an
              API Key, equivalent to first exchanging the API Key for a User
              Token
            title: X-As-User
          description: >-
            Optionally set this header to act as a specific user when using an
            API Key, equivalent to first exchanging the API Key for a User Token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AutomergeRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TreeResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKey: []
components:
  schemas:
    AutomergeRequest:
      properties:
        path:
          type: string
          title: Path
          description: File path to auto-merge.
      type: object
      required:
        - path
      title: AutomergeRequest
    TreeResponse:
      properties:
        tree_id:
          type: string
          title: Tree Id
        status:
          type: string
          title: Status
        version:
          type: integer
          title: Version
        files:
          anyOf:
            - items:
                $ref: '#/components/schemas/TreeFile'
              type: array
            - type: 'null'
          title: Files
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        created_at:
          type: string
          format: date-time
          title: Created At
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
        meta:
          additionalProperties: true
          type: object
          title: Meta
        generating:
          anyOf:
            - $ref: '#/components/schemas/TreeGenerating'
            - type: 'null'
      type: object
      required:
        - tree_id
        - status
        - version
        - files
        - error
        - created_at
        - completed_at
        - meta
      title: TreeResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TreeFile:
      properties:
        path:
          type: string
          title: Path
        content:
          type: string
          title: Content
        tier:
          type: string
          title: Tier
        team:
          anyOf:
            - type: string
            - type: 'null'
          title: Team
        updated_at:
          type: string
          title: Updated At
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        provenance:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Provenance
      type: object
      required:
        - path
        - content
        - tier
        - team
        - updated_at
      title: TreeFile
    TreeGenerating:
      properties:
        tree_id:
          type: string
          title: Tree Id
        status:
          type: string
          enum:
            - processing
            - failed
          title: Status
        created_at:
          type: string
          format: date-time
          title: Created At
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        progress:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Progress
      type: object
      required:
        - tree_id
        - status
        - created_at
      title: TreeGenerating
      description: >-
        Status of a newer generation that is processing or recently failed.


        This can accompany the last ready tree so clients can report progress
        while

        continuing to use ready content.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKey:
      type: http
      description: >-
        API Key or JWT User Token. If using an API Key, set the X-As-User header
        to act as a specific user. A JWT User Token is always scoped to a
        specific user.
      scheme: bearer
      bearerFormat: Bearer <token>

````