---
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`

## Request

- Base URL: `https://api.mixpeek.com`
- URL: `https://api.mixpeek.com/v1/collections/{collection_identifier}/apply-taxonomy`
- Auth: HTTP bearer and API key in header `X-Namespace`

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.
  - `budget_limits` BudgetLimits: User-defined limits for time and credits during execution.
    - `max_credits` number, nullable: Maximum credits allowed for a single execution (OPTIONAL).
    - `max_time_ms` integer, nullable: Maximum wall-clock time in milliseconds before forcing halt (OPTIONAL).

## 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`: Unprocessable Entity
- `429`: Too Many Requests
- `500`: Internal Server Error
- `503`: Service Unavailable

## Changes

- **2026-10-09** `61a175e8eb9a`: 1 warning, 5 info
  - removed the optional property `detail` from the response with the `422` status
  - added the non-success response with the status `429`
  - added the non-success response with the status `503`
  - added the optional property `success` to the response with the `422` status
  - …2 more
- **2026-10-04** `38e0822db900`: 1 info
  - added the new optional request property `budget_limits`
- **2026-08-09** `5d4c905106b4`: 1 info
  - the endpoint scheme security `BearerAuth AND NamespaceHeader` was added to the API

[Operation history](https://skmtc.dev/mixpeek/apis/mixpeek-api/changes/v1/collections/:collection_identifier/apply-taxonomy/post.md)

---

[API](https://skmtc.dev/mixpeek/apis/mixpeek-api.md) - [All operations](https://skmtc.dev/mixpeek/apis/mixpeek-api/llms.txt) - [OpenAPI document](https://skmtc.dev/mixpeek/apis/mixpeek-api/revisions/790bc16455f6?raw)
