Saltar al contenido principal

Enviar tu primera factura

Pre-paso: Valida el RNC del comprador

Antes de emitir, confirma que el RNC/Cédula del comprador existe y está activo en DGII:

curl -s https://api.erply.pro/v1/dgii/document/131000002 \
-H "x-api-key: $ERPLYPRO_API_KEY" | jq .status
# → "ACTIVO"

Ver la guía completa de consulta RNC.

cURL

curl -X POST https://api.erply.pro/v1/invoices \
-H "Authorization: Bearer $ERPLYPRO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d @invoice.json

invoice.json (cuerpo canónico — ver tests/fixtures/quickstart_invoice_request.json en el repositorio):

{
"type": "31",
"encf": "E310000000001",
"client_request_id": "req-2026-05-01-001",
"company": { "rnc": "131000001", "name": "ERPly Pro Demo S.R.L." },
"customer": { "rnc": "131000002", "name": "Cliente Demo S.R.L." },
"lines": [
{
"line_number": 1,
"description": "Servicio de consultoria",
"quantity": "1",
"unit_price": "5000.00",
"subtotal": "5000.00"
}
],
"totals": { "subtotal": "5000.00", "tax": "900.00", "grand_total": "5900.00" }
}
Identidad de tenant

tenantId no va en el cuerpo. Se deriva de las claims tenant_id / environment del JWT en Authorization. Esto evita que un cliente pueda emitir facturas para otro tenant aunque obtenga su clave por error.

Python

import os, uuid, requests

payload = {
"type": "31",
"encf": "E310000000001",
"client_request_id": "req-2026-05-01-001",
"company": {"rnc": "131000001", "name": "ERPly Pro Demo S.R.L."},
"customer": {"rnc": "131000002", "name": "Cliente Demo S.R.L."},
"lines": [
{
"line_number": 1,
"description": "Servicio de consultoria",
"quantity": "1",
"unit_price": "5000.00",
"subtotal": "5000.00",
}
],
"totals": {"subtotal": "5000.00", "tax": "900.00", "grand_total": "5900.00"},
}

resp = requests.post(
"https://api.erply.pro/v1/invoices",
headers={
"Authorization": f"Bearer {os.environ['ERPLYPRO_API_KEY']}",
"Content-Type": "application/json",
"Idempotency-Key": str(uuid.uuid4()),
},
json=payload,
timeout=10,
)
print(resp.status_code, resp.json())

Respuesta esperada

{
"docId": "01HW9X4G…",
"trackId": "20260501-DGII-9988",
"status": "pending",
"_links": {
"self": "/v1/invoices/01HW9X4G…",
"status": "/v1/invoices/01HW9X4G…/status"
}
}

Polling vs webhook

  • Polling: GET /v1/invoices/{docId}/status cada 30 s hasta que status sea accepted o rejected.
  • Webhook (recomendado): ERPly Pro te llama tan pronto DGII responde. Verifica la firma HMAC X-ErplyPro-Signature (ventana ±300 s).

¿Recibiste un error? Salta al paso 4.