> ## 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.

# Get one file from the latest context document tree

> Serve ONE file from the latest ready tree — the dashboard's per-page fetch.

The dashboard's ``/v2/p/<path>`` page needs a single file, but historically
fetched the whole tree via ``GET /tree/latest`` (all files' bodies +
provenance + manifests, multi-MB) and discarded all but one — an O(corpus)
cost on every page click. This endpoint returns just the requested ``path``:
the latest READY (COMPLETED/PUBLISHED) BRAIN tree's matching file, scoped to
that file's manifest, with the SAME redaction / category-filter / personal-
override semantics as the dashboard arm of ``/tree/latest``
(``include_published=true``).

Redaction parity is structural, not re-implemented: ``redact_tree_files`` is
a per-file map, so running ``_render_tree_body`` on a one-element file list
yields byte-identical redacted output to what ``/tree/latest`` serves for
that file. Conditional GET (``If-None-Match``) short-circuits to 304 without
loading/redacting/serializing, the same fast path ``/tree/latest`` has.

Returns a ``TreeResponse`` with ``files`` narrowed to the single file and
``meta`` narrowed to that file's manifest, so the dashboard's existing
parsing (``files[0]``, ``meta.doc_manifests[<file_key>]``) works unchanged.



## OpenAPI

````yaml https://app.stainlessapi.com/api/spec/documented/hyperspell.yaml get /context-documents/tree/latest/file
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:
  - APIKey: []
    AsUser: []
paths:
  /context-documents/tree/latest/file:
    get:
      tags:
        - Context Documents
      summary: Get one file from the latest context document tree
      description: >-
        Serve ONE file from the latest ready tree — the dashboard's per-page
        fetch.


        The dashboard's ``/v2/p/<path>`` page needs a single file, but
        historically

        fetched the whole tree via ``GET /tree/latest`` (all files' bodies +

        provenance + manifests, multi-MB) and discarded all but one — an
        O(corpus)

        cost on every page click. This endpoint returns just the requested
        ``path``:

        the latest READY (COMPLETED/PUBLISHED) BRAIN tree's matching file,
        scoped to

        that file's manifest, with the SAME redaction / category-filter /
        personal-

        override semantics as the dashboard arm of ``/tree/latest``

        (``include_published=true``).


        Redaction parity is structural, not re-implemented:
        ``redact_tree_files`` is

        a per-file map, so running ``_render_tree_body`` on a one-element file
        list

        yields byte-identical redacted output to what ``/tree/latest`` serves
        for

        that file. Conditional GET (``If-None-Match``) short-circuits to 304
        without

        loading/redacting/serializing, the same fast path ``/tree/latest`` has.


        Returns a ``TreeResponse`` with ``files`` narrowed to the single file
        and

        ``meta`` narrowed to that file's manifest, so the dashboard's existing

        parsing (``files[0]``, ``meta.doc_manifests[<file_key>]``) works
        unchanged.
      operationId: get_latest_tree_file_context_documents_tree_latest_file_get
      parameters:
        - name: path
          in: query
          required: true
          schema:
            type: string
            title: Path
      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: []
        - AsUser: []
components:
  schemas:
    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: >-
        Sidecar describing an in-flight (or just-failed) regeneration.


        Present only on the dashboard path (``include_published=true``) when a
        newer

        PROCESSING/FAILED row exists behind the served ready tree — the served
        body

        stays the last COMPLETED/PUBLISHED tree so the brain never blanks out

        mid-regen, and this block is how the UI knows to show a progress banner.
    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>
    AsUser:
      type: apiKey
      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
      in: header
      name: X-As-User

````