Factuarea API
Invoices

Generate corrective invoice

Issue a corrective invoice (rectificativa, RD 1619/2012 art. 15) that amends a previously issued invoice. Returns 201 with the new invoice: is_corrective: true, corrective pointing at the original, and a number derived from the original's in the same series (F-2026-0042-REC1, -REC2… for successive correctives).

Flow: the original must already be issued (sent or paid) → the corrective is born already issued, never as a draft → when VeriFactu is enabled its alta is transmitted to AEAT asynchronously, so a 201 does not mean AEAT has accepted it yet. The original is never modified: it keeps its number, its status and its own VeriFactu record. A corrective is an additional document, not an edit.

Full vs partial. correction_type: full is a substitution (VeriFactu nature S): the lines you send are the final correct amounts, and omitting lines entirely turns it into a full cancellation, where every original line is copied back negated and prefixed [ANULACION]. correction_type: partial is a correction by differences (nature I): lines is required and each one is a delta — typically negative — prefixed [AJUSTE]. In a partial correction a line only moves stock if it declares its own product_id; in a substitution the product is inherited from the original line at the same index.

AEAT R code. By default it is derived from correction_reason: error_fundado → R1, concurso → R2, incobrable → R3, everything else → R4; a corrective of a simplified (F2) invoice is always born R5 regardless of the reason. correction_code overrides that derivation, but is validated against the legal matrix — original F2 → only R5; original F1/F3 → only R1R4. Any other combination returns 422 with the legal allowed_values.

Limits: draft, overdue, cancelled and annulled originals return 422 (an overdue invoice must be paid or voided first); a corrective can never itself be corrected — issue a new corrective of the original instead. List every corrective of an invoice with GET /v1/invoices/{id}/correctives.

POST
/invoices/{invoice}/corrective
AuthorizationBearer <token>

In: header

Path Parameters

invoice*string

Header Parameters

Idempotency-Key?string

Client-generated opaque key (up to 255 characters; UUID v7 recommended) that makes retries safe: the first response is cached and replayed for repeats without re-executing the mutation. Reusing a key with a different body returns 409 idempotency_key_reused. See the Idempotency guide.

Length1 <= length <= 255
Factuarea-Version?string

Pin the API version (YYYY-MM-DD, Stripe-style date versioning) for this request; omit to use the key's pinned version, or the latest if none. Unsupported version → 400 unsupported_api_version; malformed → 400 parameter_invalid_format. The effective version is echoed in the Factuarea-Version response header. See the Versioning guide.

Formatdate
X-Active-Profile?string

