Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Carlos-Gnd/FERRED-Inventario-y-Ventas/llms.txt

Use this file to discover all available pages before exploring further.

The DTE API exposes operations for managing electronic invoices (Documentos Tributarios Electrónicos) sent to El Salvador’s Ministerio de Hacienda. DTEs are generated automatically when a sale is processed, but can be re-sent if the initial submission failed.
A sale with estado: "SIMULADO" is a valid, committed sale — it is not a test transaction. SIMULADO means Hacienda’s sandbox was unreachable at the time of submission, not that the invoice is invalid. Use POST /api/dte/:id/reenviar to retry the submission when connectivity is restored.

DTE estados

EstadoDescription
SIMULADOHacienda sandbox was unreachable (network timeout or DNS failure). The sale is valid; DTE submission is pending.
PROCESADOHacienda accepted the DTE and returned a selloRecibido.
ERROR_HACIENDAHacienda responded with a 4xx or 5xx error, rejecting the DTE.
ERROR_INTERNOA system-level error prevented DTE generation or submission.
PENDIENTEThe DTE has been queued for retry via POST /api/dte/:id/reenviar.

GET /api/dte/:id

Returns the current status of a DTE by invoice ID. Roles: ADMIN, CAJERO

Path parameters

id
number
required
ID of the FacturaDte record.

Response 200

id
number
Invoice ID.
numeroControl
string
Hacienda control number in the format DTE-01-{establecimiento}P001-{sequence}. null if not yet generated.
codigoGeneracion
string
UUID assigned to the DTE document. null if not yet generated.
estado
string
Current DTE state. See the estados table above.
sincronizado
boolean
true if Hacienda returned a selloRecibido for this DTE.

Errors

StatusCondition
400id is not a valid positive integer.
403The authenticated user does not belong to the branch that owns this invoice.
404No FacturaDte record found for the given id.

GET /api/dte/:id/qr

Returns a base64-encoded QR code image for the DTE’s Hacienda public verification URL. Roles: ADMIN, CAJERO

Path parameters

id
number
required
ID of the FacturaDte record. The DTE must already have a codigoGeneracion.

Response 200

qrBase64
string
Base64-encoded PNG data URL of the QR code (200×200 px). Suitable for use directly in an <img src="..."> tag.

Errors

StatusCondition
404Invoice not found.
409The invoice does not yet have a codigoGeneracion — send the DTE first.

POST /api/dte/:id/enviar

Sends the DTE to Hacienda for a specific invoice. This is called automatically after each sale; use this endpoint to trigger a manual send. Roles: ADMIN, CAJERO

Path parameters

id
number
required
ID of the FacturaDte to send.

Response

ok
boolean
true if Hacienda accepted the DTE (PROCESADO); false on any error.
estado
string
Resulting DTE state after the submission attempt.
selloRecibido
string
Hacienda’s receipt stamp. Only present when estado is PROCESADO.
qrBase64
string
Base64 QR code generated from the codigoGeneracion. Present on success.
error
string
Human-readable error detail. Present when ok is false.

POST /api/dte/:id/reenviar

Resets a DTE’s estado to PENDIENTE and retries the submission to Hacienda. Use this after a SIMULADO, ERROR_HACIENDA, or ERROR_INTERNO to attempt recovery without creating a new sale. Roles: ADMIN, CAJERO

Path parameters

id
number
required
ID of the FacturaDte to resend.

Response

Same shape as POST /api/dte/:id/enviar.
ok
boolean
true if Hacienda accepted the resubmitted DTE.
estado
string
Final DTE state after the retry.
selloRecibido
string
Hacienda receipt stamp, present when estado is PROCESADO.
qrBase64
string
Base64 QR code, present on successful resubmission.
error
string
Error detail, present when ok is false.

Errors

StatusCondition
404Invoice not found.
502The DTE submission was attempted but Hacienda returned an error.

GET /api/dte/sucursal/:sucursalId

Lists all DTEs for a specific branch, ordered by creation date descending. Supports pagination. Roles: ADMIN, CAJERO

Path parameters

sucursalId
number
required
ID of the branch whose DTEs you want to list. CAJERO users can only access their own branch.

Query parameters

limit
number
default:"50"
Maximum number of records to return. Capped at 200.
offset
number
default:"0"
Number of records to skip for pagination.

Response

total
number
Total number of DTEs in the branch (before pagination).
DTEs
object[]
Paginated list of DTE records.

Build docs developers (and LLMs) love