---
title: "Get the latest context document tree"
method: GET
path: "/context-documents/tree/latest"
tags: ["Context Documents"]
---

# Get the latest context document tree

`GET /context-documents/tree/latest`

Get the most recent context document tree for the authenticated app.

The sync daemon polls this endpoint to fetch updated files. Default
behaviour: serve the latest "ready" tree, where "ready" depends on
whether the app has `require_review` enabled:

- `require_review=False` (default): latest COMPLETED ships immediately.
- `require_review=True`: latest PUBLISHED only — apps that gate on a
  curator's approval before the daemon picks up the new tree.

`?status=<value>` filters to a specific status (case-insensitive).
`?include_published=true` returns the absolute latest tree (any status)
so the dashboard can surface an in-flight PROCESSING generation when
the user navigates away mid-gen and back. The daemon path (no
`include_published`) keeps strict status filtering.

Auto-trigger semantics replace the pre-Temporal lazy
``BackgroundTasks`` path:

* If the app has no tree at all and the caller has a user_key, a
  full ``TreeGenerationWorkflow`` is dispatched with
  ``user_id=user_key`` so its in-line Phase 4 populates this user's
  overrides. The endpoint still 404s on this poll; the daemon will
  see a PROCESSING tree on its next poll.
* If the latest COMPLETED tree has no ``personal_overrides`` entry
  for the caller, a lightweight ``PersonalDocWorkflow`` is
  dispatched against that tree to backfill just this user's
  override block. The response is still served immediately with
  placeholder personal/*.md content; the next poll merges the
  generated content in.

Both dispatches use deterministic workflow IDs that also dedupe with
Phase 4's child-workflow dispatch from ``TreeGenerationWorkflow``,
so concurrent runs never race against each other.

## Query parameters

- `status` string, nullable
- `include_published` boolean

## Response `200`

Successful Response

- TreeResponse
  - `tree_id` string, required
  - `status` string, required
  - `version` integer, required
  - `files` TreeFile[], nullable, required
    - `path` string, required
    - `content` string, required
    - `tier` string, required
    - `team` string, nullable, required
    - `updated_at` string, required
  - `error` string, nullable, required
  - `created_at` string, date-time, required
  - `completed_at` string, date-time, nullable, required
  - `meta` object, required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/hyperspell/apis/hyperspell-api.md) · [All operations](https://skmtc.net/hyperspell/apis/hyperspell-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/hyperspell/hyperspell-api/versions/5721acd588e6/schema)
