# Try the unhappy paths

> Sandbox magic RUTs to force rejection, repairs, exhausted folios, or a DTE stuck in procesando — plus the structured error catalog your integration must handle.

A DTE `aceptado` on the first try is the happy path. In production you'll
see rejections, documents with repairs, exhausted folios and slow SII
responses — and your integration needs to handle them **before** they
happen against a real customer. The sandbox gives you **reserved receptor
RUTs** that trigger each outcome deterministically.

Magic RUTs don't lie to Simplo's state machine: they lie to the SII
simulator. The real cycle — `firmado → enviando → procesando →
aceptado/rechazado/con_reparos`, with the same events and the same
transition code — runs exactly like it does in production. The only thing
fabricated is the answer the (simulated) SII gives.

## Magic RUTs: force the outcome from emission

Emit a DTE with one of these as `receptor.rut` and the outcome is decided
the moment you send it — no extra endpoint call required:

| Receptor RUT   | Outcome                                                 | SII code |
| --------------- | ---------------------------------------------------------- | -------- |
| `44000001-0`    | `rechazado`                                                 | `EMP`    |
| `44000002-9`    | `con_reparos`                                                | `DNK`    |
| `44000003-7`    | stays in `procesando` (the simulator never resolves it)      | `DOK` (non-terminal) |
| `44000004-5`    | the send to the simulated SII fails as if no folios were left (`CAF_NO_DISPONIBLE`) | — (the send fails) |
| anything else   | happy path: `enviando → procesando → aceptado`              | `DOK`    |

```bash
curl -X POST https://api.simplo.cl/api/v1/billing/dte \
  -H "X-Api-Key: $SIMPLO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "tipo_dte": 33,
    "receptor": { "rut": "44000001-0", "razon_social": "Cliente que rechaza" },
    "detalle": [{ "nombre": "Prueba de rechazo", "cantidad": 1, "precio": 10000 }]
  }'
```

`44000004-5` is the odd one out: the other three emit normally (`201`,
`estado: "firmado"`) and the verdict diverges later, during the async
cycle — just like production. `44000004-5` instead makes **the send to the
simulated SII** fail with an exhausted-folios error (`CAF_NO_DISPONIBLE` —
see the error table below): the emission returns `201`, but the document
never advances to `procesando`. It's the way to rehearse the "I ran out of
folios" scenario without burning through your synthetic test folios.

Magic RUTs accept the dotted/spaced format too (`44.000.001-0` and
`44000001-0` both match).

Magic RUTs are the sandbox's **only** lever: there are no endpoints to
force states on a DTE you already emitted or to reset the sandbox. If you
need a specific outcome, decide it at emission, with the receptor's RUT.

## Structured error catalog

Every API failure — sandbox or production — responds with the same shape:
`code` (machine-readable), `message`, `action` (recommended next step) and
`severity`. Here's what you'll run into testing unhappy paths:

| Code                        | Message                                                     | Recommended action        | Severity   |
| ----------------------------- | ---------------------------------------------------------------- | ---------------------------- | ---------- |
| `CAF_NO_DISPONIBLE`            | No CAF available for the document type                            | `upload_caf`                  | error      |
| `CAF_STOCK_LOW`                | Folios running low                                                 | `upload_caf`                  | warning    |
| `DTE_NOT_FOUND`                | DTE not found                                                       | `verify_empresa_and_id`       | error      |
| `DTE_ESTADO_INVALIDO`          | DTE in a state that doesn't allow this operation                    | `check_dte_status`            | error      |
| `RUT_INVALIDO`                 | RUT fails the mod-11 check                                          | `fix_rut_input`               | error      |
| `FOLIO_DUPLICADO`              | Folio already used                                                   | `check_existing_dte`          | error      |
| `MONTO_INCONSISTENTE`          | Net + VAT doesn't match the total                                    | `recalculate_totals`          | error      |
| `IDEMPOTENCY_IN_PROGRESS`      | This `Idempotency-Key`'s request is already being processed          | `retry_later`                 | warning    |
| `IDEMPOTENCY_BODY_MISMATCH`    | The `Idempotency-Key` was reused with a different body               | `generate_new_key`            | warning    |
| `SII_RECHAZADO`                | The SII rejected the document                                        | `review_xml_errors`           | error      |
| `SII_DUPLICADO`                 | The document was already sent to the SII                             | `check_existing_envio`        | warning    |

The full catalog (certificate, export, liquidaciones and more) lives in
[Errors](/en/referencia/errores/). `action` is designed so a coding agent
can decide its next step without having to parse `message` as natural
language.

## What the sandbox does NOT simulate

A sandbox that overpromises produces the same churn it exists to prevent.
Be explicit about this in your own integration too:

- **XSD and real SII business-rule validation.** The simulator accepts
  whatever XML the engine generated; the real SII rejects for reasons that
  only surface against its certification or production environment.
- **SII certification.** Passing the sandbox doesn't get you a single day
  closer to being SII-certified — see
  [Go to production](/en/comienza/pasar-a-produccion/).
- **Real folio expiry** (6 months) or certificate expiry: sandbox ones are
  synthetic and long-lived.
- **Real SII outages, latency and rate limits**, or its final codes
  904/905/906.
- **Intercambio** (email, acknowledgements, SETMAIL).
- **The PDF and XML have no tax validity** — the sandbox's CAF and
  certificate are synthetic and self-signed, and the real SII would reject
  them. The amounts and VAT ARE real, though: it's the same calculation
  engine as production — only the recipient is fake.

## Related

- [Quickstart](/en/comienza/quickstart/) — the full flow, from sandbox to
  your first DTE
- [States](/en/referencia/estados/) — the full DTE lifecycle
- [Errors](/en/referencia/errores/) — the full catalog and retry rules
- [Go to production](/en/comienza/pasar-a-produccion/) — the go-live
  checklist

---

HTML version: https://docs.simplo.cl/en/comienza/casos-infelices/ · Agent index: https://docs.simplo.cl/llms.txt
