Verifactu in Delphi: how to send invoices with the Verifactu API

With the Verifactu API you send an invoice from Delphi with THTTPClient (or WinHttpRequest on older versions): a JSON POST request to https://api.verifacti.com/verifactu/create that immediately returns the QR in Base64, the hash and a uuid. You don't need to generate the XML, compute the hash or use a digital certificate.

This tutorial uses Delphi XE8 or later with System.Net.HttpClient and System.JSON. For older versions, WinHttp.WinHttpRequest.5.1 through COM.

Before you start

  • A free Verifacti account: it includes a test environment and a test NIF.
  • The test API key of the test NIF (it starts with vf_test_) in the VERIFACTI_API_KEY environment variable. Never write it in the code.
  • Delphi XE8 or later (or Delphi 7 to XE7 with WinHttpRequest).

To register your own NIFs later, follow the Verifactu API quick start guide.

1. Authentication

Every call carries the Authorization: Bearer header with your API key. The API key sets the issuing NIF and the environment (test or production): you don't send them in the request. The base URL is https://api.verifacti.com, the same in test and production.

This tutorial uses THTTPClient (the class underneath TNetHTTPClient). Add this unit as VerifactiApi.pas: the other examples use it. The JSON goes as text and the response comes back as a TJSONValue.

VerifactiApi.pas
unit VerifactiApi;
// Una sola función para todas las llamadas a la API de Verifacti.
// Lee la API key de la variable de entorno VERIFACTI_API_KEY.

interface

uses
  System.SysUtils, System.Classes, System.JSON, System.Net.HttpClient, System.Net.URLClient;

type
  TVerifactiRespuesta = record
    Status: Integer;
    Json: TJSONValue; // libéralo con Json.Free
  end;

function VerifactiSend(const Method, Path: string; const Body: string = '';
  const IdempotencyKey: string = ''): TVerifactiRespuesta;
function Hoy: string;

implementation

const
  BASE_URL = 'https://api.verifacti.com';

function Hoy: string;
begin
  Result := FormatDateTime('dd-mm-yyyy', Now); // hora local del PC: tiene que estar en hora de España
end;

function VerifactiSend(const Method, Path, Body, IdempotencyKey: string): TVerifactiRespuesta;
var
  Http: THTTPClient;
  Headers: TNetHeaders;
  Source: TStringStream;
  Response: IHTTPResponse;
begin
  Http := THTTPClient.Create;
  Source := TStringStream.Create(Body, TEncoding.UTF8);
  try
    Headers := [TNetHeader.Create('Authorization', 'Bearer ' + GetEnvironmentVariable('VERIFACTI_API_KEY'))];
    if Body <> '' then
      Headers := Headers + [TNetHeader.Create('Content-Type', 'application/json')];
    if IdempotencyKey <> '' then
      Headers := Headers + [TNetHeader.Create('Idempotency-Key', IdempotencyKey)];

    if Method = 'GET' then
      Response := Http.Get(BASE_URL + Path, nil, Headers)
    else
      Response := Http.Post(BASE_URL + Path, Source, nil, Headers);

    Result.Status := Response.StatusCode;
    Result.Json := TJSONObject.ParseJSONValue(Response.ContentAsString(TEncoding.UTF8));
  finally
    Source.Free;
    Http.Free;
  end;
end;

end.

With another HTTP client

Delphi 7 to XE7 have no System.Net.HttpClient: use WinHttpRequest through COM, with no dependencies.

WinHttpRequest (Delphi 7 to XE7)
// Delphi 7 a XE7: WinHttp.WinHttpRequest.5.1 por COM, sin dependencias
uses
  ComObj, ActiveX, SysUtils;

procedure CrearFacturaWinHttp;
var
  Http: OleVariant;
  Factura: string;
