---
title: "Unpost Opening Entries"
method: DELETE
path: "/companies/{company_id}/fiscal-years/{fiscal_year}/opening"
tags: ["accounting-settings"]
---

# Unpost Opening Entries

`DELETE /companies/{company_id}/fiscal-years/{fiscal_year}/opening`

## Request

- Base URL: `https://app.zeno-works.ch` (the document declares no server; this is the origin it was published from)
- URL: `https://app.zeno-works.ch/companies/{company_id}/fiscal-years/{fiscal_year}/opening`
- Auth: none declared

Unpost (delete) the seeded opening batch for a fiscal year (accountant).

Removes **both** planes in one transaction: the synthetic opening-seed
``AccountingImport`` for ``(company_id, fiscal_year)`` (CASCADE drops its
``JournalEntry`` / ``JournalLine`` rows only, and the freed posting accounts' usage
counts are recomputed), **and** the year's posted opening entries in the posting GL
(``gl_actions_service.unpost_opening_batch``).

Both legs, atomically, is the fix for ZET-220: ``gl_journal_entry`` carries no FK to
``accounting_import``, so removing the import alone left the GL rows ``posted`` —
still counted by every statement, and unreachable, because the *next* unpost 404s on
the handle that is already gone. That also makes this endpoint the **in-band repair**
for a year the old code already orphaned: it now answers 404 only when *neither*
plane had anything to remove.

**409** if the GL batch cannot be retired (closed period, locked entry, a reversal
naming it, a sealed VAT period) — nothing is removed from either plane in that case.
Company scope enforced on the path ``company_id`` (contract §8).

## Path parameters

- `company_id` string, required
- `fiscal_year` integer, required

## Headers

- `authorization` string, nullable

## Cookies

- `access_token` string, nullable

## Response `200`

Successful Response

- MsgResponse: The ``{"msg": "..."}`` envelope — the error contract and many successes.
  - `msg` string, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/zeno-works/apis/zeno-api.md) · [All operations](https://skmtc.dev/zeno-works/apis/zeno-api/llms.txt) · [OpenAPI document](https://skmtc.dev/zeno-works/apis/zeno-api/revisions/1eb93dde146c?raw)
