Ejemplos de Código
Peticiones y respuestas listas para copiar
Todos los ejemplos usan el entorno de pruebas y son una representación
simplificada para que tu integración sea rápida.
Factura simplificada (F2) — Solo total
El caso más simple: envías solo el importe total. La API calcula base e IVA automáticamente.
Request
Response
cURL
json
POST /v1/verifactu/create
Authorization: Bearer TU_API_KEY
{
"id_transaccion": "AX123Z",
"certificado_base64": "MIIKog...",
"password_certificado": "tu_password",
"operacion": "alta_factura",
"desglose": [
{ "total": 100.00 }
]
}
json
{
"emisor": { "nombre": "MI EMPRESA S.L.", "nif": "B12345678" },
"entorno": "pruebas",
"operacion": "alta_factura",
"id_transaccion": "AX123Z",
"factura": {
"tipo": "F2", "serie": "S", "numero": 1,
"fecha": "05-03-2026", "hora": "19:30",
"importe_impuestos": 17.36,
"importe_total": 100.00,
"descripcion": "VENTA DE BAZAR",
"estado": "Grabada",
"huella": "6E3D2B4B6528...",
"qr":
"https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=B12345678&numserie=1-S&fecha=05-03-2026&importe=100.00",
"milisegundos": 45
},
"desglose": [
{ "base": 82.64, "tipo_iva": 21, "cuota_iva": 17.36, "suma_total": 100.00 }
]
}
bash
curl -X POST https://www.verifactusi.com/v1/verifactu/create \
-H "Authorization: Bearer TU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id_transaccion":"AX123Z","operacion":"alta_factura","desglose":[{"total":100}]}'
Factura con múltiples tipos de IVA
Puedes mezclar tipos de IVA (21%, 10%, 4%) en una misma factura. La API calcula cada línea por separado.
Request
Response
json
{
"id_transaccion": "P26T6",
"certificado_base64": "MIIKog...",
"password_certificado": "tu_password",
"operacion": "alta_factura",
"desglose": [
{ "total": 215.40 },
{ "total": 127.56, "tipo_iva": 10 },
{ "total": 345.78, "tipo_iva": 4 }
]
}
json
"desglose": [
{ "base": 178.02, "tipo_iva": 21, "cuota_iva": 37.38, "suma_total": 215.40 },
{ "base": 115.96, "tipo_iva": 10, "cuota_iva": 11.60, "suma_total": 342.96 },
{ "base": 332.48, "tipo_iva": 4, "cuota_iva": 13.30, "suma_total": 688.74 }
]
Factura con destinatario y recargo de equivalencia
Para facturas con cliente identificado (B2B) y regímenes especiales.
Request
Response
json
{
"id_transaccion": "XXF546",
"certificado_base64": "MIIKog...",
"password_certificado": "tu_password",
"operacion": "alta_factura",
"destinatario": {
"nif": "12345678X",
"nombre": "JUAN DOMINGUEZ LOPEZ"
},
"factura": {
"tipo": "F2", "serie": "X",
"descripcion": "VENTA DIVERSA",
"fecha_operacion": "13-01-2025"
},
"desglose": [
{ "tipo_iva": 10, "base": 114.12, "cuota_iva": 11.41 },
{
"regimen": "01", "calificacion": "S1",
"tipo_iva": 21, "base": 200.17, "cuota_iva": 42.04,
"tipo_re": 5.20, "cuota_re": 7.89
}
]
}
json
{
"destinatario": { "nombre": "JUAN DOMINGUEZ LOPEZ", "nif": "12345678X" },
"desglose": [
{ "base": 114.12, "tipo_iva": 10, "cuota_iva": 11.41, "suma_total": 125.53 },
{ "base": 200.17, "tipo_iva": 21, "cuota_iva": 42.04,
"tipo_re": 5.2, "cuota_re": 7.89, "suma_total": 375.63 }
]
}
Formato alternativo (campos planos)
Si tu software ya genera los desgloses, puedes enviar base_imponible,
tipo_impositivo y cuota_repercutida directamente.
json
{
"serie": "B",
"numero": "1",
"certificado_base64": "MIIKog...",
"password_certificado": "tu_password",
"fecha_expedicion": "05-03-2026",
"tipo_factura": "F1",
"descripcion": "Prestación de servicios",
"nif": "A15022510",
"nombre": "Empresa ejemplo SL",
"lineas": [
{ "base_imponible": "200", "tipo_impositivo": "21", "cuota_repercutida": "42" },
{ "base_imponible": "100", "tipo_impositivo": "10", "cuota_repercutida": "10" }
],
"importe_total": "352.00"
}
Anular una factura
json
POST /v1/verifactu/cancel
{ "serie": "S", "numero": "1", "fecha_expedicion": "05-03-2026", "certificado_base64": "MII...",
"password_certificado": "..." }
Consultar estado de una factura
json
POST /v1/verifactu/status
{ "serie": "S", "numero": "1", "fecha_expedicion": "05-03-2026" }
Listar facturas
json
POST /v1/verifactu/list
{
"ejercicio": "2026",
"periodo": "03",
"rango_fecha_expedicion": {
"desde": "01-03-2026",
"hasta": "31-03-2026"
}
}