begin
  CoInitialize(nil);
  try
    Factura :=
      '{"serie": "A", "numero": "1", "fecha_expedicion": "' + FormatDateTime('dd-mm-yyyy', Now) + '",' +
      ' "tipo_factura": "F1", "descripcion": "Servicios de consultoria",' +
      ' "nif": "A15022510", "nombre": "Empresa Cliente SL",' +
      ' "lineas": [{"base_imponible": "200.00", "tipo_impositivo": "21", "cuota_repercutida": "42.00"}],' +
      ' "importe_total": "242.00"}';

    Http := CreateOleObject('WinHttp.WinHttpRequest.5.1');
    Http.Open('POST', 'https://api.verifacti.com/verifactu/create', False);
    Http.Option[9] := $800; // TLS 1.2 en Windows 7 y 8
    Http.SetRequestHeader('Authorization', 'Bearer ' + GetEnvironmentVariable('VERIFACTI_API_KEY'));
    Http.SetRequestHeader('Content-Type', 'application/json; charset=utf-8');
    Http.Send(Factura);

    WriteLn(Integer(Http.Status), ' ', string(Http.ResponseText));
  finally
    CoUninitialize;
  end;
end;

2. Create the invoice

Create the invoice with POST /verifactu/create. This is a full invoice (F1) with one line at 21%. fecha_expedicion is today's date as DD-MM-YYYY: the test environment only accepts today's (or yesterday's).

Amounts go as text, with a decimal point and at most two decimals. importe_total must match the sum of base_imponible and cuota_repercutida of the lines. nif and nombre are the recipient's: the issuing NIF comes from the API key.

Create the invoice
uses
  System.SysUtils, System.IOUtils, System.JSON, VerifactiApi;

procedure CrearFactura;
var
  Factura: string;
  R: TVerifactiRespuesta;
begin
  Factura :=
    '{"serie": "A", "numero": "1", "fecha_expedicion": "' + Hoy + '",' +
    ' "tipo_factura": "F1", "descripcion": "Servicios de consultoria",' +
    ' "nif": "A15022510", "nombre": "Empresa Cliente SL",' +
    ' "lineas": [{"base_imponible": "200.00", "tipo_impositivo": "21", "cuota_repercutida": "42.00"}],' +
    ' "importe_total": "242.00"}';

  R := VerifactiSend('POST', '/verifactu/create', Factura);
  try
    if R.Status <> 200 then
    begin
      WriteLn('Error ', R.Status, ': ', R.Json.ToString);
      Exit;
    end;
    WriteLn('uuid: ', TJSONObject(R.Json).GetValue('uuid').Value);
    WriteLn('estado: ', TJSONObject(R.Json).GetValue('estado').Value);
    TFile.WriteAllText('respuesta.json', R.Json.ToString);
  finally
    R.Json.Free;
  end;
end;

For other invoice types (simplified F2, corrective R1–R5, exempt…), see the Verifactu invoice examples.

3. Read the response and the QR

The response arrives straight away, without waiting for the AEAT:

  • uuid: identifier of the invoicing record. Store it to check the status.
  • estado: always Pendiente on creation. Verifacti queues the record and sends it to the Spanish Tax Agency (AEAT), usually within one or two minutes.
  • url: AEAT verification URL encoded in the QR.
  • qr: PNG image of the QR (290 × 290 px) in Base64.
  • huella: hash of the record, already chained to the previous one.
Response · 200
{
  "estado": "Pendiente",
  "uuid": "b018ced3-b362-4494-8776-9eefff1c160c",
  "url": "https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=B12345674&numserie=A1&fecha=19-11-2026&importe=242.00",
  "qr": "iVBORw0KGgoAAAANSUhEUgAAASIAAAEi...",
  "huella": "B11F3A015173AD99075E2720F61E2DE1FF08CBFEDD85C6F73C77AD835301B2A3"
}
Save the QR
uses
  System.SysUtils, System.IOUtils, System.JSON, System.NetEncoding;

procedure GuardarQR;
var
  Respuesta: TJSONObject;
begin
  Respuesta := TJSONObject.ParseJSONValue(TFile.ReadAllText('respuesta.json')) as TJSONObject;
  try
    TFile.WriteAllBytes('qr.png', TNetEncoding.Base64.DecodeStringToBytes(Respuesta.GetValue('qr').Value));
    WriteLn('QR guardado en qr.png. URL de verificación: ', Respuesta.GetValue('url').Value);
  finally
    Respuesta.Free;
  end;
end;

QR size, position and legend on the invoice, in Verifactu QR.

4. Place the QR on the PDF invoice

To place the QR on a PDF from Delphi you can use SynPDF (from mORMot). This example draws the PNG you saved in the previous step on the PDF canvas, at about 35 × 35 mm.

SynPDF
uses
  System.Types, Vcl.Imaging.pngimage, SynPdf;

procedure QREnPDF;
var
  Doc: TPdfDocumentGDI;
  Qr: TPngImage;
begin
  Doc := TPdfDocumentGDI.Create;
  Qr := TPngImage.Create;
  try
    Doc.DefaultPaperSize := psA4;
    Doc.ScreenLogPixels := 72; // coordenadas del lienzo en puntos
    Doc.AddPage;
    Qr.LoadFromFile('qr.png');
    Qr.RemoveTransparency;
    // 72 puntos por pulgada: 35 mm son unos 99 puntos
    Doc.VCLCanvas.StretchDraw(Rect(28, 40, 127, 139), Qr);
    Doc.SaveToFile('factura.pdf');
  finally
    Qr.Free;
    Doc.Free;
  end;
end;

With the API you don't need to generate the QR: it comes in the response. If you still want to generate it from the url, you can use DelphiZXingQRCode or ZXing.Delphi.

5. Check the status

Check the record status with GET /verifactu/status?uuid=…. Do it after a minute or, better, get the result by webhook (step 8). Never in a loop without a wait.

The possible states are Pendiente, Correcto, Aceptado con errores, Incorrecto, Duplicado, Anulado, Factura inexistente, No registrado and Error servidor AEAT. With Aceptado con errores or Incorrecto, the response carries the AEAT's codigo_error and mensaje_error: what to do in each case, in Verifactu errors.

Check the status
uses
  System.SysUtils, System.IOUtils, System.JSON, System.NetEncoding, VerifactiApi;

procedure ConsultarEstado;
var
  Guardada: TJSONObject;
  R: TVerifactiRespuesta;
  Estado: string;
begin
  Guardada := TJSONObject.ParseJSONValue(TFile.ReadAllText('respuesta.json')) as TJSONObject;
  try
    R := VerifactiSend('GET', '/verifactu/status?uuid=' + TNetEncoding.URL.Encode(Guardada.GetValue('uuid').Value));
  finally
    Guardada.Free;
  end;
  try
    Estado := TJSONObject(R.Json).GetValue('estado').Value;
    WriteLn('estado: ', Estado);
    if (Estado = 'Incorrecto') or (Estado = 'Aceptado con errores') then
      WriteLn('AEAT ', TJSONObject(R.Json).GetValue('codigo_error').Value, ': ',
        TJSONObject(R.Json).GetValue('mensaje_error').Value);
  finally
    R.Json.Free;
  end;
end;
Response · 200
{
  "nif": "B12345674",
  "serie": "A",
  "numero": "1",
  "fecha_expedicion": "19-11-2026",
  "operacion": "Alta",
  "estado": "Correcto",
  "url": "https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=B12345674&numserie=A1&fecha=19-11-2026&importe=242.00",
  "qr": "iVBORw0KGgoAAAANSUhEUgAAASIAAAEi...",
  "codigo_error": null,
  "mensaje_error": null,
  "estado_registro_duplicado": null
}

6. Corrective invoices and cancellations

  • Corrective invoice: a new invoice with tipo_factura R1 to R5, created with the same POST /verifactu/create. See corrective invoice.
  • Cancellation: POST /verifactu/cancel, only for invoices that should never have been issued. See cancellation.
  • Correction: PUT /verifactu/modify, to fix data of a record already sent. See correction.
Cancel
uses
  System.SysUtils, System.JSON, VerifactiApi;

procedure AnularFactura;
var
  R: TVerifactiRespuesta;
begin
  R := VerifactiSend('POST', '/verifactu/cancel',
    '{"serie": "A", "numero": "1", "fecha_expedicion": "' + Hoy + '"}');
  try
    WriteLn(R.Status, ' ', R.Json.ToString);
  finally
    R.Json.Free;
  end;
end;

The cancellation answers with its own uuid, estado Pendiente and huella.

7. Retries without duplicates

Send the optional Idempotency-Key header on /create, /create_bulk, /modify and /cancel. Generate a UUID per invoice and reuse it on the retries of that same invoice:

  • Same body and same key: the API returns the first response, with the Idempotent-Replayed: true header, and creates no new record.
  • 409: the first request is still in progress. Wait a few seconds and repeat.
  • 422: you used the key with a different body. Use a new key.
  • A 400 is stored too: if you fix the data, use a new key. 5xx responses are not stored, and the retry is processed again.
  • The key is remembered for 24 hours and is tied to the issuing NIF. If more than 24 hours have passed without a response, check with POST /verifactu/status (serie, numero and fecha_expedicion) whether the invoice was registered before sending it again.
Retries
uses
  System.SysUtils, System.Net.HttpClient, VerifactiApi;

function CrearConReintentos(const Factura, Clave: string): TVerifactiRespuesta;
var
  Intento: Integer;
begin
  for Intento := 1 to 5 do
  begin
    try
      Result := VerifactiSend('POST', '/verifactu/create', Factura, Clave);
      if (Result.Status <> 409) and (Result.Status < 500) then
        Exit;
      Result.Json.Free;
    except
      on ENetHTTPClientException do ; // sin respuesta: se reintenta con la misma clave
    end;
    if Intento < 5 then
      Sleep(1000 shl Intento);
  end;
  raise Exception.Create('Sin respuesta tras 5 intentos: reintenta más tarde con la misma clave');
end;

procedure CrearFacturaSinDuplicar;
var
  G: TGUID;
  Clave: string;
  R: TVerifactiRespuesta;
begin
  CreateGUID(G);
  Clave := Copy(GUIDToString(G), 2, 36); // sin llaves
  R := CrearConReintentos(
    '{"serie": "A", "numero": "2", "fecha_expedicion": "' + Hoy + '",' +
    ' "tipo_factura": "F1", "descripcion": "Servicios de consultoria",' +
    ' "nif": "A15022510", "nombre": "Empresa Cliente SL",' +
    ' "lineas": [{"base_imponible": "100.00", "tipo_impositivo": "21", "cuota_repercutida": "21.00"}],' +
    ' "importe_total": "121.00"}', Clave);
  try
    WriteLn(R.Status, ' ', R.Json.ToString);
  finally
    R.Json.Free;
  end;
end;

8. Webhooks

Instead of checking the status, get the result by webhook. Webhooks are created with the NIF management API and linked to one or more NIFs. That API uses the account API key (it starts with vfn_, in the VERIFACTI_NIFS_API_KEY variable), available with an active subscription. With the free account you can create one webhook from the dashboard.

cURL · create the webhook
# Sustituye B12345674 por el NIF de prueba de tu cuenta
curl -X POST https://api.verifacti.com/webhooks \
  -H "Authorization: Bearer $VERIFACTI_NIFS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://tu-dominio.com/webhook", "entorno": "test", "secret": "'"$VERIFACTI_WEBHOOK_SECRET"'", "nifs": ["B12345674"]}'

