---
title: "Close the next ended GL period if it is ready"
method: POST
path: "/companies/{companyId}/close/trigger"
tags: ["GL Periods"]
---

# Close the next ended GL period if it is ready

`POST /companies/{companyId}/close/trigger`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/companies/{companyId}/close/trigger`
- Auth: HTTP bearer

Re-checks readiness for the period named by `periodId`, or else the
earliest ended open period. Only when it is ready does it post every
due schedule entry, generate the closing entry, mark the period
closed and update the books status. A close that cannot proceed
(not ready, already closed, a failed schedule posting, failed
clearing verification, or a closing entry that cannot be generated)
answers 200 with `closed: false` and a `reason`. Requires company
role admin or owner, the same authority as
`POST /companies/{companyId}/gl-periods/{id}/close`; API keys are
refused with 403 (#2411).

## Request body

- TriggerAutoCloseInput: Send `{}` to close the earliest ended open period.
  - `periodId` string, uuid: GL period to close. Omitted, the earliest ended open period is used.

## Response `200`

Close attempted; `closed` reports whether the period was closed

- AutoCloseResultResponse
  - `success` boolean, required
  - `data` AutoCloseResult, required
    - `companyId` string, uuid, required
    - `closed` boolean, required
    - `periodId` string, uuid, nullable, required
    - `reason` string, required
    - `closingEntryId` string, uuid, nullable: Closing journal entry for the period, or null when none was posted. Absent when the close stopped before posting schedule entries.
    - `scheduledPostings` AutoCloseScheduledPostings: Due schedule entries posted by this close. Absent when the close stopped before posting schedule entries.
      - `companyId` string, uuid, required
      - `periodEndDate` string, date, required
      - `postedCount` integer, required
      - `skippedCount` integer, required
      - `failedCount` integer, required
      - `postedEntryIds` string[], required
      - `failures` object[], required
        - `entryId` string, required
        - `scheduleId` string, required
        - `reason` string, required

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member

---

[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)
