DC-e
Cancel DC-e
Requests the cancellation of an authorized DC-e (within 24 hours after authorization); asynchronous, result via webhook.
/openapi/v2/empresas/{empresaId}/dc-e/{dceId}Requires the token, timestamp and sign signature headers, see Authentication.
Acceptance returns HTTP 200 with no body, the document moves to CancelamentoPendente, and the platform registers event 110111 (nSeqEvento=1) with SEFAZ asynchronously. The result arrives through the webhook dce.canceled (Cancelada) or dce.cancel_rejected (CancelamentoNegado), and can also be polled through the query. The body is optional: { "motivo": "..." } with 15-255 characters after sanitization; when omitted, the fixed default Cancelamento solicitado pelo emitente por erro de preenchimento. is used. The official DC-e has cancellation only: no correction letter, no number invalidation.
Parameters
Path parameters
empresaIdstringrequiredIdentifier returned by Register company.
Example:1934811222334455dceIdstringrequiredThe
idsent at issuance.Example:DCe-000012333
Request body
motivostringoptionalCancellation reason, 15-255 characters after sanitization (
10019043when shorter than 15). When omitted,Cancelamento solicitado pelo emitente por erro de preenchimento.is used.Example:Cancelamento solicitado pelo emitente por erro de preenchimento.
Responses
Cancellation accepted; no response body. The document moves to CancelamentoPendente; the SEFAZ verdict arrives through the webhook.
No response body
Errors
| Code | HTTP | |
|---|---|---|
| DCe0001 | 404 |
|
| 10003000 | 404 |
|
| 10019040 | 400 | Status does not allow cancellation: the document must be |
| 10019041 | 400 | 24-hour window after authorization exceeded (Manual DC-e). The document can only be kept. |
| 10019042 | 400 | Cancellation already accepted for this document (in progress). Only one cancellation is accepted per document. |
| 10019043 | 400 | Invalid |
Signing a DELETE with a body
A DELETE without a body signs with the empty string as body; a DELETE with a body (cancellation with a reason) signs the raw JSON with CR/LF removed, exactly like the JSON endpoints. If you send { "motivo": ... }, include that same text in the signature. See Authentication.
Constraints and outcome
- The document must be
Autorizada(10019040) and within 24 hours after authorization (10019041), counted from the authorization time. - Only one cancellation is accepted per document: further calls while cancelling / after cancellation return
10019042/10019040. - A
motivoshorter than 15 characters after sanitization returns10019043; a document not yet materialized (stillPendentewithout a key) returns 404DCe0001. - Outcome:
dce.canceledwithdceStatus=Cancelada(dceDataAutorizacaois the cancellation registration time anddceNumeroProtocolothe event protocol; the DACE is re-rendered with theCANCELADAwatermark), ordce.cancel_rejectedwithdceStatus=CancelamentoNegado(the document staysAutorizada, the query carries the reason inmotivoStatus, and a corrected DELETE may be sent again). Event payloads in DC-e.
