Skip to main content
Collections support arbitrary key-value metadata. Updates use deep merge — nested dictionaries are merged recursively, preserving existing keys. See Metadata for more on how metadata works in Docent.

Get Metadata

from docent import Docent

client = Docent()

metadata = client.get_collection_metadata("my-collection-id")
print(metadata)  # {"team": "support", "model": "gpt-4"}

Parameters

collection_id
str
required
ID of the collection.

Returns

metadata
dict
The collection’s metadata dictionary.

Update Metadata

Updates are deep-merged into existing metadata. Existing keys not in the update are preserved.
# Existing metadata: {"team": "support", "config": {"model": "gpt-4"}}

client.update_collection_metadata("my-collection-id", {
    "config": {"temperature": 0.7},
    "version": "v2",
})

# Result: {"team": "support", "config": {"model": "gpt-4", "temperature": 0.7}, "version": "v2"}

Parameters

collection_id
str
required
ID of the collection.
metadata
dict
required
Metadata to merge into the existing metadata.

Returns

metadata
dict
The full merged metadata dictionary after the update.

Delete Metadata Keys

Remove specific keys from metadata. Supports dot-delimited paths for nested deletion.
# Existing metadata: {"team": "support", "config": {"model": "gpt-4", "temperature": 0.7}}

metadata, not_found = client.delete_collection_metadata_keys(
    "my-collection-id",
    keys=["config.temperature", "nonexistent_key"],
)

print(metadata)    # {"team": "support", "config": {"model": "gpt-4"}}
print(not_found)   # ["nonexistent_key"]

Parameters

collection_id
str
required
ID of the collection.
keys
list[str]
required
Keys to remove. Use dot notation for nested keys (e.g., "config.model").

Returns

Returns a tuple of two values:
metadata
dict
The metadata dictionary after deletion.
not_found
list[str]
Keys that were not found in the metadata.