SonaCORE

Referência / Quadra Command API

Fiscal Operations

8 operações em Quadra Command API 0.2.0.

POST/v1/fiscal/das

Emit the DAS for a competência and record it as a GUIA

Emit the DAS for a transmitted competência through the tenant's bound fiscal provider, and record it as a `GUIA` fiscal document (born `EMITIDO`).

References only: the response and the document carry the guia's number, due date, amounts and the PDF's sha256 — never the PDF.

Requires an `Idempotency-Key` header; a retry on the same key writes the guia once.

Raises: 404: ACCOUNT_NOT_FOUND 409: FISCAL_NOT_AUTHORIZED, IDEMPOTENCY_KEY_REUSED 422: FISCAL_PROVIDER_UNKNOWN, FISCAL_OPERATION_NOT_SUPPORTED, FISCAL_REJECTED (e.g. NO_DECLARATION, BELOW_MINIMUM_DEBIT) 503: FISCAL_PROVIDER_UNAVAILABLE, FISCAL_BINDING_BROKEN

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

DasEmissionRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201FiscalOperationResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
POST/v1/fiscal/nfse/cancellations

Cancel an authorised NFS-e with the emitente's signature

Submit the signed cancellation. The note lands `CANCELADA`; a refusal — the município's deadline passed (`CANCEL_WINDOW_CLOSED`), or the note is already closed — leaves it `AUTORIZADA`.

Raises: 404: ACCOUNT_NOT_FOUND, FISCAL_DOCUMENT_NOT_FOUND 409: FISCAL_DOCUMENT_STATE, IDEMPOTENCY_KEY_REUSED 422: FISCAL_REJECTED (SIGNER_NOT_EMITTER, SIGNATURE_INVALID, CANCEL_WINDOW_CLOSED, NFSE_ALREADY_CLOSED), FISCAL_OPERATION_NOT_SUPPORTED 503: FISCAL_PROVIDER_UNAVAILABLE, FISCAL_BINDING_BROKEN

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

NfseCancellationRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201NfseSigningResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
POST/v1/fiscal/nfse/cancellations/preparations

Prepare the cancellation of an authorised NFS-e for the emitente to sign

Build the cancellation event (e101101) of an authorised note and answer its `signing_request`, plus the `dh_evento` to send back on submission. The deadline is the município's, enforced by the platform when the event is submitted.

Raises: 404: ACCOUNT_NOT_FOUND, FISCAL_DOCUMENT_NOT_FOUND 409: FISCAL_DOCUMENT_STATE, IDEMPOTENCY_KEY_REUSED 422: FISCAL_PROVIDER_UNKNOWN, FISCAL_OPERATION_NOT_SUPPORTED, FISCAL_REJECTED (INVALID_REQUEST), INVALID_COMPETENCIA, INVALID_SERIE, SUBSTITUTION_REASON_REQUIRED, or a validation error 503: FISCAL_PROVIDER_UNAVAILABLE, FISCAL_BINDING_BROKEN

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

NfseCancellationPreparationRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201NfseSigningResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
POST/v1/fiscal/nfse/preparations

Prepare an NFS-e for the emitente to sign

Build the note's DPS and answer a `signing_request` — the canonical SignedInfo bytes and the algorithm — for the **emitente's own device** to sign. The note is recorded as an `NFSE` fiscal document in `AGUARDANDO_ASSINATURA`.

Nothing is sent to the platform yet. Pass `doc_id` to prepare a draft or a rejected note again (it keeps its DPS number); pass `replaces` and `substituicao` to prepare a note that substitutes an authorised one.

Raises: 404: ACCOUNT_NOT_FOUND, FISCAL_DOCUMENT_NOT_FOUND 409: FISCAL_DOCUMENT_STATE, IDEMPOTENCY_KEY_REUSED 422: FISCAL_PROVIDER_UNKNOWN, FISCAL_OPERATION_NOT_SUPPORTED, FISCAL_REJECTED (INVALID_REQUEST), INVALID_COMPETENCIA, INVALID_SERIE, SUBSTITUTION_REASON_REQUIRED, or a validation error 503: FISCAL_PROVIDER_UNAVAILABLE, FISCAL_BINDING_BROKEN

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

NfsePreparationRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201NfseSigningResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
POST/v1/fiscal/nfse/submissions

Submit a prepared NFS-e with the emitente's signature

Submit a prepared note with the `SignatureValue` and certificate the emitente's device produced. Before anything is sent the signature is verified, the certificate is checked to be the emitente's own, and the DPS is regenerated from `dps` and must be the one prepared. An authorised note lands `AUTORIZADA` with its 50-digit chave.

⭐ **Safe to retry.** The DPS Id is the platform's own uniqueness key: before every send the provider is asked whether a note already exists for it, and if one does, the answer is that note. If it exists and its chave cannot be read back, the answer is `outcome_unknown` — terminal, never a resend.

Raises: 404: ACCOUNT_NOT_FOUND, FISCAL_DOCUMENT_NOT_FOUND 409: FISCAL_DOCUMENT_STATE, CHAVE_CONFLICT, IDEMPOTENCY_KEY_REUSED 422: FISCAL_REJECTED — ours, before any call (SIGNER_NOT_EMITTER, SIGNATURE_INVALID, CERTIFICATE_EXPIRED, DOCUMENT_CHANGED), or the platform's (the note lands REJEITADA); FISCAL_OPERATION_NOT_SUPPORTED 503: FISCAL_PROVIDER_UNAVAILABLE (retryable, Retry-After), FISCAL_BINDING_BROKEN or reason_code outcome_unknown (not retryable)

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

NfseSubmissionRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201NfseSigningResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
POST/v1/fiscal/pgdas/declarations/queries

List the PGDAS-D declarations transmitted in an ano-calendário

The index of one ano-calendário's PGDAS-D declarations, per período: `data.periodos[{competencia, declaracoes[{numero_declaracao, tipo (original|retificadora), transmitida_em, malha}], das[...]}]`. A proven-empty year is served with `data.found: false`.

⛔ An index, never the content: no receita bruta, no folha, no PDF. It tells the activation trail (contabil-14) which months were declared; the values stay the client's to declare.

⚠️ Billed on every call. Requires an `Idempotency-Key`.

Raises: 404: ACCOUNT_NOT_FOUND 409: FISCAL_NOT_AUTHORIZED, IDEMPOTENCY_KEY_REUSED 422: FISCAL_PROVIDER_UNKNOWN, FISCAL_OPERATION_NOT_SUPPORTED, FISCAL_REJECTED, or a validation error (a year before 2018) 503: FISCAL_PROVIDER_UNAVAILABLE, FISCAL_BINDING_BROKEN

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

PgdasDeclarationsQueryRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201FiscalOperationResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
POST/v1/fiscal/pgdas/transmissions

Transmit the PGDAS-D for a competência

Transmit the month's PGDAS-D through the tenant's bound fiscal provider.

⭐ **Idempotent on the período, not only on the key.** Before every send the provider is asked whether the período already has a declaration; if it does, the answer is that declaration (`data.replayed: true`) and nothing is filed. A retificação is explicit: name the declaration it corrects in `retifica_numero`.

Requires an `Idempotency-Key` header. Only a 201 is cached, so an outage stays retryable on the same key.

Raises: 404: ACCOUNT_NOT_FOUND 409: FISCAL_NOT_AUTHORIZED (the contribuinte has not authorised us — no Retry-After), IDEMPOTENCY_KEY_REUSED 422: FISCAL_PROVIDER_UNKNOWN, FISCAL_OPERATION_NOT_SUPPORTED, FISCAL_REJECTED, or a validation error 503: FISCAL_PROVIDER_UNAVAILABLE (retryable, Retry-After), FISCAL_BINDING_BROKEN (not retryable)

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

PgdasTransmissionRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201FiscalOperationResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
POST/v1/fiscal/procuracao/queries