Receive the notification

Each notification is a POST with a JSON array of records, with the same fields as GET /verifactu/status plus the uuid (and without the QR). If you set a secret, the X-Webhook-Signature header carries the hex HMAC-SHA256 of the body: compute it over the body as received, before parsing it. X-Webhook-Id is the same on every retry of a notification: use it to avoid processing it twice. Answer 2xx within 10 seconds. The receiver is the OnCommandGet event of a TIdHTTPServer (Indy); THashSHA2.GetHMAC needs Delphi 10 Seattle or later.

TIdHTTPServer · OnCommandGet
// Delphi 10 Seattle o superior (System.Hash) con Indy (TIdHTTPServer)
uses
  System.SysUtils, System.Classes, System.IOUtils, System.Hash, System.JSON, IdGlobal, IdContext, IdCustomHTTPServer;

// Compara en tiempo constante (no se corta en el primer carácter distinto)
function FirmaValida(const A, B: string): Boolean;
var
  I, Diff: Integer;
begin
  Result := Length(A) = Length(B);
  if not Result then Exit;
  Diff := 0;
  for I := 1 to Length(A) do
    Diff := Diff or (Ord(LowerCase(A)[I]) xor Ord(LowerCase(B)[I]));
  Result := Diff = 0;
end;

procedure TFormServidor.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
  Cuerpo, Esperada, Firma: string;
  Lista: TJSONArray;
  I: Integer;
