---
title: "Edit a pasted-text document"
method: PATCH
path: "/v1/knowledgebases/{id}/documents/{docId}"
tags: ["Knowledge Bases"]
---

# Edit a pasted-text document

`PATCH /v1/knowledgebases/{id}/documents/{docId}`

## Request

- Base URL: `https://api.pyai.com`
- URL: `https://api.pyai.com/v1/knowledgebases/{id}/documents/{docId}`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Edit in place and re-ingest. Only documents added as pasted text (`source: "api"`) can be edited; re-add files or URLs instead. Requires the `kb:manage` scope.

## Path parameters

- `id` string, required
- `docId` string, required

## Request body

- object
  - `text` string, required
  - `title` string

## Response `202`

Updated and re-ingesting

- KbDocument: A knowledge base document and its ingestion state.
  - `id` string
  - `kbId` string
  - `orgId` string
  - `source` 'upload' | 'url' | 'api': upload = file, url = fetched page, api = pasted text.
  - `uri` string, nullable
  - `title` string, nullable
  - `filename` string, nullable
  - `mime` string, nullable
  - `sizeBytes` integer
  - `chunks` integer: Indexed chunk count (0 until indexed).
  - `status` 'pending' | 'indexed' | 'failed'
  - `error` string, nullable: Human-readable failure/stall reason.
  - `indexedAt` integer, nullable: Unix ms.
  - `createdAt` integer: Unix ms.

## Other responses

- `400`: Invalid request (bad field, unsupported value)
- `404`: Resource not found (`code: not_found`)

---

[API](https://skmtc.dev/pyai/apis/pyai-api.md) · [All operations](https://skmtc.dev/pyai/apis/pyai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pyai/apis/pyai-api/revisions/271a1539185b?raw)