Ask whether the contribuinte has granted the procuração in the e-CAC

Ask the tenant's bound fiscal provider whether the contribuinte has granted the firm a procuração in the e-CAC for every code in `required_codes` (default `00146`, PGDAS-D). Served: `data.granted`, `data.codes`, `data.expires_on`. There is no grant operation — the client grants it in the e-CAC, and this is how the return is detected (contabil-14).

⚠️ **Billed on every call, a refusal included.** A POST because it costs money. Only a 201 is cached on the key, so send a fresh `Idempotency-Key` per check — a reused one replays the first answer.

Raises: 404: ACCOUNT_NOT_FOUND 409: FISCAL_NOT_AUTHORIZED (no procuração yet — no Retry-After: only the client resolves it), IDEMPOTENCY_KEY_REUSED 422: FISCAL_PROVIDER_UNKNOWN, FISCAL_OPERATION_NOT_SUPPORTED, or a validation error 503: FISCAL_PROVIDER_UNAVAILABLE (retryable, Retry-After), FISCAL_BINDING_BROKEN (not retryable)

Parâmetros

NomeTipoDetalhe
Idempotency-Keystringheaderobrigatório

Corpo da requisição

ProcuracaoQueryRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.

Respostas

StatusCorpoDetalhe
201FiscalOperationResponseResposta bem-sucedida
422HTTPValidationErrorErro 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.

DasEmissionRequest

Emit the DAS for a transmitted competência, and record it as a ``GUIA``.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this operation is for
competenciastringobrigatórioYYYY-MM
contribuinte_cnpjstringobrigatórioThe contribuinte's CNPJ, digits only
data_consolidacaostring, opcionalA future consolidation date (YYYY-MM-DD) for a DAS paid late
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.

FiscalOperationResponse

What a served fiscal operation answered.

CampoTipoDetalhe
dataobjectRefs only — digests, never document bytes
documentobject, opcionalThe GUIA fiscal document recorded for a served DAS
provider_idstringobrigatório
provider_refstring, opcionalThe provider's own number: numeroDeclaracao / numeroDocumento
simulatedbooleanobrigatórioTrue when the binding is simulated — never a real filing
statusstringobrigatórioserved

HTTPValidationError

CampoTipoDetalhe
detailarray de ValidationError

NfseCancellationPreparationRequest

Prepare the cancellation (e101101) of an authorised NFS-e for the emitente to sign. The deadline is the município's, enforced by the platform — never checked here.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this note is for
c_motivo"1" | "2" | "9"obrigatório1 erro na emissão · 2 serviço não prestado · 9 outros
competenciastringobrigatórioYYYY-MM
contribuinte_cnpjstringobrigatórioThe emitente's CNPJ, digits only
doc_idstringobrigatório
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.
x_motivostringobrigatório

NfseCancellationRequest

Submit the cancellation the emitente signed. ``dh_evento`` is the one the preparation answered: the event is regenerated, and the signature proves it is the same one.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this note is for
c_motivo"1" | "2" | "9"obrigatório1 erro na emissão · 2 serviço não prestado · 9 outros
certificate_der_b64stringobrigatório
competenciastringobrigatórioYYYY-MM
contribuinte_cnpjstringobrigatórioThe emitente's CNPJ, digits only
dh_eventostringobrigatório
doc_idstringobrigatório
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.
signature_value_b64stringobrigatório
x_motivostringobrigatório

NfseDps

The note's content — what the DPS is built from, on prepare and again on submit.

CampoTipoDetalhe
c_loc_emistringobrigatórioThe emitente's município (IBGE)
d_competstringobrigatórioData de competência — inside the request's competência
prestadorNfsePrestadorobrigatório
servicoNfseServicoobrigatório
tomadorNfseTomador, opcional
valoresNfseValoresobrigatório

NfsePreparationRequest

