Document Metadata in Collections

This guide covers how to work with document metadata in xAI Collections.

Overview

When you add documents to a collection, you can attach metadata to help organize and filter your content during searches.

Metadata Structure

Metadata is a key-value store attached to each document:

{
  "title": "Document Title",
  "author": "Author Name",
  "category": "technical",
  "created": "2024-01-01"
}

Setting Metadata

When adding a document to a collection, include metadata in the request body.

Updating Metadata

Use the PATCH endpoint to update document metadata:

PATCH /v1/collections/COLLECTION_ID/documents/FILE_ID

Filtering by Metadata

When searching collections, you can filter results based on metadata values.

Best Practices

  • Use consistent metadata keys across documents
  • Include relevant categorization metadata
  • Add timestamps for versioning
  • Use metadata for access control filtering

For complete API reference, see the Collections API documentation.