begin
  Cuerpo := '';
  if Assigned(ARequestInfo.PostStream) then
  begin
    ARequestInfo.PostStream.Position := 0;
    Cuerpo := ReadStringFromStream(ARequestInfo.PostStream, -1, IndyTextEncoding_UTF8);
  end;
  Esperada := THashSHA2.GetHMAC(Cuerpo, GetEnvironmentVariable('VERIFACTI_WEBHOOK_SECRET'));
  Firma := ARequestInfo.RawHeaders.Values['X-Webhook-Signature'];
  if not FirmaValida(Esperada, Firma) then
  begin
    AResponseInfo.ResponseNo := 401;
    Exit;
  end;

  Lista := TJSONObject.ParseJSONValue(Cuerpo) as TJSONArray;
  try
    for I := 0 to Lista.Count - 1 do
      TFile.AppendAllText('webhooks.log',
        ARequestInfo.RawHeaders.Values['X-Webhook-Id'] + ' ' +
        TJSONObject(Lista.Items[I]).GetValue('serie').Value +
        TJSONObject(Lista.Items[I]).GetValue('numero').Value + ': ' +
        TJSONObject(Lista.Items[I]).GetValue('estado').Value + sLineBreak);
  finally
    Lista.Free;
  end;
  AResponseInfo.ResponseNo := 200;
