---
title: "Update a document"
method: PATCH
path: "/companies/{companyId}/documents/{id}"
tags: ["Documents"]
---

# Update a document

`PATCH /companies/{companyId}/documents/{id}`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/companies/{companyId}/documents/{id}`
- Auth: HTTP bearer

## Request body

- UpdateDocumentInput
  - `type` 'invoice' | 'bill' | 'receipt' | 'contract' | 'statement'
  - `status` 'needs_review' | 'reviewed' | 'processed' | 'archived'
  - `name` string
  - `vendorName` string, nullable
  - `customerName` string, nullable
  - `invoiceNumber` string, nullable
  - `amountCents` integer, nullable
  - `currency` string, nullable: Must be supplied atomically with amountCents; non-null values are normalized to uppercase and restricted to registered scale-two ISO 4217 currencies.
  - `categoryGlAccountId` string, nullable
  - `dueDate` string, nullable
  - `fileKey` string, nullable: `null` detaches the file. A string must reference an accepted stored file of the same company (a `clean` file, or the file the upload flow stored for it); any other key, including a quarantine key, is rejected with 422.
  - `fileUrl` string, nullable
  - `sizeBytes` integer, nullable
  - `fileName` string, nullable
  - `mimeType` string, nullable
  - `transactionId` string, nullable
  - `category` string, nullable
  - `docDate` string, nullable
  - `notes` string, nullable
  - `metadata` object

## Response `200`

Document updated

- DocumentResponse
  - `success` boolean, required
  - `data` Document, required
    - `id` string, uuid, required
    - `entityId` string, uuid, nullable, required
    - `type` 'invoice' | 'bill' | 'receipt' | 'contract' | 'statement', required
    - `status` 'needs_review' | 'reviewed' | 'processed' | 'archived', required
    - `name` string, required
    - `vendorName` string, nullable, required
    - `customerName` string, nullable, required
    - `invoiceNumber` string, nullable, required
    - `amountCents` integer, nullable, required: Document total in the persisted currency's authoritative minor units; null only for true-empty intake.
    - `amountPaidCents` integer, nullable, required: Server-owned sum of applied, same-entity, same-currency payment matches; null with a true-empty document amount.
    - `outstandingAmountCents` integer, nullable, required: Exact amountCents minus amountPaidCents; null with a true-empty document amount.
    - `currency` string, nullable, required: Certified ISO 4217 currency; null only for true-empty document money.
    - `minorUnitExponent` 2 | null, nullable, required: Public scale authority for every non-null document amount.
    - `paymentStatus` 'open' | 'partial' | 'paid' | 'null', nullable, required: Server-owned bill rollup status; null for non-bills.
    - `uploadedAt` string, date-time, required
    - `dueDate` string, date, nullable, required
    - `sizeBytes` integer, nullable, required
    - `transactionId` string, uuid, nullable, required
    - `category` string, nullable, required
    - `docDate` string, date, nullable, required
    - `sourceProvider` string, nullable, required
    - `sourceRefs` object[], required
      - `type` string, required
      - `id` string, required
      - `label` string, nullable, required
    - `externalViewUrl` string, nullable, required
    - `hasProposedMatch` boolean, required: Derived. True when the engine has a proposed (not yet applied) match for this document. Drives the feed's "Review match" call-to-action.
    - `possibleDuplicateOf` object, nullable, required: Derived on the documents list only; null on every other response. The earliest-created live document of the same company, entity and type with the same counterparty (vendor, or customer when there is no vendor), invoice number, document date and amount. Null when this document is that earliest one, has no such twin, or is missing any of the four fields. A marker only: both documents stay listed.
      - `id` string, uuid, required
      - `name` string, required
    - `downloadUrl` string: Optional short-lived signed download authority when a file is available to the authenticated actor.

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Document not found
- `422`: Validation error

---

[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/20090ea32b0d?raw)
