---
title: "Update a reference document"
method: PATCH
path: "/ai-context/documents/{document_id}/"
tags: ["ai-context"]
---

# Update a reference document

`PATCH /ai-context/documents/{document_id}/`

## Request

- Base URL: `https://api.getoneprofile.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.getoneprofile.ai/ai-context/documents/{document_id}/`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Rename a document, rewrite its summary by hand, or take it in or out of the business context. Omitted fields are left untouched.

## Path parameters

- `document_id` string, uuid, required

## Request body

- AiContextDocumentUpdateSchema: Request body for editing one document (tri-state PATCH semantics).
  - `included_in_context` union: Whether this document's summary joins the business context.
    - boolean
    - unknown
  - `summary` union: New summary. Set to null to clear it. Saving one marks the summary as written by hand, so a later rewrite can warn before replacing it.
    - string
    - unknown
  - `title` union: New display name.
    - string
    - unknown

## Response `200`

Successful Response

- AiContextDocumentReadSchema: One reference document: what it is, how far it got, and what prompts read.
  - `content_type` string, required
  - `created_at` string, date-time, required
  - `drive_file_id` string, nullable, required
  - `drive_web_view_link` string, nullable, required: Where to open the original in Google Drive, for linked documents.
  - `error` string, nullable, required: Why the document could not be read, written for the reader.
  - `filename` string, required
  - `id` string, uuid, required
  - `in_prompt_budget` boolean: Whether this document's summary actually fits the prompt budget alongside the documents before it. Computed on the list; a single read reports true.
  - `included_in_context` boolean, required: Whether this document's summary joins the business context.
  - `size_bytes` integer, required
  - `source` 'upload' | 'google_drive', required: Where a reference document came from.
  - `status` 'pending' | 'processing' | 'ready' | 'failed', required: How far a reference document has got through extraction and summarizing. Unlike a generation job, ``PENDING`` IS observed here: the row commits first and its workflow starts after that commit, so a reader can catch the gap. The two terminal states are absorbing.
  - `steps` AiStep[]: What the last read did, one step per piece of work once it is done: the document read, the summary written. Grows while the document is `processing`; starts empty again when it is read again.
    - `action` string, required: What kind of move this was, e.g. `read_table`, `plan`, `write_column`.
    - `detail` string: The step's input: the instruction, the column it read, the query it ran.
    - `duration_ms` integer, nullable: Wall clock for the work this step describes, never an estimate.
    - `observation` string: One line on what came back. The half that makes a step worth reading.
    - `outcome` string: `completed`, `failed`, `refused` or `stopped`. Clients must tolerate new tokens.
    - `thought` string, nullable: The model's stated reasoning for choosing this step. Set by the agent loop; the assistant surfaces leave it null, and the renderer simply omits the rung.
  - `summary` string, nullable, required: The markdown summary that stands in for this document in AI prompts.
  - `summary_edited` boolean, required: True once somebody saved over the written summary by hand.
  - `summary_generated_at` string, date-time, nullable, required
  - `title` string, required
  - `updated_at` string, date-time, required

## Other responses

- `401`: Unauthorized
- `403`: Forbidden
- `404`: Document not found
- `422`: Invalid request made to the API.
- `500`: Internal server error.
- `502`: Bad gateway error.
- `503`: Service unavailable.

---

[API](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile.md) · [All operations](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/llms.txt) · [OpenAPI document](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/revisions/4a6bd71e3f02?raw)
