---
title: "Analyze Document"
method: POST
path: "/onboarding/analyze-document"
tags: ["onboarding"]
---

# Analyze Document

`POST /onboarding/analyze-document`

## 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/onboarding/analyze-document`
- Auth: none declared

Stage the uploaded document, run doculyse + the pure extractor (eligible).

Stateless: stages the bytes in the transient blobstore (so the create can read them
back by ``staging_ref``) and returns the structured extraction, writing nothing to
the DB. **422** when the document's fiscal year cannot be determined; **413** when the
file exceeds the upload cap or the analyzer's own (lower) one; **503** when doculyse is
unreachable. Rate-limited per user (LLM call).

## Headers

- `authorization` string, nullable

## Cookies

- `access_token` string, nullable

## Response `200`

Successful Response

- AnalyzeDocumentResponse: ``POST /onboarding/analyze-document`` → the structured extraction (no DB write).
  - `staging_ref` string, required
  - `doc_types_found` string[]
  - `warnings` string[]
  - `chart_accounts` OnboardingChartAccountIn[]
    - `account_number` string, required
    - `account_name` string, nullable
    - `category` 'asset' | 'liability' | 'equity' | 'income' | 'expense' | 'tax' | 'other' | 'unknown': The account-type axis of a ledger account (Swiss-KMU chart of accounts). Distinct from — but derived from — ``LineRole`` (the journal-line semantic role). ``unknown`` is the conservative default when classification can't decide; ``other`` covers genuinely ambiguous / closing (9xxx) accounts.
    - `is_profit_loss` boolean
    - `is_contra` boolean
    - `is_intentional` boolean
    - `account_number_guess` string, nullable
    - `journal_usage_count` integer
    - `prior_year_turnover_cents` integer, nullable
    - `prior_year_turnover_fiscal_year` integer, nullable
  - `balance_snapshots` OnboardingBalanceSnapshotIn[]
    - `fiscal_year` integer, required
    - `as_of_date` string, date, nullable
    - `currency` string, required
    - `lines` OnboardingBalanceLineIn[]
      - `line_id` string, nullable
      - `account_number` string, required
      - `account_name` string, nullable
      - `category` 'asset' | 'liability' | 'equity' | 'income' | 'expense' | 'tax' | 'other' | 'unknown': The account-type axis of a ledger account (Swiss-KMU chart of accounts). Distinct from — but derived from — ``LineRole`` (the journal-line semantic role). ``unknown`` is the conservative default when classification can't decide; ``other`` covers genuinely ambiguous / closing (9xxx) accounts.
      - `side` 'credit' | 'debit', required
      - `amount_cents` integer, required
      - `sign_display` string, nullable
      - `needs_review` boolean
      - `is_contra` boolean
      - `comparative_amount_cents` integer, nullable
    - `totals` object
    - `resolution_json` object, nullable
    - `equity_roles` object, nullable
    - `source_document_ref` string, nullable
    - `comparative_period_label` string, nullable
    - `founding` boolean, nullable: ZET-395: the answer to 'founding balance sheet (Gründungsbilanz) or closing sheet?'. true = the company's founding balance sheet: stored as its own kind (status 'founding') under its fiscal_year, which must be the create's first year, and that year's opening is generated from it on its as_of_date. false = the year's closing sheet (the historical behaviour). Asked for when as_of_date lies inside the company's first fiscal year before its end: left unset, the sheet is held for the question under Settings -> Opening (a pending change set with summary.founding_question) instead of becoming the year's closing sheet, and opening entries are refused (422). Not needed for a sheet dated on the year-end. Unset on analyze output.
  - `fiscal_year_summaries` OnboardingFiscalYearSummaryIn[]
    - `fiscal_year` integer, required
    - `net_result_cents` integer, nullable
    - `period_start` string, date, nullable
    - `period_end` string, date, nullable
  - `vat_contents` object[]

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