Skip to content

verifactu-sdkTypeScript SDK for AEAT VERI*FACTU

Issue, cancel and query Spanish invoices against the AEAT — with hash chaining, QR generation, mTLS and the full 23-rule validator built in.

verifactu-sdk

Install

bash
bun add verifactu-sdk
# or
npm i verifactu-sdk

In thirty lines

ts
import { VerifactuClient, Environment } from 'verifactu-sdk';
import { readFileSync } from 'node:fs';

const client = new VerifactuClient({
  environment: Environment.Preproduction,
  mode: 'verifactu',
  certificate: { pfx: readFileSync('./cert.pfx'), passphrase: process.env.CERT_PASS! },
  taxpayer: { nif: 'B12345678', legalName: 'My Company SL' },
  billingSystem: {
    producerName: 'My Company SL',
    nif: 'B12345678',
    systemId: 'JC',
    systemName: 'My App',
    version: '1.0.0',
    installationNumber: '0001',
    onlyVerifactu: 'S',
    multipleTaxpayer: 'N',
    hasMultipleTaxpayers: 'N',
  },
});

const response = await client.registerInvoice({
  invoiceId: { issuerNif: 'B12345678', seriesNumber: 'A/2026/0001', issueDate: '2026-05-20' },
  invoiceType: 'F1',
  recipients: [{ nif: '12345678Z', legalName: 'Customer SL' }],
  breakdown: [
    { tax: '01', regimeKey: '01', operationQualification: 'S1', taxRate: '21', taxBase: '100.00', taxAmount: '21.00' },
  ],
  totalTaxAmount: '21.00',
  totalAmount: '121.00',
  description: 'Consulting services',
});

console.log(response.csv, response.envelopeState);

Full quickstart →

Released under the MIT license.