Accounting Pieces
4 operações em Quadra Core API 0.5.0.
/v1/books/{scope_id}/daybookLivro Diário — every entry set on an account, refused sets included
The Livro Diário of one account: each entry set with **all** its legs, in order, and each refused set as a fact of the period (no legs, its reason). Give ``period`` **or** ``from``+``to``. Every payload carries ``basis``: ``CLOSE_RECORD`` for a closed period, ``LIVE`` otherwise.
Raises: 400: INVALID_QUERY, INVALID_PERIOD, INVALID_CURSOR 404: ACCOUNT_NOT_FOUND (also for estate accounts) 409: CURSOR_STALE (the period's close changed mid-paging)
Parâmetros
| Nome | Tipo | Detalhe |
|---|---|---|
| scope_id | string | pathobrigatório |
| period | string, opcional | query YYYY-MM — answered from the close record when CLOSED |
| from | string, opcional | query Inclusive first accounting day (with 'to'; ≤ 366 days) |
| to | string, opcional | query Inclusive last accounting day |
| cursor | string, opcional | query Opaque; from the previous page |
| limit | integer | query Entry sets per page |
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 200 | DaybookResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/books/{scope_id}/ledgerRazão — an account's legs per GL node, with running balances
The Razão of one account. The first page carries the per-node summary (opening, period, closing); every page carries running balances.
Raises: 400: INVALID_QUERY, INVALID_PERIOD, INVALID_CURSOR 404: ACCOUNT_NOT_FOUND (also for estate accounts) 409: CURSOR_STALE
Parâmetros
| Nome | Tipo | Detalhe |
|---|---|---|
| scope_id | string | pathobrigatório |
| period | string, opcional | query YYYY-MM — answered from the close record when CLOSED |
| from | string, opcional | query Inclusive first accounting day (with 'to'; ≤ 366 days) |
| to | string, opcional | query Inclusive last accounting day |
| gl_node_id | string, opcional | query Only this GL node's legs |
| cursor | string, opcional | query Opaque; from the previous page |
| limit | integer | query Legs per page |
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 200 | LedgerResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/books/{scope_id}/trial-balanceBalancete — an account's per-node totals as a tree, with the DRE's input
The balancete of one account. For a CLOSED period the rows **are the close record's**, and ``rederivation`` says whether they still re-derive; a disagreement answers 200 with the record's numbers and is logged loudly. ``cross_check`` is the three-way agreement (record, Razão, Diário).
The DRE is not here: its layout is the BFF's. ``by_event_kind`` is its input.
Raises: 400: INVALID_QUERY, INVALID_PERIOD 404: ACCOUNT_NOT_FOUND (also for estate accounts)
Parâmetros
| Nome | Tipo | Detalhe |
|---|---|---|
| scope_id | string | pathobrigatório |
| period | string, opcional | query YYYY-MM — answered from the close record when CLOSED |
| from | string, opcional | query Inclusive first accounting day (with 'to'; ≤ 366 days) |
| to | string, opcional | query Inclusive last accounting day |
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 200 | BooksTrialBalanceResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/exports/manifestExport manifest — everything in an account's export box, with content hashes
The completeness manifest for "exportar tudo" (R5): every entry set, refusal, annotation, close record, journal entry, checkpoint and fiscal-document file for one account in the window, each with a content hash, and the epoch floor stated. The BFF assembles the archive; Core never holds document bytes.
⛔ Never truncates: past its item cap it answers 422 MANIFEST_TOO_LARGE.
Raises: 400: INVALID_QUERY 404: ACCOUNT_NOT_FOUND (also for estate accounts) 422: MANIFEST_TOO_LARGE
Parâmetros
| Nome | Tipo | Detalhe |
|---|---|---|
| scope_id | string | queryobrigatório The account to export |
| from | string | queryobrigatório Inclusive first accounting day |
| to | string | queryobrigatório Inclusive last accounting day (≤ 366 days) |
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 200 | ExportManifestResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
Esquemas
Os modelos que as operações acima aceitam e devolvem. Campos opcionais estão marcados como tal; um campo tipado como outro modelo está documentado sob o nome dele.
AttestationState
Whether the artifact this response carries has been attested, as it is now.
| Campo | Tipo | Detalhe |
|---|---|---|
| authorizations | integer | Acts that authorised a change to the artifact rather than vouching for it (REABERTURA_AUTORIZADA). ⛔ Never counted toward ATTESTED, records or superseded_count: authorising a reopen is not approving the closePadrão 0 |
| current_subject_hash | string, opcional | The artifact's hash now — what an attestation written now must carry |
| reason | string, opcional | Why the status is not ATTESTED: PENDING_ACCOUNTANT_REVIEW, ARTIFACT_CHANGED_SINCE_ATTESTED, PERIOD_NOT_CLOSED, WINDOW_NOT_A_CLOSED_PERIOD, NO_CORRECTION_RECORDED, SUBJECT_NOT_FOUND |
| records | array de AttestationRecord | obrigatórioThe records that bind current_subject_hash, newest first. Empty unless ATTESTED |
| status | "ATTESTED" | "PENDING_ACCOUNTANT_REVIEW" | "SUPERSEDED" | "NOT_ATTESTABLE" | obrigatórioATTESTED — at least one record binds the artifact's current hash. PENDING_ACCOUNTANT_REVIEW — attestable, and nobody has. SUPERSEDED — records exist, but the artifact changed after every one of them (a reopened and re-closed period, a document that moved). NOT_ATTESTABLE — there is nothing to sign yet (an open period), and reason says why. |
| subject_id | string | obrigatório |
| subject_kind | string | obrigatório |
| superseded_count | integer | obrigatórioRecords that bind an earlier version |
BooksBasis
Which window a piece answered and whether it came from a stored close.
| Campo | Tipo | Detalhe |
|---|---|---|
| close_seq | integer, opcional | The close answered from (CLOSE_RECORD only) |
| closed_at | string, opcional | When that close was performed |
| covered_from | string, opcional | First day the entry model can describe — the opening epoch's day when the window starts before it; null when the window ends before it |
| epoch_at | string, opcional | The ledger's opening-epoch instant |
| floor | string, opcional | Set when the window touches the epoch floor |
| kind | string | obrigatórioCLOSE_RECORD — the numbers are the stored close's, re-derived and compared; LIVE — they can still move. ⚠️ An OPEN or REOPENED period is LIVE, and so is every day range. |
| live | boolean | obrigatórioTrue unless kind is CLOSE_RECORD |
| period | string, opcional | YYYY-MM when the request named a period |
| period_state | string, opcional | OPEN | CLOSED | REOPENED |
| record_hash | string, opcional | That close's record_hash |
| statement | string | obrigatórioThe basis in one sentence, for display |
| window_from | string | obrigatórioFirst accounting day (América/São_Paulo) |
| window_to | string | obrigatórioLast accounting day, inclusive |
BooksTrialBalanceResponse
The balancete for one account.
| Campo | Tipo | Detalhe |
|---|---|---|
| attestation | AttestationState | obrigatórioThe CRC attestation of the close this piece is answered from (PERIOD; NOT_ATTESTABLE on a LIVE basis) (contabil-07, catalog R1). Always present: status says whether it is attested, pending review, superseded, or not yet attestable — never a bare null. |
| basis | BooksBasis | obrigatório |
| by_event_kind | array de object, opcional | This account's legs per (event_kind, layer, asset) — the DRE's input. Revenue for inbound fiscal kinds is booked on the payer's leg, so it never appears in this account's nodes; its event_kind does. The DRE layout is the BFF's. |
| by_event_kind_agrees | boolean, opcional | Σ over kinds == totals |
| by_event_kind_basis | string | obrigatórioRECOMPUTED_FROM_REPRODUCED_LEGS on a CLOSE_RECORD basis (a close stores no per-kind numbers), else LIVE |
| cross_check | object | obrigatórioThe three-way agreement: record_totals, razao_totals (GSI1 legs), diario (the base-table legs of every set, with every_set_balanced), agrees. |
| nodes | array de object | obrigatórioPer (gl_node_id, layer, asset): dr/cr/net_cents (net = dr − cr, the close record's convention), rendered_net_cents (by normal_balance), and the node's name/type/parent_account_id. On a CLOSE_RECORD basis these ARE the record's rows. |
| rederivation | object, opcional | CLOSE_RECORD only. status agrees | disagrees | not_reproducible_superseded | not_attempted; diffs; late_postings (sets posted after the close, excluded by the projector's own annotation, never by a timestamp); set_membership (digest, or annotation_rule_only for a pre-v3 record). A disagreement answers 200 with the record's numbers, logs at ERROR and counts PieceRederivationMismatch. |
| scope_id | string | obrigatório |
| totals | object | obrigatórioPer layer|asset totals. ⚠️ Never zero for one account: the other side of every set sits on another account. Balance is asserted per entry set. |
| trees | array de object | obrigatórioOne tree per layer|asset, nested by parent_account_id, with subtree_dr/cr and subtree_net_cents rendered by each node's own normal_balance. Orphans and cycles become roots with parent_missing / cycle set. |
DaybookResponse
One page of the Livro Diário for one account.
| Campo | Tipo | Detalhe |
|---|---|---|
| attestation | AttestationState | obrigatórioThe CRC attestation of the close this piece is answered from (PERIOD; NOT_ATTESTABLE on a LIVE basis) (contabil-07, catalog R1). Always present: status says whether it is attested, pending review, superseded, or not yet attestable — never a bare null. |
| basis | BooksBasis | obrigatório |
| items | array de object | obrigatórioIn GSI1 sort-key order (effective_at, then tx hash) — ⚠️ not strictly accounting_day order when an effective_at carries a numeric offset. kind=ENTRY_SET carries every leg of the set (a counterparty the caller may not see has account_id null and redacted=true), balanced (Σ DR = Σ CR per asset|layer over the base-table legs), matches_header (== the set's layer_totals), annotations, and in_close — false for a set posted into this closed period after its close, null on a LIVE basis. kind=REFUSED_SET is a set the projector refused: no legs, its reason, positioned by the São Paulo day of its confirmation because a refusal has no effective time. |
| next_cursor | string, opcional | Opaque and bound to this scope, window and basis. A cursor from another question is a 400; a closed-basis cursor whose close changed mid-paging is a 409 CURSOR_STALE. Page until null. |
| scope_id | string | obrigatório |
| unattributed_refusals_in_window | integer | obrigatórioEstate-wide count of refusals no account could be named for. Carries no identifiers by design; resolving one is an operator task. |
ExportManifestResponse
Everything that belongs in one account's export box, each with a content hash.
| Campo | Tipo | Detalhe |
|---|---|---|
| attestable_hash | string | obrigatóriomanifest_hash without the ATTESTATION and CHECKPOINT items — the hash a PIECE attestation binds. Attesting the box never changes it, and neither does a checkpoint sealing the tail |
| attestation | AttestationState | obrigatórioThe CRC attestation of this box as the month's escrituração (PIECE) — NOT_ATTESTABLE unless the window is exactly one CLOSED month (contabil-07, catalog R1). Always present: status says whether it is attested, pending review, superseded, or not yet attestable — never a bare null. |
| counts | object | obrigatório |
| floor | object | obrigatórioepoch_at, covered_from, window_starts_before_floor and the statement: nothing before the opening epoch is derivable from entries (RFC-025 D6). |
| hash_spec | object | obrigatórioExactly what each content_hash covers |
| items | array de object | obrigatórioSorted by (kind, id). Kinds: ENTRY_SET, ANNOTATION, REFUSED_SET, PERIOD_CLOSE (every close, superseded ones included), JOURNAL_ENTRY (this account's own), CHECKPOINT, FISCAL_DOCUMENT (one per stored file), ATTESTATION (every CRC attestation of a subject in the box, superseded ones included). |
| journal_range | object | obrigatórioThe journal seq range the window maps to, and uncovered_from_seq when the newest entries are not sealed by a checkpoint yet |
| kinds_not_available | object | obrigatórioKinds no ticket has built yet |
| manifest_hash | string | obrigatóriosha256 over the sorted (kind, id, content_hash) triples |
| manifest_version | integer | obrigatório |
| periods | array de object | obrigatórioEvery month the window touches, with its state |
| scope_id | string | obrigatório |
| sources | object | obrigatórioWhere the bytes behind each kind are fetched from |
| window_from | string | obrigatório |
| window_to | string | obrigatório |
HTTPValidationError
| Campo | Tipo | Detalhe |
|---|---|---|
| detail | array de ValidationError |
LedgerResponse
One page of the Razão for one account.
| Campo | Tipo | Detalhe |
|---|---|---|
| attestation | AttestationState | obrigatórioThe CRC attestation of the close this piece is answered from (PERIOD; NOT_ATTESTABLE on a LIVE basis) (contabil-07, catalog R1). Always present: status says whether it is attested, pending review, superseded, or not yet attestable — never a bare null. |
| basis | BooksBasis | obrigatório |
| gl_node_id | string, opcional | The node filter, when given |
| items | array de object | obrigatórioThis account's legs with running_balance_cents per node|layer|asset. On a CLOSE_RECORD basis a late posting is listed with in_close=false and does not move the running balance. |
| next_cursor | string, opcional | Opaque; bound like the Diário's. Page until null. |
| scope_id | string | obrigatório |
| summary | object, opcional | First page only. opening_basis (CLOSE_RECORDS when every month back to the epoch is closed, else LIVE), period_basis, and per node|layer|asset: opening_cents, dr/cr/net_cents for the window (the record's on a CLOSE_RECORD basis), closing_cents. Signed DR-positive (dr − cr); render with normal_balance. |
ValidationError
| Campo | Tipo | Detalhe |
|---|---|---|
| ctx | object | |
| input | não declarado | |
| loc | array de string ou integer | obrigatório |
| msg | string | obrigatório |
| type | string | obrigatório |