Operate on behalf of a child company (gestoría master key): pass its public id (UUID v7) and the request runs against that child's data without changing the key's scope, tier or environment (omit to use the key's own company). Invalid UUID → 400 parameter_invalid_uuid; unknown or non-owned id → 404 profile_not_found. See the Acting on behalf guide.

Formatuuid

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

import { Factuarea } from "@factuarea/sdk";const factuarea = new Factuarea({ apiKey: process.env.FACTUAREA_API_KEY! });const result = await factuarea.invoices.corrective("01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a01", {    // request body — see the schema below  });
{
  "data": {
    "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a60",
    "object": "invoice",
    "number": "RECT-2026-00007",
    "is_number_assigned": true,
    "type": "R1",
    "series": {
      "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8b04",
      "code": "RECT-2026"
    },
    "client": {
      "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a01",
      "name": "Acme Soluciones SL"
    },
    "status": "issued",
    "issued_on": "2026-03-22",
    "due_on": "2026-04-21",
    "subtotal": -500,
    "taxes_total": -105,
    "total": -605,
    "total_disbursements": 0,
    "total_to_pay": -605,
    "currency": "EUR",
    "notes": "Rectificativa por descuento comercial sobre FAC-2026-00010.",
    "external_id": "ERP-RECT-2026-0007",
    "lines": [
      {
        "object": "invoice_line",
        "description": "Rectificación: descuento comercial 5 h consultoría",
        "product": {
          "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8b03",
          "name": "Consultoría técnica (hora)"
        },
        "quantity": 5,
        "unit_price": -100,
        "tax_rate": 21,
        "retention_rate": 0,
        "surcharge_rate": 0,
        "discount_percent": 0,
        "subtotal": -500,
        "taxes": -105,
        "total": -605,
        "indirect_tax_regime": "iva",
        "aeat_tax_code": "S1",
        "line_type": "NORMAL"
      }
    ],
    "metadata": {
      "order_id": "PO-2026-0010"
    },
    "tags": [
      "rectificativa",
      "cliente-vip"
    ],
    "custom_fields": [
      {
        "field": "centro_coste",
        "value": "CC-2026-001"
      }
    ],
    "operation_regime": "general",
    "exemption_reason": null,
    "legal_mentions": [],
    "exclude_347": false,
    "verifactu_status": "accepted",
    "paid_amount": 0,
    "pending_amount": -605,
    "payments": {
      "detail": [],
      "total": 0,
      "pending": -605
    },
    "is_corrective": true,
    "corrective": {
      "original_id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a10",
      "original_number": "FAC-2026-00010",
      "original_date": "2026-02-01",
      "correction_reason": "R1",
      "correction_type": "por_sustitucion",
      "correction_nature": "S",
      "base_rectificada": -500,
      "cuota_rectificada": -105,
      "correction_aeat_type": "R1"
    },
    "payment": null,
    "public_link": {
      "object": "public_link",
      "url": "https://app.factuarea.com/d/01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a60",
      "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a60",
      "enabled": true,
      "expires_at": "2026-09-22T23:59:59Z",
      "max_days": 120
    },
    "substituted_by": {
      "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a50",
      "number": "FAC-2026-00050"
    },
    "recurring": {
      "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a08"
    },
    "paid_at": null,
    "paid_on": null,
    "sent_at": "2026-03-22T09:10:00Z",
    "voided_at": null,
    "void_reason": null,
    "scheduled_for": null,
    "scheduled_action": null,
    "created_at": "2026-03-22T09:00:00Z",
    "updated_at": "2026-03-22T09:10:00Z"
  }
}

{
  "error": {
    "type": "authentication_error",
    "code": "missing_api_key",
    "message": "No se ha proporcionado una API key válida en el header Authorization.",
    "param": null,
    "doc_url": "https://docs.factuarea.com/guides/errors#missing_api_key",
    "request_id": "req_01HKQS5N8VR7QXJ9K3T6BWPMZA"
  }
}

{
  "error": {
    "type": "authorization_error",
    "code": "insufficient_scope",
    "message": "Esta API key no tiene el scope requerido para esta operación.",
    "param": null,
    "doc_url": "https://docs.factuarea.com/guides/errors#insufficient_scope",
    "request_id": "req_01HKQS5NBC3P8M1KX4V7SLNHQD"
  }
}

{
  "error": {
    "type": "not_found_error",
    "code": "resource_not_found",
    "message": "El recurso solicitado no existe o pertenece a otra empresa.",
    "param": null,
    "doc_url": "https://docs.factuarea.com/guides/errors#resource_not_found",
    "request_id": "req_01HKQS5NEQ6X1R4N9B0C5DWTPG"
  }
}

{
  "error": {
    "type": "idempotency_error",
    "code": "idempotency_key_reused",
    "message": "La cabecera `Idempotency-Key` ya se usó con un body distinto. Usa una clave nueva o reenvía exactamente el mismo body.",
    "param": null,
    "doc_url": "https://docs.factuarea.com/guides/errors#idempotency_key_reused",
    "request_id": "req_01HKQS5NHT9A4U7R2E3F8GZWTJ"
  }
}

{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "El campo `name` es obligatorio y no puede estar vacío.",
    "param": "name",
    "doc_url": "https://docs.factuarea.com/guides/errors#parameter_invalid",
    "request_id": "req_01HKQS5NGS8Z3T6Q1D2E7FYVSI"
  }
}

{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "message": "Has excedido el rate limit de 60 peticiones por minuto. Reintenta tras 30 segundos.",
    "param": null,
    "doc_url": "https://docs.factuarea.com/guides/errors#rate_limit_exceeded",
    "request_id": "req_01HKQS5NKW1C6W9T4G5H0JBZVL"
  }
}

{
  "error": {
    "type": "api_error",
    "code": "internal_error",
    "message": "Ha ocurrido un error inesperado. Si persiste, contacta con soporte adjuntando el request_id.",
    "param": null,
    "doc_url": "https://docs.factuarea.com/guides/errors#internal_error",
    "request_id": "req_01HKQS5NLX2D7X0U5H6J1KCAWM"
  }
}