---
title: "Record evidence before a write"
method: POST
path: "/accountant/companies/{customerId}/agent/runs/{runId}/evidence"
tags: ["Accountant Portal"]
---

# Record evidence before a write

`POST /accountant/companies/{customerId}/agent/runs/{runId}/evidence`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/accountant/companies/{customerId}/agent/runs/{runId}/evidence`
- Auth: HTTP bearer

Agent key only. Reserves the run's row cap atomically. There is no amount cap: the amount at stake is read from the target rows by the server and recorded on the evidence, and never refuses a record. The returned evidence id authorizes exactly one write on the named action and target, sent with the `X-Agent-Run-Id` and `X-Agent-Evidence-Id` headers. That write is refused, before its evidence is used, with 409 `AGENT_BOOKS_UNSOUND` and `extensions` `{ reason, unwaivedCount }` (#4323) unless the company's latest scheduled `current_month` integrity run finished under 26 hours ago, did not error, ran all 8 hard checks, and every hard-check violation is on an active waiver; `reason` is the first of `no_run_within_26h`, `run_errored`, `hard_check_not_run`, `hard_check_red`. Mounted only when the deployment enables the bookkeeping agent (default off); otherwise 404. The shared cloud-bookkeeping service token gets 404 here.

## Path parameters

- `customerId` string, uuid, required
- `runId` string, uuid, required

## Request body

- BookkeepingAgentEvidenceInput
  - `actionType` 'recategorize' | 'match_document' | 'match_transfer' | 'complete_reconciliation' | 'queue_task' | 'repair_duplicate_stripe_je' | 'run_revenue' | 'run_bills' | 'run_close', required
  - `targetType` string, required
  - `targetIds` string[], required
  - `before` unknown
  - `after` unknown
  - `sources` unknown[]
    - unknown
  - `reasoning` string
  - `confidence` number

## Response `201`

Success envelope

- object

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `409`: Run is not open, or the agent is disabled or stopped
- `422`: Cap reached (AGENT_CAP_EXCEEDED) or validation failed

## Changes

- **2026-11-28** `629ac127e9e4`: 3 info
  - added the new `run_bills` enum value to the request property `actionType`
  - added the new `run_close` enum value to the request property `actionType`
  - added the new `run_revenue` enum value to the request property `actionType`
- **2026-11-26** `4a2098becaf9`: 1 info
  - added the new `repair_duplicate_stripe_je` enum value to the request property `actionType`
- **2026-10-29** `e1fc804546d3`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/medianfi/apis/median-api/changes/accountant/companies/:customerId/agent/runs/:runId/evidence/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)