Prepare an NFS-e for the emitente to sign. Creates the ``NFSE`` fiscal document (or re-prepares ``doc_id``, a draft or a rejected note, on the **same** DPS number) and answers a ``signing_request`` for the emitente's own device. ``replaces`` prepares a substituting note for an authorised one; ``substituicao`` then says why.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this note is for
competenciastringobrigatórioYYYY-MM
contribuinte_cnpjstringobrigatórioThe emitente's CNPJ, digits only
doc_idstring, opcional
dpsNfseDpsobrigatório
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.
replacesstring, opcional
seriestring, opcionalThe DPS série (00001–49999). Pick one the emitente never used with another emitter — a reused (série, número) is refused as a duplicate
substituicaoNfseSubstituicao, opcional

NfseSigningResponse

A prepared note or event: the document, and what the emitente's device signs.

CampoTipoDetalhe
dataobject`signing_request`: the canonical SignedInfo (base64) and its algorithm — sign those bytes, PKCS#1 v1.5, with the emitente's key
documentobject, opcional
provider_idstringobrigatório
provider_refstring, opcionalThe DPS Id, or the event Id
simulatedbooleanobrigatório
statusstringobrigatório

NfseSubmissionRequest

Submit a prepared NFS-e with the emitente's signature. ``dps`` must be the block that was prepared: the DPS is regenerated and its digest compared, so a changed note is refused rather than submitted under an old signature.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this note is for
certificate_der_b64stringobrigatório
competenciastringobrigatórioYYYY-MM
contribuinte_cnpjstringobrigatórioThe emitente's CNPJ, digits only
doc_idstringobrigatório
dpsNfseDpsobrigatório
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.
signature_value_b64stringobrigatório
substituicaoNfseSubstituicao, opcionalAs prepared, for a substituting note

NfseSubstituicao

CampoTipoDetalhe
c_motivo"01" | "02" | "03" | "04" | "05" | "99"obrigatório
x_motivostring, opcional

PgdasDeclarationsQueryRequest

Which períodos of one ano-calendário carry a transmitted PGDAS-D (contabil-14). ⛔ An **index**, never the declaration's content: no receita bruta, no folha, no PDF. Billed on every call.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this operation is for
ano_calendariostringobrigatórioYYYY, 2018 or later
contribuinte_cnpjstringobrigatórioThe contribuinte's CNPJ, digits only
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.

PgdasTransmissionRequest

Transmit the month's PGDAS-D. ⭐ **Idempotent on the período, not only on the key.** A driver whose provider has no idempotency handle (Serpro has none) consults the período before every send, so a second transmission for a month that already has one answers with the existing declaration (``data.replayed = true``) and files nothing. A retificação is an explicit act: name the declaration it corrects in ``retifica_numero``.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this operation is for
competenciastringobrigatórioYYYY-MM
contribuinte_cnpjstringobrigatórioThe contribuinte's CNPJ, digits only
declaracaoobjectobrigatórioThe PGDAS-D declaração block, as the RFB defines it
estabelecimentosarray de object, opcional
indicador_comparacaobooleanPadrão false
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.
retifica_numerostring, opcionalThe numeroDeclaracao this transmission rectifies
valores_para_comparacaoarray de object, opcional

ProcuracaoQueryRequest

Ask whether the contribuinte has granted the firm a procuração in the e-CAC (contabil-14). ⚠️ **Billed on every call, a refusal included** — poll with backoff and a ceiling, and never on a tight loop: only the client can change the answer. Not cached per request in any useful sense: send a fresh ``Idempotency-Key`` per check, or the first answer replays.

CampoTipoDetalhe
account_idstringobrigatórioThe company account this operation is for
contribuinte_cnpjstringobrigatórioThe contribuinte's CNPJ, digits only
provider_idstring, opcionalA fiscal provider bound for this tenant. Omitted: the default.
required_codesarray de string, opcionalProcuração service codes that must all be granted. Omitted: 00146 (PGDAS-D)

ValidationError

CampoTipoDetalhe
ctxobject
inputnão declarado
locarray de string ou integerobrigatório
msgstringobrigatório
typestringobrigatório