One model call for a bookkeeping agent run
Changed onAgent key only; a person gets 403 AGENT_ONLY and the shared cloud-bookkeeping service token gets 404. The bookkeeping agent's only way to a model: the API sends the agent's instructions, input and output schema to the configured model under a fixed routing policy (zero data retention, an explicit provider allowlist that provider fallback never leaves, no model fallback) and returns the arguments of one forced tool call as data.output. The call must belong to an open run of the company (409 AGENT_RUN_NOT_OPEN) started today (UTC): a run started before today's 00:00 UTC is refused with 409 AGENT_RUN_DAY_ENDED, because the daily budget counts the spend of runs started today; the caller starts a new run. Refused for a disabled (409 AGENT_DISABLED) or stopped (409 AGENT_KILLED) company and for a patient-data-restricted one (403 AGENT_PHI_RESTRICTED). Spend is integer micro-USD, charged to the company's daily agent budget at once (added to the run's spend) and recorded as agent_decision usage (agent_simulation for a run with trigger simulation, which accepts no evidence, write or decision record: 409 AGENT_RUN_NOT_OPEN); its spend counts toward no other model cap. When the budget for today is spent the call is refused with 429 AGENT_BUDGET_EXHAUSTED. At most four model calls run at once per company; a fifth is refused with 429 AGENT_MODEL_CALL_IN_FLIGHT and may be retried when one finishes. A run's finish adds only the spend it reports beyond what this route already charged. No attempt may use the whole deadline (BK-023): each is cut off at AGENT_MODEL_ATTEMPT_TIMEOUT_MS (default 55 s) or at what is left of the deadline, and an attempt cut off at its own cap, or an answer with no usable tool call or missing an output.requiredFields field, is asked again at once while at least 10 s of the deadline is left. A failed model call answers 503 AGENT_MODEL_UNAVAILABLE (503 AGENT_MODEL_POLICY_VIOLATION when the provider broke the routing policy), with error.extensions.failureCode, error.extensions.usage (what the attempt cost) and error.extensions.finishReason and error.extensions.provider (the last answer's, null when no allowlisted provider answered); the same 503 AGENT_MODEL_UNAVAILABLE, without them, when the model is not configured. At a PHI-bounded company (phi_bounded_ingestion, read by the API; the body cannot say) the agent makes no model call: the call is refused with 403 AGENT_PHI_BOUNDED_NO_MODEL before any provider call and nothing is charged. A failed read of that flag answers 503. Mounted only when the deployment enables the bookkeeping agent (default off); otherwise 404. Writes no books and spends no write budget.
Request
- Base URLhttps://api.medianfi.com/api/v1
- AuthHTTP bearer
Path parameters
Request body
Response
Success envelope
Changes
- info
added the new optional request property
output/requiredFields - info
added the optional property
data/finishReasonto the response with the status - info
added the required property
data/usage/abortedAttemptsto the response with the status
- info