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

# Start a bookkeeping agent run

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

## Request

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

Agent key only. One run per work item: the work item key is the lease. A run that ended without writing anything may be handed back under its key (failed with attempts left, or stopped by the patient-data flag or the kill switch), and only to a start with the trigger it was started with; any other start answers 409 `AGENT_WORK_ITEM_TAKEN`. A stopped run with no decision recorded under its attempt is handed back under the same `attempts`: it uses none of the three. One writing run per company: a start with any trigger but `simulation` answers 409 `AGENT_COMPANY_LEASE_HELD` while another work item's writing run is open on the company; simulation runs neither take nor respect this. A run still open 8 minutes after it started is ended as failed before the start is decided. 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

## Request body

- BookkeepingAgentRunInput
  - `workItemKey` string, required
  - `trigger` 'transaction' | 'task_answer' | 'replay' | 'held' | 'simulation', required

## Response `201`

Success envelope

- object

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `409`: Work item already has a run (AGENT_WORK_ITEM_TAKEN), another writing run is open on this company (AGENT_COMPANY_LEASE_HELD), or the agent is disabled (AGENT_DISABLED) or stopped (AGENT_KILLED) for this company
- `429`: Daily model budget spent (AGENT_BUDGET_EXHAUSTED)

## Changes

- **2026-10-29** `e1fc804546d3`: 1 info
  - endpoint added

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