Every resource in the VeriFactuAPI is represented by a dedicated PHP class in verifactuPHP. These model classes encapsulate the fields required by the API, enforce correct data types, and expose a singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/NemonInvocash/verifactu-php/llms.txt
Use this file to discover all available pages before exploring further.
getArrayData() method that serializes the object into the exact array structure the API expects. Models are designed to be composable — smaller models such as Emisor, Destinatario, and Desglose are nested inside the top-level submission objects RegistroAlta and RegistroAnulacion.
Available models
| Class | Factory method | Purpose |
|---|---|---|
Emisor | nuevoEmisor() | The invoice issuer. Holds the NIF, company name, optional representative details, webhook assignment, and AEAT submission flags. |
Destinatario | nuevoDestinatario() | The invoice recipient. Holds the NIF or foreign identification details (otroCodPais, otroIDType, otroID) for domestic and cross-border invoices. |
Tercero | nuevoTercero() | A third party that issues an invoice on behalf of the emisor. Uses prefixed fields (tercNombreRazon, tercNIF, etc.) to avoid field-name collisions with Destinatario. |
Desglose | nuevoDesglose() | A single tax breakdown line. Specifies the tax type (Impuesto, lista L1), fiscal regime (ClaveRegimen / ClaveRegimenIGIC), rate (TipoImpositivo), taxable base, and charged tax amount. |
RegistroAlta | nuevoRegistroAlta() | The main invoice registration record submitted to AEAT. Aggregates an Emisor, Destinatario, Desglose, and optionally a Tercero, FacturaRectificada, or FacturaSustituida. |
RegistroAnulacion | nuevoRegistroAnulacion() | An invoice cancellation record. References a previously registered invoice by IDEmisorFactura, NumSerieFactura, and FechaExpedicionFactura. |
FacturaRectificada | nuevaFacturaRectificada() | Identifies a prior invoice being corrected by the current RegistroAlta. Contains the issuer ID, series number, and issue date of the original invoice. |
FacturaSustituida | nuevaFacturaSustituida() | Identifies a prior invoice being replaced (substituted) by the current RegistroAlta. Shares the same three-field structure as FacturaRectificada. |
Key patterns
1. Models are created through ClienteVerifactu factory methods
All models must be instantiated through the corresponding factory method onClienteVerifactu. The factory wraps the constructor, emits debug output when debug mode is enabled, and propagates any construction errors as Exception instances with descriptive messages.
2. Models accept a flat array in their constructor
Each model class accepts a single associative array whose keys match the PHP property names (camelCase). Any key not supplied defaults to an empty string,0, or 0.0 depending on the property type — there is no need to pass every field.
3. getArrayData() serialises only non-empty fields
When you call getArrayData() on any model, it iterates over its internal $APIids map and includes only fields whose value is neither an empty string nor 0 (nor 0.0 for floats). Empty fields are silently omitted. This means the resulting array contains exactly the fields the API needs — no nulls, no empty strings.
4. empty() provides a safe default placeholder
Every model exposes a static empty() factory that returns a fully-initialised instance with all fields set to their zero values. RegistroAlta uses this internally — if you omit 'destinatario', 'tercero', 'facturaRectificada', or 'facturaSustituida' from the objects array, the constructor falls back to the corresponding empty() instance. Because getArrayData() omits zero-value fields, an empty model contributes nothing to the serialised output.
Composing a RegistroAlta
The example below shows how the individual models are built and composed into aRegistroAlta ready for submission:
Model reference pages
Emisor
Invoice issuer — NIF, name, AEAT submission settings.
Destinatario
Invoice recipient — NIF or foreign identification fields.
Desglose
Tax breakdown — IVA/IGIC type, regime, rates, and amounts.
Tercero
Third-party issuer acting on behalf of the emisor.
RegistroAlta
Main invoice registration record submitted to AEAT.
RegistroAnulacion
Invoice cancellation record.
FacturaRectificada
Reference to the invoice being corrected.
FacturaSustituida
Reference to the invoice being substituted.

