Documentation › Testing
Failure simulator
Trigger timeout, rejection, Sefin down and transmission failure with the test key.
Only with the sdr_test_ key. Send the X-Sudrel-Simular header in
POST /v1/nfse (or the simular field in each item of POST /v1/lotes).
The simulated invoice goes through the SAME states, events, webhooks and
timeline as a real invoice, but it never goes to the Sefin, not even to
the test environment: Sudrel itself responds. It does not consume the
company's numbering (the DPS uses series 49998), the access key starts
with seven zeros, the PDF carries the SIMULAÇÃO (SIMULATION) mark and the
resource includes simulacao with the scenario. With the production key,
the simulation request returns 422 simulacao_so_no_sandbox.
Real time limits run faster on simulated invoices: the 10 minutes until
recovery queries the DPS become 5 seconds, the 30 minutes of the
long-processing warning become 20 seconds, and the 7 days until
falha_transmissao become 1 minute.
| Scenario | What you see |
|---|---|
autorizada_lenta |
With the default wait (10 s), 202 with transmitindo; authorized in about 15 s. Webhook NFSE_AUTORIZADA. |
rejeicao:<codigo> |
422 with the invoice rejeitada, rejeicao.codigo_oficial equal to the requested code, and rejeicao.explicacao when that code is in the catalog (e.g.: rejeicao:E0240). Webhook NFSE_REJEITADA. |
timeout_depois_autorizada |
202 with transmitindo. The transmission "drops", recovery queries the DPS, finds the invoice and it becomes autorizada, ONLY ONE, with no resend. Timeline: envio (technical error), consulta_dps (found), recuperada. Webhook NFSE_AUTORIZADA. |
sefin_fora |
202 with transmitindo, and it stays transmitindo while the "Sefin is down". The DPS query says it did not arrive, the invoice is resent and authorized (envio, consulta_dps, reenfileirada, envio). The API has no "scheduled" status: the wait shows as transmitindo. |
processamento_prolongado |
202. After about 20 s the invoice gets aviso: { codigo: "processamento_prolongado" } and the NFSE_PROCESSAMENTO_PROLONGADO webhook fires, once; it stays transmitindo and is then authorized. |
falha_transmissao_nao_enviada |
422 with falha_transmissao and falha.dps_enviada: "nao": the invoice stopped before it was sent. Webhook NFSE_FALHA_TRANSMISSAO. |
falha_transmissao_desconhecido |
202. The long-processing warning at 20 s and, about 1 minute later, falha_transmissao with falha.dps_enviada: "desconhecido": the case where you must check the Emissor Nacional before issuing again. Webhook NFSE_FALHA_TRANSMISSAO. |
aguardando_confirmacao |
202 with aguardando_confirmacao and the NFSE_AGUARDANDO_CONFIRMACAO webhook. Once confirmed in POST /v1/nfse/{id}/confirmacao, the invoice is authorized. |