---
title: "List candidate documents for a customer transaction"
method: GET
path: "/accountant/companies/{customerId}/transactions/{transactionId}/document-candidates"
tags: ["Accountant Documents"]
---

# List candidate documents for a customer transaction

`GET /accountant/companies/{customerId}/transactions/{transactionId}/document-candidates`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/accountant/companies/{customerId}/transactions/{transactionId}/document-candidates`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

The accountant-portal twin of /companies/{companyId}/transactions/{id}/document-candidates (#2013), read by the bookkeeping agent for every transaction it decides (zero questions, #2587; rule P32: the documents are searched before a question is asked). With `query` the company's documents are searched by text, beyond the newest ones. Refused with 403 AGENT_PHI_RESTRICTED to the agent's key for a patient-data-restricted company. At a PHI-bounded company (`phi_bounded_ingestion`) the agent's key is answered no candidates, with `documentsForModel: false` (a transaction that does not exist is still 404); a failed read of that flag answers the agent's key 503.

## Path parameters

- `customerId` string, uuid, required
- `transactionId` string, uuid, required

## Query parameters

- `query` string
- `limit` integer

## Response `200`

Ranked candidate documents, money-compatible with the transaction

- object
  - `success` boolean
  - `data` object
    - `candidates` TransactionDocumentCandidate[]
      - `document` object
        - `id` string, uuid
        - `name` string
        - `fileName` string
        - `type` 'invoice' | 'bill' | 'receipt' | 'contract' | 'statement': The DISPLAYED type, re-derived from metadata; may differ from the stored column.
        - `status` string
        - `vendorName` string, nullable
        - `customerName` string, nullable
        - `invoiceNumber` string, nullable
        - `amountCents` integer, nullable
        - `currency` string, nullable
        - `minorUnitExponent` integer, nullable
        - `docDate` string, nullable
        - `paymentStatus` string, nullable
        - `categoryGlAccountId` string, uuid, nullable: The account the document itself was given, if any.
      - `attachedTransactionId` string, nullable: The transaction this document is already attached to, or null when it is free. A matched but unpaid bill keeps this while its status stays `reviewed`, so status alone cannot tell the two apart. Attaching a marked candidate REPLACES the existing link.
      - `score` integer
      - `amountDiffCents` integer, nullable
      - `dateDiffDays` integer, nullable
      - `textScore` number
      - `rejectedByPerson` boolean: A person rejected this document's proposal for the transaction (Reject, not Unmatch). Left out with no query; with a query it is listed after every other document. The bookkeeping agent's read keeps it in place.
    - `documentsForModel` boolean: Present only for the bookkeeping agent's service key: whether these documents may reach its model. False at a PHI-bounded company (`phi_bounded_ingestion`), where `candidates` is always empty. A person's response has no such field.

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `422`: Request failed validation
- `503`: For the bookkeeping agent's service key only: the PHI-bounded company flag (`phi_bounded_ingestion`) could not be read, so no candidate is answered on a guess. Retry.

## Changes

- **2026-11-26** `4a2098becaf9`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/medianfi/apis/median-api/changes/accountant/companies/:customerId/transactions/:transactionId/document-candidates/get.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)
