Return event
The Return Event (Evento de Retorno, 18) records a return of goods, a refund, or a return of containers on a processed Invoice (01), Export Invoice (11), or Excluded Subject Invoice (14). The original document remains in force.
- It requires the
dte:emitpermission and supportsIdempotency-Key. precioUnigoes as on the original document: on an Invoice (01) with VAT; on 11 and 14 without VAT.- Recipient, third parties, and export data are copied from the document. Withholdings are applied if the document had them.
- Deadline: 3 months from the document’s date (2 years for Invoices and Export Invoices of activities 21001, 21008, 46482, 46484, 46491, and 47721).
- The sum of returns can’t exceed the document:
409 retorno_excedidowithdetails.disponible. - If the customer exchanges the product, also issue a new document for the new sale.
Register a return
Section titled “Register a return”curl https://app.openfactura.co/api/v1/dte/0862382B-0BB8-42A0-BB6B-B42DCCDF1EA4/retorno \ -H "Authorization: Bearer $OPENFACTURA_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: devolucion-1042" \ -d '{ "items": [{ "descripcion": "Silla", "cantidad": 1, "precioUni": 22.6 }] }'echo '{ "items": [{ "descripcion": "Silla", "cantidad": 1, "precioUni": 22.6 }] }' \ | openfactura dte retorno 0862382B-0BB8-42A0-BB6B-B42DCCDF1EA4 -dte_retorno with the document’s codigoGeneracion, idempotencyKey, and items.
Fields of each item: descripcion, cantidad, precioUni and, optionally, tipoItem, codigo,
uniMedida, descuento, tipoVenta, seguro, and flete.
Response: 201 with the Evento:
{ "id": "…", "tipo": "retorno", "tipoEvento": "18", "codigoGeneracion": "…", "ambiente": "00", "estado": "procesado", "selloRecibido": "…", "documentoId": "…", "creado": 1794469092559}If the MH rejects the event: 422 evento_rechazado with details.mh.
If it can’t be confirmed whether the MH received the event (the connection dropped while
transmitting it, or the MH stamped it but it couldn’t be saved): 502 evento_incierto with
details.codigoGeneracion and, if it was stamped, details.selloRecibido. It’s stored as the final
response for the Idempotency-Key. Don’t send it again without checking with the MH first;
resend with another key only if it didn’t arrive.
Query and deliver
Section titled “Query and deliver”GET /eventos?tipo=retorno— the 50 most recent in the active environment.GET /eventos/{codigo}— the event with its JSON and the MH response.GET /eventos/{codigo}/jsonandGET /eventos/{codigo}/pdf— the file and the graphic representation for the recipient.
For AI assistants: llms.txt ·llms-full.txt ·every page as Markdown by adding .md to its path.