end;

Full example in a single file

A console program that creates the invoice with Idempotency-Key, saves the QR as PNG and checks the status. Run it with the VERIFACTI_API_KEY environment variable. It uses the date and time as the invoice number so you can run it several times.

Completo.dpr
// Verifactu en Delphi con la API de Verifacti: crea una factura, guarda el QR y consulta el estado.
// Delphi XE8 o superior. Ejecuta con la variable de entorno VERIFACTI_API_KEY=vf_test_...
program Completo;

{$APPTYPE CONSOLE}

uses
  System.SysUtils, System.Classes, System.IOUtils, System.JSON, System.NetEncoding,
  System.Net.HttpClient, System.Net.URLClient;

const
  BASE_URL = 'https://api.verifacti.com';

function Send(const Method, Path: string; const Body: string; const Clave: string;
  out Status: Integer): TJSONObject;
var
  Http: THTTPClient;
  Headers: TNetHeaders;
  Source: TStringStream;
  Response: IHTTPResponse;
begin
  Http := THTTPClient.Create;
  Source := TStringStream.Create(Body, TEncoding.UTF8);
  try
    Headers := [TNetHeader.Create('Authorization', 'Bearer ' + GetEnvironmentVariable('VERIFACTI_API_KEY'))];
    if Body <> '' then
      Headers := Headers + [TNetHeader.Create('Content-Type', 'application/json')];
    if Clave <> '' then
      Headers := Headers + [TNetHeader.Create('Idempotency-Key', Clave)];
    if Method = 'GET' then
      Response := Http.Get(BASE_URL + Path, nil, Headers)
    else
      Response := Http.Post(BASE_URL + Path, Source, nil, Headers);
    Status := Response.StatusCode;
    Result := TJSONObject.ParseJSONValue(Response.ContentAsString(TEncoding.UTF8)) as TJSONObject;
  finally
    Source.Free;
    Http.Free;
  end;
