---
title: Unified Document Extraction API
slug: unified-document-extraction
url: https://apyhub.com/apyhub/service/unified-document-extraction
provider: ApyHub
categories: [Ingestion Kit, Document Intelligence Kit]
tags: [document-extraction, markdown-conversion, ocr, pdf-extraction, document-ingestion]
auth: api_key
version: 1.0
service_type: sync
endpoints: 1
atoms: 10
mcp: true
---

# Unified Document Extraction API

Extract documents into per-unit Markdown with OCR, metadata, and diagnostics. Useful for search, chunking, and downstream document processing.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/apyhub/unified-document-extraction` | What it does Uploads a document via a presigned URL and returns its extracted content as per-unit M… | 10 |

## Endpoint reference

### Extract a document into per-unit Markdown

`POST https://api.eu.apyhub.com/apyhub/unified-document-extraction` · 10 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `filename` | body | string | no | Optional. Used only as an extension hint for plain-text containers (.csv, .tsv, .md) and image naming. Example: `Safety Handbook.pdf`. |
| `mime_type` | body | string | no | MIME type hint. Never trusted — routing uses the type detected from content. Example: `application/pdf`. |
| `presigned_url` | body | string (uri) | yes | S3 presigned GET URL (or any http/https URL). Fetched as-is; may exceed 2,048 characters. Never logged. |

#### Quickstart

Send a presigned file URL so the API can extract its content.

```bash
curl -X POST "https://api.eu.apyhub.com/apyhub/unified-document-extraction" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "presigned_url": "https://assets.apyhub.com/samples/sample.pdf",
    "filename": "sample.pdf",
    "mime_type": "application/pdf"
  }'
```

#### What you'll get back

Returns a JSON object with a `data` object. `data` contains `units` (the extracted content units in document order), `metadata` (the detected MIME type and model), and `diagnostics` (OCR and embedded-image counts).

```json
{
  "data": {
    "units": [
      {
        "index": 1,
        "kind": "page",
        "label": "Page 1",
        "markdown": "Adobe Acrobat PDF Files Adobe® Portable...",
        "route": "native",
        "language": "en",
        "warnings": []
      }
    ],
    "metadata": {
      "detected_mime_type": "application/pdf",
      "model": "apyhub-unified/v1"
    },
    "diagnostics": {
      "ocr_attempted": false,
      "embedded_images_total": 0,
      "embedded_images_ocrd": 0,
      "embedded_images_skipped_decorative": 0
    }
  }
}
```

## About

## What it does
Document Markdown Extractor turns an uploaded document into per-unit Markdown. Send a `presigned_url`, with optional `filename` and `mime_type` hints, and get back a document-order breakdown of `units` that you can join into the full text.

Each unit includes an `index`, `kind`, `label`, `markdown`, `route`, `language`, and `warnings`. That gives you both the extracted content and the context needed to rebuild page-by-page, slide-by-slide, sheet-by-sheet, or section-by-section output. The extractor also returns `metadata` with the detected MIME type and extraction model, plus `diagnostics` for OCR activity and embedded image handling.

Use Document Markdown Extractor when you need document content that is easier to search, chunk, review, or feed into downstream processing than the original file. It handles native text, OCR fallback, and embedded image text, while preserving stable warning codes such as `ocr_fallback_used`, `table_split_into_blocks`, and `embedded_image_ocr_failed`.

For PDFs, spreadsheets, slides, images, and text containers, you get a consistent Markdown representation without having to build your own parsing pipeline.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/apyhub/service/unified-document-extraction
