---
title: "Apply Taxonomy to Existing Documents"
method: POST
path: "/v1/collections/{collection_identifier}/apply-taxonomy"
tags: ["Collection Taxonomies"]
---

# Apply Taxonomy to Existing Documents

`POST /v1/collections/{collection_identifier}/apply-taxonomy`

Apply a taxonomy to all existing documents in a collection retroactively.

This endpoint triggers distributed Ray processing to enrich existing documents
with taxonomy data. Unlike automatic materialization (which happens during ingestion),
this endpoint allows you to:

1. **Backfill enrichment** for documents ingested before the taxonomy was created
2. **Re-apply taxonomy** after configuration changes
3. **Process specific subsets** using scroll_filters

⚙️ **Processing Details:**
- Uses Ray datasets with map_batches for parallel processing
- Scales horizontally across Ray cluster
- Non-blocking: Returns immediately with task_id
- Monitor progress via Tasks API

⚠️ **Prerequisites:**
- Taxonomy must exist and be valid
- Taxonomy must be in collection's taxonomy_applications list
- Collection must contain documents

📊 **Performance:**
- ~1000-5000 docs/second depending on cluster size
- Parallel processing across multiple Ray workers
- Batch size and parallelism configurable

🔍 **Use Cases:**
- Backfill: Apply new taxonomy to historical data
- Re-enrichment: Update after taxonomy changes
- Selective: Process filtered document subsets

See Collections API and Taxonomies API documentation for details.

## Path parameters

- `collection_identifier` string, required — Collection ID or name to apply taxonomy to

## Request body

- ApplyTaxonomyRequest — Request to apply a taxonomy to an existing collection. This endpoint triggers retroactive taxonomy materialization on all documents in a collection using distributed Ray processing. Use Cases: - Apply taxonomy to documents that were ingested before the taxonomy was created - Re-apply taxonomy after taxonomy configuration changes - Backfill enrichment data for existing collections Requirements: - taxonomy_id: REQUIRED - Must be an existing, valid taxonomy - The taxonomy must already be attached to the collection via taxonomy_applications - Documents must exist in the collection
  - `taxonomy_id` string, required — ID of the taxonomy to apply. REQUIRED. Must be an existing taxonomy (tax_*). The taxonomy must already be in the collection's taxonomy_applications list.
  - `scroll_filters` object, nullable — Optional filters to limit which documents are enriched. NOT REQUIRED. If not provided, all documents in the collection will be enriched. Use to process specific subsets (e.g., documents missing enrichment).
  - `batch_size` integer — Number of documents to process in each parallel batch. NOT REQUIRED. Defaults to 1000. Larger batches = fewer Ray tasks but more memory per task. Smaller batches = more Ray tasks but lower memory per task.
  - `parallelism` integer — Number of parallel Ray workers to use for processing. NOT REQUIRED. Defaults to 4. Higher parallelism = faster processing but more cluster resources. Set based on available Ray cluster capacity.

## Response `200`

Successful Response

- ApplyTaxonomyResponse — Response from applying taxonomy to collection. Returns statistics about the materialization process.
  - `task_id` string, required — ID of the Ray task executing the materialization
  - `status` string, required — Status of the materialization task
  - `collection_id` string, required — Collection ID where taxonomy is being applied
  - `taxonomy_id` string, required — Taxonomy ID being applied
  - `estimated_documents` integer, nullable — Estimated number of documents to process (if available)

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `422` — Validation Error
- `500` — Internal Server Error

---

[API](https://skmtc.net/mixpeek/apis/mixpeek-api.md) · [All operations](https://skmtc.net/mixpeek/apis/mixpeek-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mixpeek/mixpeek-api/versions/220a3b263fda/schema)
