Invoicing and VeriFactu
Lifecycle of invoices, quotes and proformas; series, Spanish taxes, issuing with VeriFactu, corrective and simplified invoices, PDF, Facturae and third-party invoices.
Document types
| Document | Path | Notes |
|---|---|---|
| Invoice | /invoices/ | Includes corrective (is_rectifying) and simplified (is_simplified) invoices. |
| Quote | /quotes/ | Accepted or rejected and converted into a proforma or invoice. |
| Proforma | /proformas/ | Preliminary document with no tax value; converted into an invoice. |
| Third-party invoice | /external-invoices/ | Income invoices the organization does not issue (self-billing). |
| Recurring invoice | /recurring-invoices/ | Templates that generate invoices periodically. |
| Credit note (legacy) | /credit-notes/ | Credit notes from the previous system. They are not VeriFactu corrective invoices: use /invoices/{id}/create-rectifying/. |
All sales documents share a structure: customer, series, dates, currency, notes and lines; Billora computes subtotal, tax_total, withholding_total, surcharge_total, total and balance (outstanding).
Reading documents requires invoices:read; creating, issuing and every other action, invoices:write.
From draft to issued invoice
PATCH / DELETE
┌──────┐
▼ │
POST ───▶ draft ───┘ ──── POST /send/ ───▶ sent ──▶ partially_paid ──▶ paid
/invoices/ (number + │
VeriFactu) ├──▶ overdue
├──▶ cancelled (POST /cancel/)
└──▶ rectified (corrective invoices issued)1. Create the draft
/api/v1/invoices/invoices:write{
"customer": 318,
"series": 12,
"due_date": "2026-12-01",
"currency": "EUR",
"notes": "Pedido 2026-1042",
"terms": "Pago por transferencia a 30 días.",
"lines": [
{ "product": 77, "description": "Licencia anual", "quantity": "1", "unit_price": "1200.00", "spanish_taxes": [1] },
{ "description": "Formación (4 h)", "quantity": "4", "unit_price": "60.00", "discount_percent": "10", "spanish_taxes": [1] }
]
}| Field | Description |
|---|---|
customer | Customer id. Required except for simplified invoices. |
series | Numbering series (type INVOICE). Needed to issue. |
due_date | Due date. Recomputed from the payment terms, if any, when issuing. |
operation_date | Operation date if different from the issue date. |
currency, exchange_rate | ISO currency and rate to euros if not EUR. |
payment_terms | Payment terms (/payment-terms/). |
income_category | Income category (/income-categories/). With accounting_account (a group 7 account) on the category, its sales are booked to that account. |
accounting_account | Accounting account of the sale. Priority: invoice account → category account → 700/705 by product type. A 2xx account makes it a fixed-asset sale (see below). |
fixed_asset | Fixed-asset sale: record of the asset sold (/accounting/fixed-assets/), required when accounting_account is 2xx. |
notes, terms | Texts shown on the document. |
external_reference | Your reference (order, contract…). Useful for reconciliation. |
metadata | Free-form JSON object for your own data. |
lines[] | description, quantity, unit_price (before tax), discount_percent, product (optional) and spanish_taxes (tax ids). |
The issue date (issue_date) and the number (number) are not sent: Billora assigns them when issuing.
2. Edit or delete the draft
/api/v1/invoices/{id}/invoices:writeSend only the fields that change. If you send lines, all lines are replaced. A draft is deleted with DELETE /invoices/{id}/ (204). Issued documents can't be deleted or edited.
3. Issue
/api/v1/invoices/{id}/send/invoices:writeAssigns the number and issue date, records the invoice in VeriFactu and marks it as issued. Irreversible. Doesn't send any email.
{
"number": "F-2026-0042",
"status": "sent",
"message": "Factura enviada correctamente",
"verifactu_processed": true,
"sent_to_aeat": true
}Issuing is atomic: if numbering or the VeriFactu record fails, the API returns an error, the invoice stays a draft and no series number is consumed. Always send an Idempotency-Key when issuing.
Numbering series
/api/v1/settings/series/series:readEach series has a type (INVOICE, CREDIT_NOTE, QUOTE, PROFORMA…), a prefix/suffix, number padding and a reset policy (for example yearly). The number is assigned when issuing, sequentially and without gaps, so you must not compute it yourself.
- Regular and simplified invoices:
INVOICEseries. - Corrective invoices:
CREDIT_NOTEseries (for exampleR-2026-0001). - Use separate series if you need separate numbering (for example one per shop or channel).
Series are created in Settings → Series in the app.
Spanish taxes
/api/v1/spanish-tax-rates/taxes:readLine taxes go in spanish_taxes as ids from this catalog:
{
"id": 9,
"name": "IRPF Profesionales 15%",
"tax_type": "IRPF_PROF",
"category": "retencion",
"rate": "15.00",
"is_active": true
}tax_type | Tax | category |
|---|---|---|
IVA | VAT (21, 10, 4, 0%, exemptions) | incremental |
IGIC | IGIC (Canary Islands) | incremental |
IPSI | IPSI (Ceuta and Melilla) | incremental |
RECARGO | Equivalence surcharge (5.2%, 1.4%, 0.5%…) | incremental |
IRPF_PROF | IRPF withholding on professional services (15%, 7%…) | retencion |
IRPF_ARR | Withholding on rentals (19%) | retencion |
RET_ESP | Other withholdings | retencion |
A line combines one main tax (IVA, IGIC or IPSI), optionally the equivalence surcharge and optionally one withholding. incremental taxes are added and retencion ones are subtracted:
{ "description": "Honorarios octubre", "quantity": "1", "unit_price": "1000.00", "spanish_taxes": [1, 9] }| Amount | |
|---|---|
| Tax base | €1,000.00 |
| VAT 21% | + €210.00 |
| IRPF withholding 15% | − €150.00 |
| Total | €1,060.00 |
- Exempt or non-taxable operations use the catalog rates with their legal ground (for example exempt under art. 20 or intra-EU supply under art. 25), which is what is reported to VeriFactu.
- Ids are stable, but don't hard-code them: read them from the catalog once and keep them in your configuration.
- If a line references a
productand you don't sendspanish_taxes, the product's default taxes apply. - Other read-only endpoints with
taxes:read:/spanish-tax-regimes/,/tax-templates/and/organization-tax-config/.
VeriFactu
Billora is a VeriFactu invoicing system (Spanish Royal Decree 1007/2023). When an invoice is issued:
- The invoicing record is generated, with its hash chained to the previous invoice.
- If the organization has VeriFactu enabled, the record is submitted to the Spanish Tax Agency (AEAT) and the invoice gets the QR code and the “VERI*FACTU” legend.
- Cancellations (
/cancel/) generate their own cancellation record.
Related invoice fields:
| Field | Description |
|---|---|
verifactu_mode | Organization mode when issued. |
verifactu_status | Record status at the tax agency (pending, accepted, accepted with errors, rejected…). |
verifactu_qr_url / has_verifactu_qr | QR verification URL and whether the PDF includes it. |
Submission to the tax agency can complete a few seconds after issuing. To find out without polling, subscribe to the invoice.verifactu.accepted and invoice.verifactu.rejected events (webhooks). If a record is rejected or the submission fails, you can retry it (with an amendment when appropriate) with:
/api/v1/invoices/{id}/retry-verifactu/invoices:writeInvoicing from several systems
VeriFactu requires every invoice to be recorded in the system that issues it. If you issue with Billora through the API, don't also issue it in another program: use Billora as the single issuer and download the PDF from here.
Cancelling an invoice
/api/v1/invoices/{id}/cancel/invoices:writeCancels an issued invoice (and records the cancellation in VeriFactu). Only appropriate when the invoice should never have been issued; rectified or already cancelled invoices can't be cancelled. To correct amounts or data of a valid invoice, issue a corrective invoice.
If the invoice has payments (paid or partially paid) it can only be cancelled with refund=true (query ?refund=true or body {"refund": true}): Billora first records the refund to the customer of each payment (Payment with is_refund: true and a negative amount; entry debit 4300xxxx / credit 572) and then the reversal. Without refund it returns 400 with {"code": "refund_required", "paid_amount": "…"}. The response with refunds is {status, refunds: [Payment…]}.
Selling a fixed asset
An invoice whose accounting_account is a 2xx account and carries fixed_asset (the asset record) records the sale of the asset: the entry is debit 4300xxxx + 28x (+ 671 on a loss) / credit 2xx + 477 (+ 771 on a gain) and the record becomes disposed with disposal_date = invoice date and disposal_amount = net amount. With fixed_asset and no accounting_account the asset's account is used; a 2xx account without fixed_asset returns 400. Cancelling the invoice reactivates the record.
Corrective invoices
/api/v1/invoices/{id}/create-rectifying/invoices:writeCreates, from an issued invoice, a draft corrective invoice. Answers 201 with {rectifying_invoice_id, rectification_type, detail}; the new invoice carries is_rectifying: true, rectifies: <original id> and metadata.rectification_type.
{ "notes": "Return of 2 defective units", "series": 13 }rectification_type | What it creates |
|---|---|
differences (default) without lines | Full reversal: every line of the original, negated. |
differences with lines | Partial correction by differences: only the lines sent, with their sign as given (e.g. "unit_price": "-50.00"). An invoice may have several partial corrections. |
substitution (requires lines) | Correction by substitution: full reversal of the original plus the correct lines, in a single document of the R series. |
{ "rectification_type": "differences", "lines": [{ "description": "Late-delivery discount", "quantity": "1", "unit_price": "-50.00", "spanish_taxes": [1] }] }lines has the same format as in POST /invoices/.
- Review the draft (you can edit its lines with
PATCH). - Issue it with
POST /invoices/{id}/send/: it is numbered with aCREDIT_NOTEseries and recorded in VeriFactu as a corrective invoice. - The original invoice's outstanding amount goes down; if issued corrective invoices cover its whole amount it becomes
rectified. Its detail includescredited_amount,refund_dueandrectified_by.
The corrective invoice of a simplified invoice is simplified too.
Simplified invoices
Send "is_simplified": true when creating the invoice. They can be issued without a customer: if you don't send customer, Billora uses “Consumidor final” (end consumer). Spanish rules limit their use (generally amounts up to €400 VAT included, or €3,000 in certain sectors).
Quotes and proformas
| Action | Endpoint |
|---|---|
| Create a quote | POST /quotes/ (same body as an invoice) |
| Number and mark as sent | POST /quotes/{id}/send/ |
| Accept / reject | POST /quotes/{id}/accept/ · POST /quotes/{id}/reject/ |
| Convert into a proforma | POST /quotes/{id}/to-proforma/ |
| Convert into an invoice | POST /quotes/{id}/to-invoice/ |
| Convert a proforma into an invoice | POST /proformas/{id}/to-invoice/ |
Conversions copy customer, lines and taxes and answer 201 with the new document (invoice_id or proforma_id). Since they create a document, they count towards the plan's document quota (like create-rectifying). The resulting invoice is a draft: review it and issue it with /send/. You can set the invoice's series and due date:
{ "series": 12, "due_date": "2026-12-15" }Quote statuses: draft, sent, accepted, rejected, expired. Proforma statuses: draft, sent, invoiced, cancelled.
Email and payment links
/api/v1/invoices/{id}/email/invoices:writeEmails the PDF to the recipients in to (if omitted, to the customer's email). Works the same on /quotes/{id}/email/ and /proformas/{id}/email/.
{ "to": ["administracion@talleresmartin.es"] }With POST /invoices/{id}/collect-payment/ Billora creates a card payment link (requires the Stripe integration) and sends it to the customer with the invoice; the response includes checkout_url.
PDF and Facturae
| Download | Endpoint | Type |
|---|---|---|
| Invoice PDF | GET /invoices/{id}/download-pdf/ | application/pdf |
| Facturae 3.2.2 (unsigned XML) | GET /invoices/{id}/download-facturae/ | application/xml |
| Quote / proforma PDF | GET /quotes/{id}/download-pdf/ · GET /proformas/{id}/download-pdf/ | application/pdf |
- The PDF uses the organization's configured design. A draft downloads marked as a draft.
- Facturae is meant for invoicing Spanish public administrations (FACe): the customer must have its DIR3 codes (
dir3_unit,dir3_organ,dir3_office). Sign it with your certificate before submitting it if your flow requires it.
curl -L https://api.billora.app/api/v1/invoices/5120/download-facturae/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-o F-2026-0042.xmlThird-party and self-billed invoices
Some income invoices are not issued by the organization: the customer issues them on its behalf (self-billing, for example an insurer invoicing its agent's commissions) or a third party does. Those invoices already have a number and are already recorded by their issuer, so they are not created with /invoices/ nor issued: they are registered as-is in /external-invoices/.
/api/v1/external-invoices/invoices:write{
"issuer_type": "recipient",
"external_issuer_name": "Aseguradora Ejemplo, S.A.",
"customer": 412,
"number": "AF-2026/000318",
"issue_date": "2026-10-31",
"declared_total": "1210.00",
"lines": [
{ "description": "Comisiones octubre 2026", "quantity": "1", "unit_price": "1000.00", "spanish_taxes": [1] }
]
}issuer_type:recipient(self-billing: issued by the customer) orthird_party(issued by a third party).declared_totalis the original document's total: Billora checks it matches the lines.- Attach the original PDF with a
multipart/form-datarequest and theoriginal_documentfield; download it withGET /external-invoices/{id}/document/. - They are not renumbered nor sent to VeriFactu, but they count in VAT books, reports and accounting, and accept payments like any invoice.
- Cancel them with
POST /external-invoices/{id}/cancel/(if they have no payments). Trying to issue or correct them through/invoices/returns400with"code": "external_invoice".
Related events
invoice.created, invoice.updated, invoice.issued, invoice.sent, invoice.paid, invoice.partially_paid, invoice.overdue, invoice.cancelled, invoice.rectified, invoice.deleted, invoice.verifactu.accepted, invoice.verifactu.rejected, quote.*, proforma.*, external_invoice.* and recurring_invoice.generated. See the event catalog.
Every field and filter of each endpoint is in the API reference.
