Referência / Quadra Command API
Fiscal Operations
8 operações em Quadra Command API 0.2.0.
/v1/fiscal/dasEmit 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
DasEmissionRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | FiscalOperationResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/fiscal/nfse/cancellationsCancel 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
NfseCancellationRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | NfseSigningResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/fiscal/nfse/cancellations/preparationsPrepare 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
NfseCancellationPreparationRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | NfseSigningResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/fiscal/nfse/preparationsPrepare 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
NfsePreparationRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | NfseSigningResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/fiscal/nfse/submissionsSubmit 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
NfseSubmissionRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | NfseSigningResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/fiscal/pgdas/declarations/queriesList 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
PgdasDeclarationsQueryRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | FiscalOperationResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/fiscal/pgdas/transmissionsTransmit 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
PgdasTransmissionRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | FiscalOperationResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/v1/fiscal/procuracao/queriesAsk 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
| Nome | Tipo | Detalhe |
|---|---|---|
| Idempotency-Key | string | headerobrigatório |
Corpo da requisição
ProcuracaoQueryRequest — obrigatório. Os campos estão listados em Esquemas, abaixo.
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 201 | FiscalOperationResponse | 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.
DasEmissionRequest
Emit the DAS for a transmitted competência, and record it as a ``GUIA``.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigatórioThe company account this operation is for |
| competencia | string | obrigatórioYYYY-MM |
| contribuinte_cnpj | string | obrigatórioThe contribuinte's CNPJ, digits only |
| data_consolidacao | string, opcional | A future consolidation date (YYYY-MM-DD) for a DAS paid late |
| provider_id | string, opcional | A fiscal provider bound for this tenant. Omitted: the default. |
FiscalOperationResponse
What a served fiscal operation answered.
| Campo | Tipo | Detalhe |
|---|---|---|
| data | object | Refs only — digests, never document bytes |
| document | object, opcional | The GUIA fiscal document recorded for a served DAS |
| provider_id | string | obrigatório |
| provider_ref | string, opcional | The provider's own number: numeroDeclaracao / numeroDocumento |
| simulated | boolean | obrigatórioTrue when the binding is simulated — never a real filing |
| status | string | obrigatórioserved |
HTTPValidationError
| Campo | Tipo | Detalhe |
|---|---|---|
| detail | array 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.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigató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 |
| competencia | string | obrigatórioYYYY-MM |
| contribuinte_cnpj | string | obrigatórioThe emitente's CNPJ, digits only |
| doc_id | string | obrigatório |
| provider_id | string, opcional | A fiscal provider bound for this tenant. Omitted: the default. |
| x_motivo | string | obrigató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.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigató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_b64 | string | obrigatório |
| competencia | string | obrigatórioYYYY-MM |
| contribuinte_cnpj | string | obrigatórioThe emitente's CNPJ, digits only |
| dh_evento | string | obrigatório |
| doc_id | string | obrigatório |
| provider_id | string, opcional | A fiscal provider bound for this tenant. Omitted: the default. |
| signature_value_b64 | string | obrigatório |
| x_motivo | string | obrigatório |
NfseDps
The note's content — what the DPS is built from, on prepare and again on submit.
| Campo | Tipo | Detalhe |
|---|---|---|
| c_loc_emi | string | obrigatórioThe emitente's município (IBGE) |
| d_compet | string | obrigatórioData de competência — inside the request's competência |
| prestador | NfsePrestador | obrigatório |
| servico | NfseServico | obrigatório |
| tomador | NfseTomador, opcional | |
| valores | NfseValores | obrigató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.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigatórioThe company account this note is for |
| competencia | string | obrigatórioYYYY-MM |
| contribuinte_cnpj | string | obrigatórioThe emitente's CNPJ, digits only |
| doc_id | string, opcional | |
| dps | NfseDps | obrigatório |
| provider_id | string, opcional | A fiscal provider bound for this tenant. Omitted: the default. |
| replaces | string, opcional | |
| serie | string, opcional | The 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 |
| substituicao | NfseSubstituicao, opcional |
NfseSigningResponse
A prepared note or event: the document, and what the emitente's device signs.
| Campo | Tipo | Detalhe |
|---|---|---|
| data | object | `signing_request`: the canonical SignedInfo (base64) and its algorithm — sign those bytes, PKCS#1 v1.5, with the emitente's key |
| document | object, opcional | |
| provider_id | string | obrigatório |
| provider_ref | string, opcional | The DPS Id, or the event Id |
| simulated | boolean | obrigatório |
| status | string | obrigató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.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigatórioThe company account this note is for |
| certificate_der_b64 | string | obrigatório |
| competencia | string | obrigatórioYYYY-MM |
| contribuinte_cnpj | string | obrigatórioThe emitente's CNPJ, digits only |
| doc_id | string | obrigatório |
| dps | NfseDps | obrigatório |
| provider_id | string, opcional | A fiscal provider bound for this tenant. Omitted: the default. |
| signature_value_b64 | string | obrigatório |
| substituicao | NfseSubstituicao, opcional | As prepared, for a substituting note |
NfseSubstituicao
| Campo | Tipo | Detalhe |
|---|---|---|
| c_motivo | "01" | "02" | "03" | "04" | "05" | "99" | obrigatório |
| x_motivo | string, 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.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigatórioThe company account this operation is for |
| ano_calendario | string | obrigatórioYYYY, 2018 or later |
| contribuinte_cnpj | string | obrigatórioThe contribuinte's CNPJ, digits only |
| provider_id | string, opcional | A 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``.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigatórioThe company account this operation is for |
| competencia | string | obrigatórioYYYY-MM |
| contribuinte_cnpj | string | obrigatórioThe contribuinte's CNPJ, digits only |
| declaracao | object | obrigatórioThe PGDAS-D declaração block, as the RFB defines it |
| estabelecimentos | array de object, opcional | |
| indicador_comparacao | boolean | Padrão false |
| provider_id | string, opcional | A fiscal provider bound for this tenant. Omitted: the default. |
| retifica_numero | string, opcional | The numeroDeclaracao this transmission rectifies |
| valores_para_comparacao | array 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.
| Campo | Tipo | Detalhe |
|---|---|---|
| account_id | string | obrigatórioThe company account this operation is for |
| contribuinte_cnpj | string | obrigatórioThe contribuinte's CNPJ, digits only |
| provider_id | string, opcional | A fiscal provider bound for this tenant. Omitted: the default. |
| required_codes | array de string, opcional | Procuração service codes that must all be granted. Omitted: 00146 (PGDAS-D) |
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 |