end;

var
  Numero, Factura, Clave, Uuid, Estado: string;
  Alta, Registro: TJSONObject;
  Status, Intento, Consulta: Integer;
  G: TGUID;
begin
  Numero := FormatDateTime('yyyymmddhhnnss', Now);
  Factura :=
    '{"serie": "A", "numero": "' + Numero + '", "fecha_expedicion": "' + FormatDateTime('dd-mm-yyyy', Now) + '",' +
    ' "tipo_factura": "F1", "descripcion": "Servicios de consultoria",' +
    ' "nif": "A15022510", "nombre": "Empresa Cliente SL",' +
    ' "lineas": [{"base_imponible": "200.00", "tipo_impositivo": "21", "cuota_repercutida": "42.00"}],' +
    ' "importe_total": "242.00"}';

  // 1. Crear la factura. La misma Idempotency-Key en cada reintento: nunca se duplica.
  CreateGUID(G);
  Clave := Copy(GUIDToString(G), 2, 36);
  Alta := nil;
  Status := 0;
  for Intento := 1 to 5 do
  begin
    try
      FreeAndNil(Alta);
      Alta := Send('POST', '/verifactu/create', Factura, Clave, Status);
      if (Status <> 409) and (Status < 500) then
        Break;
    except
      on ENetHTTPClientException do ;
    end;
    if Intento < 5 then
      Sleep(1000 shl Intento);
  end;
  if Status <> 200 then
  begin
    if Assigned(Alta) then
      WriteLn('Error ', Status, ': ', Alta.ToString)
    else
      WriteLn('Sin respuesta');
    Halt(1);
  end;
  Uuid := Alta.GetValue('uuid').Value;
  WriteLn('Factura A', Numero, ' creada. uuid: ', Uuid);

  // 2. Guardar el QR para la factura impresa o en PDF.
  TFile.WriteAllBytes('qr.png', TNetEncoding.Base64.DecodeStringToBytes(Alta.GetValue('qr').Value));
  WriteLn('QR guardado en qr.png');
  Alta.Free;

  // 3. Consultar el estado. El envío a la AEAT suele tardar uno o dos minutos.
  Registro := nil;
  for Consulta := 1 to 6 do
  begin
    Sleep(30000);
    FreeAndNil(Registro);
    Registro := Send('GET', '/verifactu/status?uuid=' + Uuid, '', '', Status);
    if (Status = 200) and (Registro.GetValue('estado').Value <> 'Pendiente') then
      Break;
  end;
  if (Status <> 200) or not Assigned(Registro) then
  begin
    WriteLn('Sin respuesta del estado: ', Status);
    Halt(1);
  end;
  Estado := Registro.GetValue('estado').Value;
  WriteLn('Estado: ', Estado);
  if (Estado = 'Incorrecto') or (Estado = 'Aceptado con errores') then
    WriteLn('AEAT ', Registro.GetValue('codigo_error').Value, ': ', Registro.GetValue('mensaje_error').Value);
  Registro.Free;
end.

Common errors

