---
title: "Run the accrual detector for a period before locking it"
method: POST
path: "/accountant/companies/{customerId}/month-end-close/run-detection"
tags: ["Accountant Portal", "Schedule Proposals"]
---

# Run the accrual detector for a period before locking it

`POST /accountant/companies/{customerId}/month-end-close/run-detection`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/accountant/companies/{customerId}/month-end-close/run-detection`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

The month-end close page's "Run detection" step (#1266). Runs the period-aware accrual detector for one GL period of this customer; the deferral detector is not run here (it runs on every sync). The lock does not depend on this call, and a successful lock starts the same sweep for its period in the background afterwards.

It never posts a journal entry, creates a schedule, approves a proposal, or changes close or period state. It can create proposals (some created `blocked` by the QA gate), supersede an older live proposal for the same candidate when its inputs changed or its real charge has posted, move an approved-but-unposted proposal to `blocked` when its real charge has posted, close the low-confidence review task of a proposal it supersedes, and write decision-manifest rows and audit events. If the detector fails midway, the proposals that run created are expired.

Bounded by a 20-second budget; a sweep that runs past it is reported as `timed_out` and may still finish afterwards. `detection_off` when `accruals_deferrals_detection` is off for the company (nothing runs). `partial` when some candidates could not be judged; `skipped` says why. A filing-locked period is refused with 422; open and closed periods are accepted.

## Request body

- MonthEndRunDetectionInput
  - `periodId` string, uuid, required: The GL period to detect accruals and deferrals for.

## Response `200`

What the detection run did

- MonthEndRunDetectionResponse
  - `success` boolean
  - `data` object
    - `status` 'completed' | 'partial' | 'detection_off' | 'timed_out' | 'not_available', required: `completed`: every candidate was judged. `partial`: some candidates could not be judged (see `skipped`). `detection_off`: the company's detection flag is off. `timed_out`: the 20-second budget ran out. `not_available`: the detector stack is not wired here. All counts are 0 unless the status is `completed` or `partial`.
    - `periodId` string, uuid, required
    - `periodEndDate` string, date, required
    - `proposalsCreated` integer, required: New proposals awaiting review.
    - `blocked` integer, required: New proposals the QA gate created as `blocked` (for example a missing account).
    - `superseded` integer, required: Older live proposals superseded because their real charge has posted.
    - `approvedBlocked` integer, required: Approved-but-unposted proposals moved to `blocked` because their real charge has posted.
    - `candidatesEvaluated` integer, required
    - `skipped` object, required: Candidates the detector could not judge. Any non-zero entry makes the run `partial`.
      - `modelUnavailable` integer, required: The model call failed, timed out, was over the company's budget, or is not configured.
      - `qaInvalid` integer, required
      - `unsupportedCurrency` integer, required
      - `unresolvedCounterparty` integer, required
      - `scopeBlocked` string, nullable, required: Set when the whole sweep was refused because the company's records are not tied to a single legal entity.

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `409`: Detection is already running for this company and period
- `422`: Invalid body, or the period is filing-locked
- `503`: The accountant's assignment could not be verified right now

---

[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/20090ea32b0d?raw)
