---
title: "Finish a bookkeeping agent run"
method: POST
path: "/accountant/companies/{customerId}/agent/runs/{runId}/finish"
tags: ["Accountant Portal"]
---

# Finish a bookkeeping agent run

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

## Request

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

Agent key only. Records outcomes and model spend in micro-USD, and for a `killed` run the stop reason the agent gives (`stopReason`). A run finished `failed` on its last allowed attempt, with nothing reserved, also creates one `bookkeeping_question` task on the company's primary accountant saying the transaction could not be processed automatically (source key `txn:<transaction>:unprocessed`); a reconciliation gets none, and the response is the same either way. 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

- BookkeepingAgentRunFinishInput
  - `status` 'applied' | 'queued' | 'blocked_phi' | 'capped' | 'killed' | 'failed', required
  - `outcomes` object[]
    - `evidenceId` string, uuid, required
    - `result` string, required
    - `after` unknown
  - `model` string
  - `provider` string
  - `promptTokens` integer
  - `completionTokens` integer
  - `costMicros` integer: Micro-USD.
  - `stopReason` 'window_open' | 'pairs_not_live' | 'categorize_not_live' | 'source_paused': Why a `killed` run stopped (422 with any other status). `window_open`, the row's document match waits for its date window to settle. `pairs_not_live`, the row is a card payment whose other side is in the books while `transfers.pairs` is not live for the company. `categorize_not_live`, the agent judged the row while `categorize` is not live for the company (F8), so nothing was written or asked. Kept on the run until it is reopened, and given as the run's `reasonCode` in the agent activity report.

## Response `200`

Success envelope

- object

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `409`: Run already finished
- `422`: Validation failed

## Changes

- **2026-11-26** `4a2098becaf9`: 2 info
  - added the new `categorize_not_live` enum value to the request property `stopReason`
  - added the new `source_paused` enum value to the request property `stopReason`
- **2026-10-29** `e1fc804546d3`: 1 info
  - endpoint added

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