Common errors when sending invoices with the Verifactu API
CodeCauseFix
401Missing or invalid API keyCheck the Authorization header and that the key belongs to the NIF.
403NIF deactivatedActivate it in the dashboard or with the NIF management API.
400 vf-verifactu-fecha_expedicion_hoyfecha_expedicion is not today's date (test environment)Send today's date as DD-MM-YYYY, Spanish time.
400 vf-verifactu-importe_total_cuadreimporte_total does not match the sum of the linesRecalculate base, tax and surcharge of every line.
400 vf-verifactu-factura_duplicadaAn invoice with the same serie, numero and fecha_expedicion already existsCheck your numbering.
409Another request with the same Idempotency-Key is still in progressWait a few seconds and repeat with the same key.
422Idempotency-Key reused with a different bodyUse a new key for the corrected request.

Every code and state, in Verifactu errors.

Your own library or an API?

To comply with Verifactu you can integrate directly with the AEAT: generate the XML (Verifactu XML structure), compute the hash and chaining, send with a certificate and follow the flow control. Or use a REST API like Verifacti's, which takes JSON and needs no certificate.

What changes between generating the XML yourself and using the Verifactu API
What you have to solveGenerate and send the XML yourselfWith the Verifactu API
FormatBuild the XML against the AEAT XSD schemasYou send JSON
Hash and chainingCompute the SHA-256 hash of every record and keep the previous one per NIFVerifacti does it; the hash comes back in the response
CertificateAuthenticated call with an electronic certificate, yours or your customer’sNo certificate: Verifacti sends as a colaborador social with each NIF’s representation form
SendingFollow the AEAT flow control (by default one submission per minute unless you collect 1,000 records) and manage queues and retriesImmediate response; Verifacti queues and sends
QRGenerate the verification URL and the QRIncluded in the response (PNG in Base64)
Record keepingStore records and responsesQuery, list and export the XML through the API

Next step

Read the Verifactu API documentation, copy the invoice examples or follow the quick start guide to move to production. See pricing.

Test environment and test NIF included

What those who have integrated it say

Koibox
«La integración con Verifactu fue muy sencilla y el soporte ha sido excelente. Siempre atentos y rápidos para resolver dudas. Muy contento con el servicio.»
Antonio TapiasCTO & Co-Founder, Koibox
Boxify
«Hemos integrado nuestro software en tiempo récord. La documentación es clara y sencilla, y los ejemplos variados y muy útiles. El equipo de soporte me ha ayudado con todas las dudas.»
Kike IsasiFounder, Boxify
Xolo
“Verifacti’s SaaS platform is intuitive and reliable, and their team’s deep expertise and prompt, crystal-clear answers helped us reach our goals on time. They’re not only highly knowledgeable and professional but also a genuine pleasure to work with.”
Sebastien RequiemCTO, Xolo
Mekavo
“Verifacti made Veri*factu compliance surprisingly straightforward. Their API is clean, well-documented, and their support team responds with real solutions — not generic replies. For any SaaS serving Spanish businesses, Verifacti is the partner you want.”
Mehrdad MadadiFounder & Lead Developer, Mekavo

Questions about Verifactu in Delphi

Is there an official Verifactu library for Delphi?

No. The AEAT publishes web services and XSD schemas, not libraries. There are third-party projects that generate and sign the XML. With the Verifactu API an HTTP client is enough: you send JSON and get the QR back.

Do I need a digital certificate to send invoices to Verifactu from Delphi?

Not with the Verifactu API. Verifacti sends the records to the AEAT as a colaborador social, with the representation form each NIF signs.

How do I get the invoice QR?

It comes in the POST /verifactu/create response, in the qr field: a PNG image in Base64. Decode it and place it on the invoice; you don't need to generate it.

Can I test without tax effects?

Yes. The free account includes a test NIF connected to the AEAT test environment: all the code in this tutorial works with its API key (vf_test_…).

How do I retry a submission without duplicating the invoice?

With the Idempotency-Key header: generate a UUID per invoice and repeat it on every retry. If the first request got through, the API returns the same response and creates no new record.

Try the code with the free account

It gives you the test API key the whole tutorial works with.

Test environment and test NIF includedRead the documentation