---
# @generated by sylphx-gen 0.1.0 from contracts@478c308ceb6a738b4ac0675760ae37b0502b002be414f1c7954a3baf04a4d32d. Do not edit.
title: "Patch in Documents"
description: "`data.documents.patch` (PATCH /v1/documents/{index_id}/{document_id}): Changes some fields of a document and keeps the rest: a JSON merge patch (RFC 7396)."
type: reference
product: search
summary: "Changes some fields of a document and keeps the rest: a JSON merge patch (RFC 7396)."
updated: 2026-09-28
nav: false
---

Changes some fields of a document and keeps the rest: a JSON merge patch (RFC 7396). The version goes up by one.

- **Path** `PATCH https://api.data.sylphx.com/v1/documents/index-id/document-id`
- **Scope** `data:write`
- **Effect** `write` — a successful call changes state.
- **Collection** [documents](/docs/api/documents)
- **Host** `https://api.data.sylphx.com`

## Request

| Field | Type | What it is |
| --- | --- | --- |
| `index_id` | `string` | The search index's id. Required. |
| `document_id` | `string` | The document's id; the document must exist. Required. |
| `patch_json` | `bytes` | A JSON object, base64; at most 1 MiB. A field set to a value replaces that field, an object merges into the stored object field by field, and null removes the field. Required. |
| `vector` | `double[]` | A new embedding; empty keeps the stored one. |
| `expected_version` | `uint64` | Write only when the current version equals this one (0: any). |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `document` | `DocumentRecord` | The stored document. |

### DocumentRecord

| Field | Type | What it is |
| --- | --- | --- |
| `index_id` | `string` | The search index's id in the environment, for example `articles`. |
| `document_id` | `string` | The document's id. |
| `document_json` | `bytes` | The document as JSON, base64. |
| `vector` | `double[]` | The document's embedding; its length is the index's vector dimensions. |
| `sha256` | `string` | `sha256:<hex>` of the document. |
| `version` | `uint64` | The version, increasing per document. |
| `updated_at_unix_ms` | `int64` | When this version was written, in Unix milliseconds. |

## Errors

- [`UNAUTHENTICATED`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`INVALID_FIELD`](/docs/api/errors/INVALID_FIELD) — A field failed validation.
- [`RESOURCE_NOT_FOUND`](/docs/api/errors/RESOURCE_NOT_FOUND) — The named Resource does not exist or is not visible.
- [`ETAG_MISMATCH`](/docs/api/errors/ETAG_MISMATCH) — The etag sent does not match the Resource's current etag.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
curl -X PATCH "https://api.data.sylphx.com/v1/documents/index-id/document-id" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"patch_json":"…"}'
```

**TypeScript**

```ts
const response = await sylphx.data.documents.patch({ documentId: 'document-id', indexId: 'index-id', patchJson: '…' })
```

**Rust**

```rust
let mut req = sylphx::data::PatchDocumentRequest::default();
req.document_id = "document-id".to_string();
req.index_id = "index-id".to_string();
req.patch_json = "…".to_string();
let response = sx.data().documents().patch(req).await?;
```

**MCP**

```json
{ "method_id": "data.documents.patch", "args": {"document_id":"document-id","index_id":"index-id","patch_json":"…"} }
```
