---
title: "Edit files in a draft tree before publishing"
method: PATCH
path: "/context-documents/tree/{tree_id}/files"
tags: ["Context Documents"]
---

# Edit files in a draft tree before publishing

`PATCH /context-documents/tree/{tree_id}/files`

Edit individual files in a draft tree before publishing.

Only DRAFT trees can be edited. Pass a map of file paths to new content.

## Path parameters

- `tree_id` string, required

## Request body

- EditFilesRequest — Request body for editing files before publishing.
  - `files` object, required — Map of file path → new content. Only provided paths are updated.

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

## Changes

- **2026-04-22** `a4bf4f3aaf15` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/hyperspell/apis/hyperspell-api/changes/context-documents/tree/:tree_id/files/patch.md)

---

[API](https://skmtc.dev/hyperspell/apis/hyperspell-api.md) · [All operations](https://skmtc.dev/hyperspell/apis/hyperspell-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/hyperspell/hyperspell-api/revisions/69d534d74b00/schema)
