Create a corrective invoice
Scopeinvoices:writeIssues a corrective invoice that amends the invoice in the path. It is a new fiscal document with its own number, not an edit of the original.
rectification_type:TOTALleaves the originalVOIDEDand rectifies what is still invoiced on it: every line of the original and of its live correctives (voided ones do not count), negated. It takes nolines— sending them fails with422 RECTIFICATIVA_TOTAL_CON_LINEAS.PARTIALleaves the originalRECTIFIEDand requires the adjustmentlines.- Never more than was invoiced: a
PARTIALmay raise any amount, but may not take the taxable base of any rate (tax, rate and equivalence surcharge;SUPLIDOlines by their amount) below zero once the previous correctives are counted. That fails with422 CORRECTIVE_EXCEEDS_INVOICED_AMOUNT, anderror.details(CorrectiveInvoiceErrorDetails) carriestax_group(for exampleIVA 21%) andmax_reduction, how much of that rate is left to rectify. ATOTALon an invoice that previous correctives already brought to zero fails with422 CORRECTIVE_NOTHING_LEFT_TO_RECTIFY. - Not for the withholding alone: a
PARTIALwhose lines leave the taxable base of every rate unchanged and only change the withholding fails with422 CORRECTIVE_WITHHOLDING_ONLY. A withholding is not a cause for a corrective: void the invoice and issue a new one without it. - The original's PDF: unchanged by either type. The corrective has its own PDF; the
original keeps the one that was delivered, and its new status is in
status. - Total of 0: a corrective whose
total_to_payis 0 has nothing to refund or collect, so it is issued asPAID, withpayment_dateequal toissue_date. - What can be rectified: an ordinary or simplified invoice in
ISSUED,SENT,PAID,OVERDUEorRECTIFIED. Rectifying a corrective fails with422 CORRECTIVE_NOT_RECTIFIABLE— to fix an erroneous corrective, issue another one against the original invoice. - Repeat rectifications: several
PARTIALcorrectives are allowed, but aVOIDEDinvoice is no longer rectifiable, so a secondTOTALagainst the same invoice fails with422 INVOICE_NOT_CORRECTIBLE_IN_CURRENT_STATUS. - Correcting the recipient's data: when the invoice recorded its recipient with a wrong
name, tax ID or address, send the corrected
recipientwithrectification_typePARTIAL,rectification_codeR4and nolines. The corrective carries the corrected recipient and does not change the amounts: its lines negate what is still invoiced and repeat it, so every rate nets to zero. A different person is not a data correction (422 CORRECTIVE_RECIPIENT_IS_ANOTHER_PERSON): correct the invoice in full and issue a new one to the right customer. - Original rejected by the AEAT: when VeriFactu rejected the original's record and it
has not been resubmitted, the original is not in the AEAT's books: fix and resubmit it
first. Until then the request fails with
422 CORRECTIVE_ORIGINAL_RECORD_REJECTED. - Exchange invoice recorded as F3: correcting a full invoice issued in exchange for
simplified invoices is not available yet:
422 EXCHANGE_INVOICE_NOT_CORRECTABLE. Contact support. - Deadline: four years from when the tax accrued (the original's operation date) or,
for a cause of article 80 of the VAT Act, from the
circumstance_dateyou declare. Past it the request fails with422 CORRECTIVE_OUT_OF_TIME, withdeadlineandcounted_frominerror.details(CorrectiveInvoiceErrorDetails). - What the reason code requires (Ley 37/1992, art. 80):
R2(insolvency) andR3(bad debt) need a recipient established in Spain, the Canary Islands, Ceuta or Melilla —anR2also accepts a recipient in another EU member state, for insolvency proceedings there— and fail otherwise with422 CORRECTIVE_RECIPIENT_NOT_ESTABLISHED. AnR3needs at least six months since the original's operation date (422 CORRECTIVE_BAD_DEBT_TOO_EARLY, withearliest_date; one year when the previous year's turnover exceeded 6,010,121.04 €, which is the issuer's to apply), and on an operation with a base of 50 € or less it needsrecipient_is_business(422 CORRECTIVE_BAD_DEBT_BASE_TOO_LOW). The other conditions of each code (claims, guarantees, related parties, filing with the AEAT) are the issuer's to meet. - Fiscal inheritance on a
PARTIAL: a line that omitsirpf_rateorequivalence_surcharge_ratetakes it from the original invoice — the document being amended — and never from the company's current tax profile, so a profile that changed after the original was issued does not leak into the credit note. An explicit value always wins,0included. The surcharge inherits the regime (on/off), not the rate: the rate is re-derived from each corrective line's own VAT (21→5.2, 10→1.4, 5→0.62, 4→0.5), and an original outside the regime pins the line to0.SUPLIDOlines are out of it on both sides. When the original is not unambiguous BeeL does not pick for you: different IRPF rates per line fail with422 CORRECTIVE_ORIGINAL_MIXED_IRPF, and a surcharge applied on some lines but not others fails with422 CORRECTIVE_ORIGINAL_MIXED_SURCHARGE. Declare the figure on every line to get past either — both only fire when some line actually needs to inherit. series_id: when omitted, the document is numbered in the company's default corrective series, never in the series of the original: corrective invoices go in a series of their own (RD 1619/2012, art. 6.1.a). If the company has none, it is created on first use (codeR, or the next free one that cannot repeat another series' numbers). An explicitseries_idmust be a corrective series.- Numbering conflict: if the number the series would assign is already used by another
invoice of the same company, in this series or in another one, the request fails with
400 SERIES_NUMBER_COLLISIONwithout issuing anything or consuming a number. The series needs review, so contact support.
Keys are prefixed beel_sk_, and each one carries the scopes it was created with: a key
short of the scope an operation needs is answered 403. The scope an operation requires
is shown next to its title, and the full catalogue lives in the Scopes reference.
Keys are created from the BeeL dashboard. They are secret credentials: do not share them or commit them to source control.
In: header
Path Parameters
Unique identifier (UUID) of the company the operation acts on — its identifier, not its NIF. It is the only source of context: the account that owns it is derived from it, and the BeeL-Active-Company header plays no part. A company you do not reach answers 403, and so does a company that does not exist, so the existence of a company in another account is never disclosed.
uuidInvoice ID
uuidHeader Parameters
Idempotency key to prevent duplicates in sensitive operations.
- Any unique client-generated string (e.g. an order id). A UUID also works but is not required
- Allowed characters: letters, digits,
_and-(max 255 chars) - Retrying with the same key replays the first response when it was a success (2xx) or a
server error (5xx): same status and body, plus the header
Idempotency-Replay: true. After a 5xx, check whether the operation took effect before retrying with a new key - A 4xx is not stored: the key is released, so the corrected request can reuse it
- Stored responses expire 24 hours after processing
The key is scoped per user and environment, and bound to the request body, so retrying after a network timeout replays the stored response instead of repeating the operation.
| Status | Code | When |
|---|---|---|
400 | INVALID_IDEMPOTENCY_KEY | The key breaks the format rules above. |
409 | IDEMPOTENCY_KEY_PROCESSING | The first request is still in flight. Wait for the Retry-After seconds (2) and retry with the same key. |
409 | IDEMPOTENCY_KEY_MISMATCH | The key was already used with a different body. Use a new key. |
^[a-zA-Z0-9_-]+$length <= 255Type of rectification applied to a corrective invoice:
- TOTAL: Rectifies everything still invoiced on the original, its live correctives included (status → VOIDED)
- PARTIAL: Partially corrects the original invoice (status → RECTIFIED)
"TOTAL" | "PARTIAL"Rectification codes according to VeriFactu regulations (AEAT):
- R1: Error founded in law and Art. 80 One, Two and Six LIVA
- R2: Article 80 Three LIVA (Bankruptcy proceedings)
- R3: Article 80 Four LIVA (Uncollectable debts)
- R4: Other causes
- R5: Corrective of a simplified invoice - ONLY for simplified invoices
"R1" | "R2" | "R3" | "R4" | "R5"Detailed reason for rectification (minimum 10 characters)
10 <= length <= 1000TOTAL: not accepted. A TOTAL corrective rectifies what is still invoiced on the
original —its lines and those of its live correctives, negated— and a request with
lines fails with 422 RECTIFICATIVA_TOTAL_CON_LINEAS.
PARTIAL: required. The adjustment lines, with positive or negative amounts; they
may not take the base of any rate below zero (422 CORRECTIVE_EXCEEDS_INVOICED_AMOUNT).
When the circumstance that causes the rectification took place, if it is one of article 80 of the VAT Act (Ley 37/1992): a discount granted after the sale, an operation cancelled or a price changed after it took place, the customer's insolvency, a bad debt. Optional.
A corrective must be issued within four years from when the tax accrued or, for those
causes, from when the circumstance took place (RD 1619/2012, art. 15.3). Without this
date the four years count from the original's operation date (its operation_date, or
its issue_date when it has none), the stricter of the two. Past the deadline the request
fails with 422 CORRECTIVE_OUT_OF_TIME.
Only for R1, R2, R3 and R5: R4 covers causes other than article 80, and sending
it with R4 fails with 422 CORRECTIVE_CIRCUMSTANCE_DATE_NOT_APPLICABLE. It must lie
between the original's operation date and today
(422 CORRECTIVE_CIRCUMSTANCE_DATE_OUT_OF_RANGE).
dateDeclares that the recipient acted as a business or professional in the operation being
rectified. Optional, and it only matters for a bad-debt corrective (R3) on an
operation whose taxable base is 50 € or less: the law allows that reduction only when
the recipient acted as a business or professional, and the invoice does not say so
(Ley 37/1992, art. 80.Cuatro.A.3.ª). Without it, that R3 fails with
422 CORRECTIVE_BAD_DEBT_BASE_TOO_LOW.
Additional observations about the rectification
length <= 1000Series for the corrective invoice. Optional: if not specified, the company's
default series for corrective invoices is used — not the original invoice's
series, which is an ordinary or simplified one and cannot hold a corrective.
If the company has no default corrective series, one is created on first use; a
series of the wrong type fails with 422 SERIES_INCOMPATIBLE_DOC_TYPE.
uuidClient-supplied identifier from an external system (order, cart, contract…). Stored as-is, echoed back on read, and filterable via GET /v1/invoices?external_ref=. Optional. Enforced UNIQUE per issuer for live standard/simplified invoices: creating a second invoice with the same reference returns 409 (INVOICE_DUPLICATE_EXTERNAL_REFERENCE); deleting the existing one lets you recreate. Corrective invoices are exempt from that uniqueness: a corrective carries the same order reference as the invoice it corrects, so both can coexist. This is a business key, NOT the Idempotency-Key (which guards request retries).
length <= 255Your own key/value pairs to cross-reference this invoice with records in your system (order ids, tenants, internal codes). Namespace them to avoid clashing with the system keys BeeL adds on payment-generated invoices.
Controls how the invoice is processed after creation.
All fields default to false if not specified.
VeriFactu is not an option here: whether an invoice is registered with AEAT is a
fact of the tax identity (NIF x environment), resolved at issue time against the
company's regime. See verifactu.enabled in the invoice response for what was applied.
Common combinations:
- Draft (default): omit
optionsor set all tofalse - Issue immediately:
{ issue_directly: true } - Issue + wait for PDF:
{ issue_directly: true, wait_for_pdf: true } - Issue + send email:
{ issue_directly: true, send_automatically: true } - Full automation:
{ issue_directly: true, wait_for_pdf: true, send_automatically: true, email_config: { ... } }
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://app.beel.es/api/v1/companies/497f6eca-6276-4993-bfeb-53cbbbba6f08/invoices/550e8400-e29b-41d4-a716-446655440000/corrective" \ -H "Content-Type: application/json" \ -d '{ "rectification_type": "TOTAL", "rectification_code": "R1", "reason": "Spanish VAT was charged on a service not subject to it in Spain (Art. 69 LIVA): the invoice is rectified in full and reissued without VAT.", "notes": "The correct invoice is issued separately, without Spanish VAT." }'New corrective invoice created. Original invoice marked as RECTIFIED/VOIDED
{
"success": true,
"data": {
"id": "b8a4d0f3-c2e5-49b7-d4f0-c3f2b9e6d1f5",
"invoice_number": "A/2025/0043-R",
"series": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"code": "A"
},
"number": 43,
"type": "CORRECTIVE",
"status": "ISSUED",
"issue_date": "2025-01-25",
"rectified_invoice_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"rectification_reason": "Partial correction for bad debt under Art. 80 Cuatro LIVA",
"rectification_type": "PARTIAL",
"rectification_code": "R3",
"issuer": {
"legal_name": "Tu Empresa SL",
"nif": "B12345674",
"address": {
"street": "Calle Ejemplo",
"number": "123",
"postal_code": "28001",
"city": "Madrid",
"province": "Madrid",
"country": "España"
}
},
"recipient": {
"customer_id": "123e4567-e89b-12d3-a456-426614174000",
"legal_name": "Cliente Ejemplo SL",
"nif": "B87654321"
},
"lines": [
{
"description": "Bad debt adjustment - Full cancellation of outstanding amount",
"quantity": -40,
"unit": "hours",
"unit_price": 37.5,
"discount_percentage": 0,
"taxable_base": -1500,
"main_tax": {
"type": "IVA",
"percentage": 21,
"regime_key": "01"
},
"line_total": -1815
}
],
"totals": {
"taxable_base": -1500,
"total_vat": -315,
"total_irpf": 0,
"total_equivalence_surcharge": 0,
"vat_breakdown": [
{
"type": 21,
"base": -1500,
"amount": -315
}
],
"invoice_total": -1815
},
"verifactu": {
"enabled": true,
"invoice_hash": "B8A4D0F3C2E549B7D4F0C3F2B9E6D1F5A8C2E7B0D4F8C3A6B1E9D2F7A5C8E3B0",
"qr_url": "https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR?nif=B12345674&numserie=A%2F2025%2F0043-R&fecha=25-01-2025&importe=-1815.00",
"registered_at": "2025-01-25T11:00:00Z",
"submission_status": "ACCEPTED"
},
"pdf_download_url": "/v1/companies/7c9e6679-7425-40de-944b-e07fc1f90ae7/invoices/b8a4d0f3-c2e5-49b7-d4f0-c3f2b9e6d1f5/pdf",
"created_at": "2025-01-25T11:00:00Z",
"updated_at": "2025-01-25T11:00:00Z"
},
"meta": {
"timestamp": "2025-01-25T11:00:00Z",
"request_id": "a5b6c7d8-e9f0-4a1b-2c3d-4e5f6a7b8c9d"
}
}{
"success": false,
"error": {
"code": "INVALID_JSON_FORMAT",
"message": "The field 'due_date' has an invalid date format: '2026-03-04fds'. Expected format: YYYY-MM-DD.",
"details": {
"field": "due_date",
"invalid_value": "2026-03-04fds",
"expected_format": "YYYY-MM-DD"
}
},
"meta": {
"timestamp": "2026-03-05T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication is required to access this resource"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "The provided data is not valid",
"details": {
"field": "specific error message"
}
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
},
"type": "https://docs.beel.es/errors/INVOICE_NO_LINES",
"title": "INVOICE_NO_LINES",
"detail": "The invoice must have at least one line",
"instance": "/v1/invoices/abc-123"
}{
"success": false,
"error": {
"code": "INVOICE_NOT_FOUND",
"message": "Invoice not found"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
}{
"success": false,
"error": {
"code": "CONCURRENT_MODIFICATION",
"message": "The resource was modified by another request; read it again and retry"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
}An explicit series_id was sent, but that series is not typed for corrective invoices (e.g. an ordinary series). Pass a corrective series, or omit series_id to use the company default.
{
"success": false,
"error": {
"code": "SERIES_INCOMPATIBLE_DOC_TYPE",
"message": "The selected series is not compatible with this document type. Please select a series of the correct type.",
"details": {
"expected_document_type": "CORRECTIVE",
"defaults_status_endpoint": "GET /v1/companies/{company_id}/series/defaults"
}
},
"meta": {
"timestamp": "2025-02-01T10:20:00Z",
"request_id": "b2b2b2b2-0810-4000-a000-000000000422"
}
}{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please try again in 60 seconds."
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
}{
"success": false,
"error": {
"code": "INTERNAL_ERROR",
"message": "Internal server error"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
}{
"success": false,
"error": {
"code": "UNSUPPORTED_MEDIA_TYPE",
"message": "Unsupported media type: text/plain. Supported: application/json"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}
}Remove the scheduling of an invoice DELETE
Removes the scheduling of an invoice, returning it to a plain draft. Idempotent: an invoice that is not scheduled answers `204` all the same. Unlike the `PUT`, it does not require the `scheduled_invoices` feature.
Exchange simplified invoices for a full invoice POST
Issues a full invoice in exchange for one or more simplified invoices already issued, when the customer asks for an invoice with their details. It is not a corrective invoice: it documents the same operations again with the recipient identified (RD 1619/2012, art. 15.6). - **What it issues:** a `STANDARD` invoice with the lines of the simplified invoices and the `recipient` sent, numbered in `series_id` or in the company's default standard series. It lists the invoices it replaces in `replaced_invoice_ids`. - **The simplified invoices:** each becomes `VOIDED` with `void_cause` `EXCHANGED`, in the same act: their records are not cancelled, the exchange replaces them. They must be simplified invoices (`422 EXCHANGE_REQUIRES_SIMPLIFIED`), issued and not voided, exchanged or corrected before (`422 SIMPLIFIED_NOT_EXCHANGEABLE`), and each one listed once in `simplified_invoice_ids` (`422 EXCHANGE_DUPLICATED_SIMPLIFIED`, before anything is read or numbered). - **The exchange invoice** cannot be voided afterwards (`422 EXCHANGE_INVOICE_NOT_VOIDABLE`), and when it is recorded as `F3` it cannot be corrected yet (see the corrective operation). - **VeriFactu:** the exchange invoice is recorded as `F3`, identifying each simplified invoice it replaces by number and issue date. Each of them must already be accepted by the AEAT, or nothing is issued: one issued without VeriFactu fails with `422 SIMPLIFIED_EXCHANGE_NOT_RECORDABLE`; one whose record is still pending fails with `422 EXCHANGE_SIMPLIFIED_NOT_YET_ACCEPTED` (wait until the AEAT accepts it and retry); one whose record was rejected fails with `422 EXCHANGE_SIMPLIFIED_RECORD_REJECTED` (fix or resubmit it first).