---
title: "Launch document preprocessing"
method: POST
path: "/api/v1/datasets/{dataset_id}/launch-preprocessing"
tags: ["Dataset"]
---

# Launch document preprocessing

`POST /api/v1/datasets/{dataset_id}/launch-preprocessing`

## Request

- The document declares no server URL.
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/adaptionlabs/apis/adaption-api/docs/api/v1/datasets/:dataset_id/launch-preprocessing/post.ts> (a function with typed inputs; its response is checked against the schema)

Extracts the text, tables and figures of an uploaded document dataset (pdf, docx, pptx, xlsx, html, or a zip of them) into rows. After the upload completes, such a dataset reports `awaiting_input` until this is called. Reserves credits from the page count of the selected documents — quote them first with GET /datasets/{dataset_id}/preprocessing-credits — then starts extraction. Poll GET /datasets/{dataset_id}/status: it reports `pending` while extracting and `awaiting_input` once the rows are ready, at which point call POST /datasets/{dataset_id}/adapt.

## Path parameters

- `dataset_id` string, required

## Request body

- LaunchPreprocessingBodyDto
  - `pages_to_process` number: Maximum number of pages to process. Documents are included until this budget is reached. If omitted, all pages are processed.
  - `documents_to_process` number: Maximum number of documents to process. If omitted, all documents are processed.
  - `preprocessing_mode` 'per_document' | 'per_page': How extracted content becomes rows: `per_document` (default) makes one row per document, `per_page` one row per page. Omit to keep the mode already set on the dataset.

## Response `202`

- LaunchPreprocessingResponseDto
  - `dataset_id` string, required: ID of the dataset
  - `status` string, required: Dataset status after the launch. Poll GET /datasets/{dataset_id}/status until it reports `awaiting_input`, then call POST /datasets/{dataset_id}/adapt.
  - `credits_escrowed` number: Credits reserved for extracting the selected documents
  - `pages_to_process` number: Total pages across the documents selected for extraction
  - `documents_selected` number: Number of documents selected for extraction
  - `documents_total` number: Number of documents in the dataset

## Other responses

- `400`: Not a document dataset, or both pages_to_process and documents_to_process were set.
- `402`: Insufficient credits
- `409`: Preprocessing was already launched for this dataset, or its upload has not completed.
- `503`: The page count of a document could not be read yet. Retry shortly.

## Changes

- **2026-11-03** `d4cf908c19a0`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/adaptionlabs/apis/adaption-api/changes/api/v1/datasets/:dataset_id/launch-preprocessing/post.md)

---

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