---
title: "Re-run extraction on one document"
method: POST
path: "/accountant/companies/{customerId}/documents/{documentId}/re-extract"
tags: ["Accountant Documents"]
---

# Re-run extraction on one document

`POST /accountant/companies/{customerId}/documents/{documentId}/re-extract`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/accountant/companies/{customerId}/documents/{documentId}/re-extract`
- Auth: HTTP bearer

Requires an accountant assigned to the customer; a person only (no service API key). Sends the document's retained file to the configured document extraction provider (the existing extraction path) and records a new extraction (metadata source `accountant_re_extract`, with the requesting user). Side effects: only EMPTY vendor, customer, invoice number, document date and due date are filled, never a field a person set; the stored inline extraction metadata is replaced; the document type may change to the type the extraction resolves (unless a person set it). It never writes money (money is certified only through the separate certification path), never matches, posts or creates AR/AP items. With the scoped Median Labs Vertex review enabled, a currently assigned reviewer or firm admin with legal entity access may review a clean, supported electronic receipt. Vertex receives only a locally derived financial projection and may confirm the missing receipt date. The fill is computed from the document as it is after the provider call and written only if the document did not change meanwhile. Each authorized call writes one audit log row. 404 for unassigned or missing documents and for a document without a retained file; 403 when external extraction is not allowed for the company; 503 when extraction is not configured. 409 codes: DOCUMENT_REEXTRACT_COOLDOWN (a completed extraction is less than 10 minutes old), DOCUMENT_EXTRACTION_FAILED (the provider returned nothing or a failure), DOCUMENT_CHANGED_DURING_EXTRACTION (nothing written), DOCUMENT_SOURCE_UNAVAILABLE (the retained file cannot be read).

## Path parameters

- `customerId` string, uuid, required
- `documentId` string, uuid, required

## Response `200`

The accountant document after extraction

- object
  - `success` true, required
  - `data` AccountantDocument, required: Accountant document DTO (toAccountantDocumentDto); money fields follow the accountant document money projection.
    - `id` string, uuid, required
    - `customerId` string, uuid, required
    - `entityId` string, uuid, nullable
    - `type` string, required
    - `status` string, required
    - `name` string, required
    - `vendorName` string, nullable
    - `customerName` string, nullable
    - `invoiceNumber` string, nullable
    - `categoryGlAccountId` string, uuid, nullable
    - `uploadedAt` string, date-time
    - `dueDate` string, date, nullable
    - `docDate` string, date, nullable
    - `sizeBytes` integer, nullable
    - `fileName` string, nullable
    - `mimeType` string, nullable
    - `transactionId` string, uuid, nullable
    - `category` string, nullable
    - `notes` string, nullable
    - `paymentStatus` string, nullable
    - `sourceProvider` string, nullable
    - `externalViewUrl` string, nullable
    - `hasProposedMatch` boolean

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `409`: Request conflicts with the durable onboarding state
- `422`: Request failed validation
- `503`: Required sandbox provider configuration or service is unavailable

## Changes

- **2026-10-21** `002d2efa258c`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/medianfi/apis/median-api/changes/accountant/companies/:customerId/documents/:documentId/re-extract/post.md)

---

[API](https://skmtc.dev/medianfi/apis/median-api.md) - [All operations](https://skmtc.dev/medianfi/apis/median-api/llms.txt) - [OpenAPI document](https://skmtc.dev/medianfi/apis/median-api/revisions/4f4c2d34276b?raw)
