Documentación API
Empieza a usar la API en 5 minutos. JSON REST, sin XML, sin SOAP.
AdSense placeholder
Añade NEXT_PUBLIC_ADSENSE_CLIENT en .env
¿Qué ofrece esta API?
Envía JSON, recibe factura verificada con QR y hash SHA-256.
Cada factura tiene su PDF profesional descargable.
60 req/min, 1000/día por API key. Sin abuso.
Cada 30 días desde tu primer uso. Sin tarjeta.
Node.js, Python y PHP. Copia y pega.
Generamos el XML FacturaE y el código QR verificable.
Quickstart
Copia, pega y envía tu primera factura en 5 minutos.
1Consigue tu API Key
Regístrate en el dashboard y obtén tu API key gratis. Formato: vf_live_XXX...
2Instala el SDK
📦 Node.js
npm install @verifactu/node🐍 Python
pip install verifactu🐘 PHP
composer require verifactu/sdk3Envía tu primera factura
Node.js
import { VeriFactu } from '@verifactu/node';
const client = new VeriFactu('vf_live_xxx');
const factura = await client.invoices.create({
emitter: {
nif: 'B12345678',
name: 'Tu Empresa SL'
},
receiver: {
nif: '12345678A',
name: 'Cliente Ejemplo'
},
lines: [{
description: 'Desarrollo web',
amount: 1000,
vat: 21
}]
});
console.log(factura.id);
// "d4f8c3a2-..."
console.log(factura.qrCode);
// URL del QR verificablecURL
curl -X POST \
https://verifactu-api-nine.vercel.app/api/v1/invoices \
-H "Authorization: Bearer vf_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"emitter": {
"nif": "B12345678",
"name": "Tu Empresa SL"
},
"receiver": {
"nif": "12345678A",
"name": "Cliente Ejemplo"
},
"lines": [{
"description": "Desarrollo web",
"amount": 1000,
"vat": 21
}]
}'Respuesta: { "id": "uuid", "total": 1210, "vat": 210, "status": "created" }
Referencia de Endpoints
Base URL: https://verifactu-api-nine.vercel.app/api
| Método | Endpoint | Descripción | Auth |
|---|---|---|---|
| GET | /v1/health | Estado del servicio | — |
| POST | /v1/invoices | Crear factura | API Key |
| GET | /v1/invoices | Listar facturas (limit/offset) | API Key |
| GET | /v1/invoices/:id | Obtener factura por ID | API Key |
| POST | /v1/invoices/:id | Cancelar factura (action: cancel) | API Key |
| GET | /v1/invoices/:id/pdf | Descargar factura en PDF | API Key |
| GET | /v1/invoices/export | Exportar facturas a CSV | API Key |
| POST | /v1/invoices/export | Importar facturas desde CSV/JSON | API Key |
| GET | /v1/products | Listar productos | API Key |
| POST | /v1/products | Crear producto | API Key |
| GET | /v1/customers | Listar clientes (search opcional) | API Key |
| POST | /v1/customers | Crear cliente | API Key |
| GET | /v1/webhooks | Listar webhooks | API Key |
| POST | /v1/webhooks | Crear webhook | API Key |
| DELETE | /v1/webhooks | Eliminar webhook | API Key |
| GET | /v1/subscription | Ver plan actual | API Key |
| GET | /v1/usage | Ver uso de rate limit | API Key |
| GET | /v1/keys | Listar API keys | JWT |
| POST | /v1/keys | Crear nueva API key | JWT |
| GET | /v1/user/stats | Estadísticas del usuario | JWT |
| POST | /auth/register | Registrar usuario | — |
| POST | /auth/login | Iniciar sesión | — |
Autenticación
API Key (para facturas)
Incluye tu API key en el header Authorization:
Authorization: Bearer vf_live_3a7b9c2d1e4f...Formato: vf_live_ + 32 caracteres hexadecimales
JWT (para dashboard)
Para gestionar API keys y ver estadísticas, usa el token JWT del login:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...Expira en 7 días. Se obtiene al hacer login o register.
Rate Limiting
60
peticiones / minuto
1.000
peticiones / día
100
facturas / mes
Si excedes el rate limit, recibirás HTTP 429 con el header Retry-After. Los headers X-RateLimit-* te indican cuántas peticiones te quedan.
Los SDKs reintentan automáticamente con exponential backoff. No necesitas gestionarlo manualmente.
Límite de Facturas (Plan Gratuito)
100 facturas gratis cada 30 días
El ciclo de 30 días empieza con tu primera factura, no al registrarte. Las facturas no usadas no se acumulan para el siguiente ciclo.
- • Al alcanzar las 100 facturas, la API devuelve error
403 - • En el dashboard ves cuántas te quedan y la fecha exacta de renovación
- • No hay permanencia ni tarjeta de crédito
Códigos de Estado HTTP
200OK - Petición exitosa
201Created - Recurso creado (factura, producto...)
400Bad Request - Faltan campos obligatorios
401Unauthorized - API key inválida o ausente
403Forbidden - Límite de facturas alcanzado
404Not Found - La factura no existe o no es tuya
429Rate Limit - Demasiadas peticiones
500Internal Server Error - Error del servidor
AdSense placeholder
Añade NEXT_PUBLIC_ADSENSE_CLIENT en .env