Create Return
ID of the original sale being returned. Must exist in the system.
SII adjustment document type code:
56: Nota de Débito Electrónica (Debit Note)61: Nota de Crédito Electrónica (Credit Note)111: Nota de Crédito Exportación (Export Credit Note)112: Nota de Débito Exportación (Export Debit Note)
SII reason code for the adjustment:
1: Anula documento de referencia (Cancels referenced document)2: Corrige texto del documento de referencia (Corrects text)3: Corrige montos (Corrects amounts)
Explanation for the return (e.g., “Producto defectuoso”, “Cliente insatisfecho”)
Payment method ID for the refund. Common options:
- Cash refund (method code:
EFECTIVO) - Store credit (method code:
CREDITO_INTERNO)
Unique ID of the credit note
Fiscal folio number assigned for the credit note (separate sequence from sales)
ID of the original sale that is being adjusted
Automatic reference to the original sale document, including:
- Original document type
- Original folio number
- Original emission date
- SII reason code
Return Processing Flow
The return endpoint executes the following atomic transaction:- Original Sale Validation: Verifies the original sale exists
- Product Validation: Confirms each returned product exists
- Stock Reinstatement: For products with stock control enabled:
- Increases stock quantity by returned amount
- Creates stock movement record (type: ENTRADA, reason: DEVOLUCION)
- Price Lookup: Uses the original sale price for each product (not current price)
- Amount Calculation: Computes net amount, VAT (19%), and total for returned items
- Folio Assignment: Assigns next available folio from adjustment document CAF
- Reference Generation: Automatically creates reference to original sale
- Credit Note Creation: Generates new Sale record with adjustment type
- Refund Processing: Based on
return_method_id:CREDITO_INTERNO: Decreases customer’s balance (credits their account)EFECTIVO: Records cash refund (requires cash session validation)- Other methods: Records refund transaction
- Database Commit: Persists all changes atomically
Historical Pricing: Returns use the original sale price for each product, ensuring accurate credit calculation even if product prices have changed since the original sale.
Return Methods
Cash Refund
Returns money to the customer immediately:Store Credit
Applies credit to customer’s account for future purchases:CREDITO_INTERNO, the return amount is subtracted from the customer’s current_balance, effectively crediting their account.
SII Reason Codes
Code 1: Anula documento
Code 1: Anula documento
Use when the return completely or partially cancels the original sale. Most common for product returns.Example: Customer returns defective merchandise.
Code 2: Corrige texto
Code 2: Corrige texto
Use when correcting textual information on the original document (customer details, descriptions, etc.)Example: Customer name was spelled incorrectly on invoice.
Code 3: Corrige montos
Code 3: Corrige montos
Use when correcting pricing or calculation errors on the original document.Example: Wrong price was applied, needs adjustment.
Error Responses
Partial Returns
You can return a subset of items or partial quantities from the original sale:Example: Return only 1 of 2 items
The system does not currently validate that returned quantities don’t exceed original sale quantities. Operators should verify this manually to ensure data accuracy.