---
title: "Record one decision of the agent, to learn from"
method: POST
path: "/accountant/companies/{customerId}/agent/runs/{runId}/decisions"
tags: ["Accountant Portal"]
---

# Record one decision of the agent, to learn from

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

## Request

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

Agent key only, into an open run that is not a simulation run (trigger `simulation`: 409 `AGENT_RUN_NOT_OPEN`). Keeps what the model was shown (ids and hashes) and answered (account, confidence, citations), how the decision was reached and its cost. One row per run attempt: a retry returns the row already recorded (200). Every transaction and account named must belong to the company, and the evidence to the run (422 otherwise). 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

- BookkeepingAgentDecisionInput: One decision of the agent, kept to learn from. Ids, codes, numbers and hashes only: free text in any field is refused (422).
  - `transactionId` string, uuid
  - `evidenceId` string, uuid
  - `decisionPath` 'model' | 'answer_rule' | 'precedent_rule' | 'guard' | 'model_timeout' | 'model_error' | 'skipped', required
  - `finalAction` 'recategorize' | 'match_document' | 'match_transfer' | 'complete_reconciliation' | 'queue_task' | 'repair_duplicate_stripe_je' | 'run_revenue' | 'run_bills' | 'run_close'
  - `reasonCode` string
  - `modelAction` string
  - `proposedGlAccountId` string, uuid
  - `modelConfidence` number
  - `cited` object[]
    - `kind` 'history' | 'rule' | 'document' | 'policy' | 'transfer_proposal' | 'reconciliation' | 'accountant_answer' | 'merchant' | 'bank_category' | 'memo', required
    - `id` string, required
  - `shown` object
    - `samePayee` object[]
      - `id` string, uuid, required
      - `glAccountId` string, uuid, nullable, required
      - `precedent` boolean, required
    - `counts` object
    - `clientContext` object[]: The load receipt (Penny plan v2 D3) - each client context entry the run sent, at its version. The version row records its source and commit.
      - `id` string, uuid, required
      - `version` integer, required
  - `payloadSha256` string
  - `instructionsSha256` string
  - `policySha256` string
  - `workerCommit` string
  - `model` string
  - `provider` string
  - `params` object
  - `promptTokens` integer
  - `completionTokens` integer
  - `cachedTokens` integer
  - `reasoningTokens` integer
  - `costMicros` integer
  - `latencyMs` integer
  - `httpAttempts` integer
  - `finishReason` string

## Response `200`

The decision this run attempt already recorded

- object

## Other responses

- `201`: Success envelope
- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `409`: Run is not open, or is a simulation run (AGENT_RUN_NOT_OPEN)
- `422`: Validation failed (free text, or an id outside the company or run)

## Changes

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

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