---
title: "Automap Document"
method: POST
path: "/api/batch/{batch_id}/document/{document_id}/automap"
tags: ["Batch Processing"]
---

# Automap Document

`POST /api/batch/{batch_id}/document/{document_id}/automap`

Aggregate data from multiple pages and map to Excel template fields.

This endpoint:
1. Retrieves selected pages from the document
2. Aggregates structured data across pages
3. Uses OpenAI to intelligently map aggregated data to Excel fields
4. Returns mapping suggestions with confidence scores

## Path parameters

- `batch_id` string, required
- `document_id` string, required

## Request body

- AutomapRequest — Request model for automap operation
  - `batch_id` string, required
  - `document_id` string, required
  - `selected_page_numbers` integer[], required
  - `excel_fields` ExcelFieldSchema[], required
    - `name` string, required
    - `type` string, required
    - `description` string, nullable
    - `required` boolean
  - `openai_api_key` string, required

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/qomplement/apis/fastapi.md) · [All operations](https://skmtc.dev/qomplement/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/qomplement/fastapi/revisions/7a7c8e2b5afc/schema)
