The Invoices API is the core of Eme2App’s billing workflow. A factura moves through a lifecycle —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eme2dev/Eme2App/llms.txt
Use this file to discover all available pages before exploring further.
borrador → confirmada → anulada — with strict transition rules. Confirming a factura automatically generates facturas_vencimientos (due-date instalments) derived from the assigned forma_pago. Voiding a confirmed invoice creates a mirror rectificativa with negative amounts. All endpoints require a Bearer token that contains a valid empresa_id.
Base path: /api/facturas
Authorization: Authorization: Bearer <token> with empresa_id embedded (call POST /api/auth/seleccionar-empresa first if needed).
Endpoint reference
| Method | Path | Description |
|---|---|---|
| GET | /api/facturas | List invoices (paginated) |
| POST | /api/facturas | Create invoice |
| GET | /api/facturas/proximo-numero | Next available invoice number |
| GET | /api/facturas/informe-cobros | Collections report |
| GET | /api/facturas/:id | Get invoice by ID |
| PUT | /api/facturas/:id | Update invoice |
| PUT | /api/facturas/:id/estado | Transition invoice status |
| PATCH | /api/facturas/:id/estado-emision | Update emission status |
| POST | /api/facturas/:id/anular | Void a confirmed invoice |
| DELETE | /api/facturas/:id | Delete a draft invoice |
| POST | /api/facturas/:id/enviar-email | Send PDF by email |
| POST | /api/facturas/:id/cobros | Register a collection against a vencimiento |
| GET | /api/facturas/:id/cobros | List collections for an invoice |
| DELETE | /api/facturas/:id/cobros/:cobro_id | Delete cobro and revert vencimiento |
| PUT | /api/facturas/cobros/:id | Update a cobro |
| DELETE | /api/facturas/cobros/:id | Delete a cobro |
| GET | /api/facturas/:id/vencimientos | List all due dates |
| GET | /api/facturas/:id/vencimientos-disponibles | List payable (pending/partial) due dates |
| POST | /api/facturas/:id/vencimientos | Create a manual due date |
| PATCH | /api/facturas/:id/vencimientos/:vencimiento_id | Update a due date |
| DELETE | /api/facturas/:id/vencimientos/:vencimiento_id | Delete a due date |
| POST | /api/facturas/:id/vencimientos/restaurar | Restore due dates from forma_pago template |
| POST | /api/facturas/:id/vencimientos/:vencimiento_id/revertir-cobro | Revert all cobros on a due date |
GET /api/facturas
Returns a paginated list of invoices belonging to the active company. Query parameters| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (default: 1) |
pageSize | integer | Results per page (default: company setting) |
POST /api/facturas
Creates a new invoice inborrador status. Totals (subtotal, IVA, IRPF) are calculated server-side from the article catalogue; you do not send pre-computed tax amounts.
ID of the client. Must belong to the active company.
Invoice number. Must be unique within the combination of
empresa_id and serie. Use GET /api/facturas/proximo-numero to fetch the next available value.Invoice date.
ID of the invoice series (
series_facturas). Required when the company has usa_series = true.Series code (e.g.
"A"). Alternative to serie_id; the server resolves the ID from the code.Payment terms. If omitted, the client’s
forma_pago_defecto_id is used. Drives automatic vencimiento generation when the invoice is confirmed.Free-text notes printed on the invoice. Max 1000 characters.
Array of invoice line items. At least one line is required.
GET /api/facturas/proximo-numero
Returns the next sequential invoice number for the given series. Query parameters| Parameter | Description |
|---|---|
serie_id | UUID of the series. |
serie | Series code. Alternative to serie_id. |
GET /api/facturas/:id
Returns a single invoice with its header, line details, and totals.PUT /api/facturas/:id
Full update of aborrador or confirmada invoice. The body mirrors POST /api/facturas. Existing line items are replaced entirely.
PUT /api/facturas/:id/estado
Transitions the invoice status.Target status. Allowed values:
"borrador", "confirmada", "anulada".| From | To | Effect |
|---|---|---|
borrador | confirmada | Generates vencimientos from forma_pago |
confirmada | borrador | Deletes vencimientos (only if none are cobrado/partial) |
confirmada | anulada | Use POST /:id/anular instead |
anulada | any | Not allowed |
PATCH /api/facturas/:id/estado-emision
Updates the emission tracking state. Transitions are irreversible (one-way).One of
"sin_emitir", "pdf", "email". Can only progress forward.POST /api/facturas/:id/anular
Voids a confirmed invoice by creating a rectificativa (mirror invoice with negative amounts). The original invoice is markedanulada.
Code of the rectificative series to use. Required only when the company has more than one active rectificative series configured.
Date of the void document. Defaults to today.
When the original invoice had cobros, the void operation creates corresponding negative cobros on the original invoice to zero out the accounting.
DELETE /api/facturas/:id
Permanently deletes aborrador invoice and its line items. If the invoice originated from a presupuesto and no other linked invoices remain, the presupuesto is restored to borrador.
POST /api/facturas/:id/enviar-email
Sends the invoice PDF to a recipient. After a successful send,estado_emision is automatically updated to "email".
Recipient email address.
Base64-encoded PDF content generated client-side.
Attachment filename. Defaults to
factura-{serie}-{numero}.pdf.Email subject. Defaults to
"Factura {serie}-{numero}".Email body text. Plain text, not HTML.
Only confirmed invoices (
estado !== "borrador") can be sent. Draft invoices return 400.GET /api/facturas/informe-cobros
Paginated report of all registered collections (cobros) for the active company.POST /api/facturas/:id/cobros
Registers a collection against a specific vencimiento. Supports full and partial payment.The due-date instalment to pay.
Amount collected. Must be > 0 and ≤ the vencimiento’s remaining balance.
Date the payment was received.
Payment instrument (e.g. bank transfer, direct debit). Must be active.
Optional internal note on the collection.
Required for partial payments only. The due date for the remaining balance. Must be after
fecha_pago.GET /api/facturas/:id/cobros
Returns all cobros for the invoice along with a payment summary. ResponseDELETE /api/facturas/:id/cobros/:cobro_id
Deletes a cobro and reverts the associated vencimiento topending. If the payment was partial and a rest vencimiento was created, that rest vencimiento is also removed.
Response
PUT /api/facturas/cobros/:id
Updates metadata on a cobro (date, instrument, notes). Theimporte field cannot be changed for cobros linked to a vencimiento — delete and re-create the cobro instead.
New payment date.
Replacement payment instrument.
External reference number.
Internal note.
DELETE /api/facturas/cobros/:id
Deletes a cobro by its own ID and reverts the effect on its associated vencimiento (the vencimiento is restored topending and any partial-payment rest vencimientos are removed). Functionally equivalent to DELETE /api/facturas/:id/cobros/:cobro_id but addressed directly by cobro ID, without needing the parent invoice ID.
Path parameter
| Parameter | Description |
|---|---|
:id | UUID of the cobro to delete. |
GET /api/facturas/:id/vencimientos
Returns all due-date instalments for the invoice, including their currentestado (pending, partial, cobrado, overdue).
GET /api/facturas/:id/vencimientos-disponibles
Returns only vencimientos with statuspending or partial — i.e. those that can still receive a cobro.
POST /api/facturas/:id/vencimientos
Manually adds a new due-date instalment to a confirmed invoice.Instalment sequence number. Must not duplicate an existing cuota on this invoice.
Amount due on this instalment.
Due date.
Payment instrument. Falls back to the company’s default instrument.
Optional note.
PATCH /api/facturas/:id/vencimientos/:vencimiento_id
Updates an existing vencimiento. If the vencimiento has a cobro, onlyfecha_vencimiento and notas can be changed (the importe is locked to the cobro amount).
New instalment amount.
New due date.
Replacement instrument.
Updated note.
DELETE /api/facturas/:id/vencimientos/:vencimiento_id
Removes a vencimiento. Blocked if the vencimiento has a cobro or is part of an agrupador.POST /api/facturas/:id/vencimientos/restaurar
Regenerates the full vencimiento schedule from the invoice’sforma_pago template. Only available for confirmed invoices with no existing cobros.
POST /api/facturas/:id/vencimientos/:vencimiento_id/revertir-cobro
Reverts all cobros on a specific vencimiento, restoring it topending. Any rest vencimientos created by partial payments are also removed. Use this to undo a collection entered in error.
Response