Beacon

Fiscal API

View as Markdown

Fiscal API

Beacon self-service fiscal onboarding, canonical setup-state, and issuance endpoints for PT operations.

reference • updated 2026-03-17

Goal

Control fiscal onboarding, issuance, reconciliation, and canonical setup state without exposing internal provider details.

Primary endpoints

EndpointFunctionTypical usage
POST /api/fiscal/engine/provision?org={slug}&mode={test|live}starts Beacon-managed provisioningwhen the organization becomes eligible or an admin wants to resume setup
POST /api/fiscal/setup/at?org={slug}&mode={test|live}stores and validates TA credentialswhen the wizard asks for Configure TA in live
POST /api/fiscal/tax-authority/series/communicate?org={slug}&mode={test|live}communicates the default serieswhen blockedSubcode = series_not_reported
PUT /api/fiscal/tax-authority/saft/automatic?org={slug}&mode={test|live}enables automatic SAF-Twhen blockedSubcode = saft_disabled
POST /api/fiscal/setup/self-heal?org={slug}&mode={test|live}runs a closed wizard actionwhen the CTA can be resolved without extra input
POST /api/fiscal/setup/preview?org={slug}&mode={test|live}generates a deterministic preview PDFbefore the first live issuance or for internal demos
GET /api/fiscal/overview?org={slug}&mode={test|live}aggregate fiscal statusdaily monitoring and operational handover
GET /api/fiscal/documents?org={slug}&mode={test|live}list fiscal documentsdaily operations and investigation
POST /api/fiscal/documents?org={slug}&mode={test|live}issue manual fiscal documentsafter eligible commercial events
POST /api/fiscal/reconciliation?org={slug}&mode={test|live}queue reconciliationdaily/month-end close or incident response
GET /api/fiscal/setup-state?org={slug}&mode={test|live}single source of fiscal truthwhenever the frontend needs the next CTA, block reason, or readiness

setup-state contract

  • The endpoint returns an envelope { ok, state, context }; the functional object is nested under state.
  • state.state returns the canonical text state (ready, pending:*, blocked:<subcode>).
  • state.blockedSubcode lets the UI map clean CTAs such as Configure TA, Communicate series, and Enable automatic SAF-T.
  • state.cta, state.canRetry, and state.nextRetryAt exist so the frontend can render without private logic.
  • state.issuanceContextOptions returns the public default store and series options for the wizard, with no parallel catalog read.
  • state.profile, state.checklist, state.blockingReasons, state.wizardRequired, and state.canIssueNow expose current operational progress.
  • The flow is white-label: customers never submit provider tokens, secrets, or endpoints.
  • Preview always returns a deterministic PDF with the RASCUNHO - SEM VALOR FISCAL watermark.
  1. 11) Managed provisioning

    Call engine/provision without client tokens. Beacon creates or resumes the internal organization context.
  2. 22) Read setup-state

    The frontend reads setup-state and renders the exact CTA for the current block.
  3. 33) Configure TA in live

    Use setup/at to store encrypted tax authority credentials and validate access only in live.
  4. 44) Resolve canonical blockers

    Use series/communicate, saft/automatic, or setup/self-heal until setup-state returns ready.
  5. 55) Preview and operate

    Generate setup/preview with zero side effects and only then use documents and reconciliation.

Environments

  • test always uses a demo/sandbox flow, must never call the real tax authority, and treats TA setup as optional in the wizard.
  • In test, if the provider omits final fiscal compliance fields, Beacon synthesizes sandbox-only markers so the final PDF still renders with the Beacon template.
  • live uses real TA/SAF-T validations and requires all controls before issuance activation.

Common blocked states

blockedSubcodeMain CTAMeaning
at_credentials_invalidConfigure TAtax authority credentials failed
series_not_reportedCommunicate seriesthe default series was not reported yet
saft_disabledEnable automatic SAF-Tautomatic submission is disabled
customer_data_incompleteComplete customer datafiscal data or default context is missing
provider_unavailableTry again latertemporary technical outage