## Extracted text of a document version (tenant:dms:read)

`GET /api/dms/v1/documents/{id}/text`

Module: DMS · operationId: `getDocumentText` · Tag: Text · Auth: access token (`Authorization: Bearer <accessToken>`)

Returns the text of a finished extraction (`DONE` or `PARTIAL`) as Markdown (default) or
plain text, joined in `text` and per page in `pages`. `structured` holds structured data
when the extractor produced any (e.g. a parsed e-invoice). Audited as `VIEW`.

Without text the answer is `409` while the extraction is still queued or running (`code:
extraction_pending`; retry later) and `422` otherwise (`code` `not_extracted`, `encrypted`
or the extraction's error code such as `no_text` or `pdf_password`); both carry the
extraction `status`.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes |  |
| `version` | query | integer |  | Version number; default the current version |
| `format` | query | string |  | (one of `markdown`, `plain`; default `"markdown"`) |
| `pages` | query | string |  | One page `N` or a range `N-M` (1-based) |
| `include` | query | string |  | `text` returns only the joined text (`pages` is empty) (one of `pages`, `text`; default `"pages"`) |

### Responses

- **200** Text (`application/json`)
- **400** Error (`application/json`)
- **404** Error (`application/json`)
- **409** No text available (409 extraction still running, 422 no text) (`application/json`)
- **422** No text available (409 extraction still running, 422 no text) (`application/json`)

Fields of the 200 answer:

- `degraded` (boolean, required): At least one page was extracted in degraded quality
- `documentId` (string (uuid), required): Document id
- `pages` (array of TextPage, required): Empty with `include=text`
  - `pageNo` (integer, required): Page number, from 1
  - `source` (string, required): How the page text was obtained (one of `text_layer`, `ocr`, `tika`, `einvoice`)
  - `text` (string, required): Text of the page
- `pagesProcessed` (integer, required): Pages extracted
- `pagesTotal` (integer, required): Pages of the file
- `status` (string, required): Extraction status (PARTIAL: page limit or partial failure) (one of `DONE`, `PARTIAL`)
- `structured` (object, nullable, required): Structured extraction result (e.g. a parsed e-invoice) or null
- `text` (string, required): The selected pages joined by blank lines
- `version` (integer, required): Version the text belongs to
- `model` (string): Model used for OCR, if any

Example 200 answer:

```json
{
  "degraded": false,
  "documentId": "3f6c2a1e-8b4d-4c7a-9e21-5d0b7a9c1f42",
  "pages": [
    {
      "pageNo": 1,
      "source": "einvoice",
      "text": "# Rechnung RE-482117\n\nNordlicht IT-Distribution GmbH, Hafenstraße 40, 20457 Hamburg"
    },
    {
      "pageNo": 2,
      "source": "einvoice",
      "text": "| Pos. | Artikel | Menge | Einzelpreis |\n|---|---|---|---|\n| 1 | Notebook ProBook 14 G10 | 6 | 829,00 € |\n| 2 | USB-C Dockingstation 100 W | 6 | 139,00 € |\n\nGesamt netto 5.808,00 €, USt. 19 % 1.103,52 €, Gesamt brutto 6.911,52 €"
    }
  ],
  "pagesProcessed": 2,
  "pagesTotal": 2,
  "status": "DONE",
  "structured": {
    "currency": "EUR",
    "grossTotal": 6911.52,
    "invoiceNumber": "RE-482117",
    "issueDate": "2026-09-30",
    "netTotal": 5808,
    "taxTotal": 1103.52
  },
  "text": "# Rechnung RE-482117\n\nNordlicht IT-Distribution GmbH, Hafenstraße 40, 20457 Hamburg\n\n| Pos. | Artikel | Menge | Einzelpreis |\n|---|---|---|---|\n| 1 | Notebook ProBook 14 G10 | 6 | 829,00 € |\n| 2 | USB-C Dockingstation 100 W | 6 | 139,00 € |\n\nGesamt netto 5.808,00 €, USt. 19 % 1.103,52 €, Gesamt brutto 6.911,52 €",
  "version": 1
}
```

### Example request

```bash
curl -X GET 'https://api.mbcom.cloud/api/dms/v1/documents/3f2b8c1e-7d4a-4e9b-9c2a-5b1d6e8f0a12/text' \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```
