---
title: "Update Document Metadata"
method: PUT
path: "/datastores/{datastore_id}/documents/{document_id}/metadata"
tags: ["/datastores/{id}/documents"]
---

# Update Document Metadata

`PUT /datastores/{datastore_id}/documents/{document_id}/metadata`

Post details of a given document that will enrich the chunk and be added to the context or just for filtering. If Just for filtering, start with "_" in the key.

## Path parameters

- `datastore_id` string, uuid, required — Datastore ID of the datastore from which to retrieve the document
- `document_id` string, uuid, required — Document ID of the document to retrieve details for

## Request body

- MetadataRequest — This class contains all queries associated with metadata request for a doc.
  - `custom_metadata` object — Custom metadata for the document, provided by the user at ingestion time.Must be a JSON-serializable dictionary with string keys and simple primitive values (str, int, float, bool). The total size must not exceed 2 KB.The strings with date format must stay in date format or be avodied if not in date format.The 'custom_metadata.url' field is automatically included in returned attributions during query time, if provided.The default maximum metadata fields that can be used is 15, contact support if more is needed.
  - `custom_metadata_config` object — A dictionary mapping metadata field names to the configuration to use for each field. If a metadata field is not present in the dictionary, the default configuration will be used. If the dictionary is not provided, metadata will be added in context for rerank and generation but will not be returned back to the user in retrievals in query API. Limits: - Maximum characters per metadata field (for prompt or rerank): **400** - Maximum number of metadata fields (for prompt or retrieval): **10** Contact support@contextual.ai to request quota increases.

## Response `200`

Successful Response

- DocumentDescription — Document description
  - `custom_metadata` object — Custom metadata for the document, provided by the user at ingestion time.Must be a JSON-serializable dictionary with string keys and simple primitive values (str, int, float, bool). The total size must not exceed 2 KB.The strings with date format must stay in date format or be avodied if not in date format.The 'custom_metadata.url' field is automatically included in returned attributions during query time, if provided.The default maximum metadata fields that can be used is 15, contact support if more is needed.
  - `custom_metadata_config` object — A dictionary mapping metadata field names to the configuration to use for each field. If a metadata field is not present in the dictionary, the default configuration will be used. If the dictionary is not provided, metadata will be added in context for rerank and generation but will not be returned back to the user in retrievals in query API. Limits: - Maximum characters per metadata field (for prompt or rerank): **400** - Maximum number of metadata fields (for prompt or retrieval): **10** Contact support@contextual.ai to request quota increases.
  - `id` string, uuid, required — ID of the document that was ingested
  - `name` string, required — User specified name of the document
  - `status` 'pending' | 'processing' | 'retrying' | 'completed' | 'failed' | 'cancelled', required
  - `created_at` string, required — Timestamp of when the document was created in ISO format.
  - `updated_at` string — Timestamp of when the document was modified in ISO format.
  - `ingestion_config` object — Ingestion configuration for the document when the document was ingested. It may be different from the current datastore configuration.
  - `has_access` boolean — Whether the user has access to this document.

## Other responses

- `422` — Validation Error

## Changes

- **2025-10-28** `c8152db45500` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/contextualai/apis/endpoints/changes/datastores/:datastore_id/documents/:document_id/metadata/put.md)

---

[API](https://skmtc.dev/contextualai/apis/endpoints.md) · [All operations](https://skmtc.dev/contextualai/apis/endpoints/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/contextualai/endpoints/revisions/ca7f807eec8b/schema)
