Webhooks
Un webhook es una URL de tu sistema a la que Conectate Cloud envía un POST cada vez que pasa algo
importante, por ejemplo cuando la DGII acepta o rechaza un comprobante. Así no tienes que
consultar GET /v1/documents/{id} una y otra vez.
Los endpoints se crean en el panel, en Desarrolladores › Webhooks. Al crear uno verás su secreto de firma una sola vez: guárdalo en tu gestor de secretos.
Eventos
Sección titulada «Eventos»| Evento | Cuándo se envía |
|---|---|
document.created |
Conectate Cloud recibió el comprobante y le asignó un e-NCF. |
document.accepted |
La DGII aceptó el comprobante. |
document.rejected |
La DGII rechazó el comprobante. |
certificate.expiring |
El certificado de una empresa vence en 30, 15 o 7 días. |
webhook.test |
Lo envías tú desde el panel con Enviar prueba. |
Formato
Sección titulada «Formato»POST /webhooks/ploceus HTTP/1.1Content-Type: application/jsonUser-Agent: Conectate-Webhooks/1.0X-Conectate-Event: document.acceptedX-Conectate-Delivery: 7b0c4f8e-2a0e-4d0a-9a51-3f7f0c1b2d55X-Conectate-Signature: t=1731500000,v1=5f2b…c9a1
{ "id": "7b0c4f8e-2a0e-4d0a-9a51-3f7f0c1b2d55", "type": "document.accepted", "created_at": "2026-11-13T13:58:05-04:00", "data": { "id": 1042, "company_id": 1, "type": "31", "encf": "E310000000148", "status": "accepted", "internal_id": "PED-48213", "customer_rnc": "131234567", "customer_name": "Constructora Ejemplo SRL", "total": "29500.00", "currency": "DOP", "dgii_tracking_id": "a3f9c2e1-…", "dgii_messages": [], "issued_at": "2026-11-13T13:58:02-04:00", "signed_at": "2026-11-13T13:58:03-04:00", "sent_at": "2026-11-13T13:58:03-04:00", "accepted_at": "2026-11-13T13:58:05-04:00" }}data tiene la misma forma que la respuesta de GET /v1/documents/{id}. En
document.rejected, dgii_messages trae el motivo del rechazo.
certificate.expiring trae los datos del certificado:
{ "id": "0d9e…", "type": "certificate.expiring", "created_at": "2026-11-14T07:00:00-04:00", "data": { "certificate_id": 7, "company_id": 1, "company_rnc": "131234567", "valid_to": "2026-12-14T23:59:59-04:00", "days_until_expiry": 30 }}Verificar la firma
Sección titulada «Verificar la firma»X-Conectate-Signature tiene dos partes: t (fecha en segundos Unix) y v1, el HMAC-SHA256 en
hexadecimal de {t}.{cuerpo} usando tu secreto. Usa el cuerpo tal como llegó, antes de
convertirlo a JSON.
- Calcula el HMAC y compáralo con
v1en tiempo constante. - Rechaza la petición si
ttiene más de 5 minutos, para evitar que alguien la reenvíe.
import crypto from 'node:crypto';
function verify(rawBody, header, secret) { const parts = Object.fromEntries(header.split(',').map((p) => p.split('='))); if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false; const expected = crypto.createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex'); const given = Buffer.from(parts.v1 ?? ''); return given.length === expected.length && crypto.timingSafeEqual(Buffer.from(expected), given);}function verify(string $rawBody, string $header, string $secret): bool{ parse_str(str_replace(',', '&', $header), $parts); if (abs(time() - (int) ($parts['t'] ?? 0)) > 300) { return false; } $expected = hash_hmac('sha256', $parts['t'].'.'.$rawBody, $secret);
return hash_equals($expected, $parts['v1'] ?? '');}
// Laravel: verify($request->getContent(), $request->header('X-Conectate-Signature'), $secret)import hashlibimport hmacimport time
def verify(raw_body: bytes, header: str, secret: str) -> bool: parts = dict(p.split("=", 1) for p in header.split(",")) if abs(time.time() - int(parts.get("t", 0))) > 300: return False signed = parts["t"].encode() + b"." + raw_body expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, parts.get("v1", ""))
# Flask: verify(request.get_data(), request.headers["X-Conectate-Signature"], secret)using System.Security.Cryptography;using System.Text;
static bool Verify(string rawBody, string header, string secret){ var parts = header.Split(',').Select(p => p.Split('=', 2)).ToDictionary(p => p[0], p => p[1]); if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - long.Parse(parts["t"])) > 300) return false;
using var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret)); var expected = Convert.ToHexString(hmac.ComputeHash(Encoding.UTF8.GetBytes($"{parts["t"]}.{rawBody}"))).ToLowerInvariant();
return CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(expected), Encoding.UTF8.GetBytes(parts.GetValueOrDefault("v1", "")));}Responder y reintentos
Sección titulada «Responder y reintentos»- Responde con cualquier código 2xx en menos de 10 segundos. Si necesitas hacer trabajo pesado, guarda el evento y procésalo después.
- Las redirecciones (3xx) no se siguen y cuentan como fallo.
- Si falla, reintentamos a los 1, 5, 30, 120, 720 y 1440 minutos (unas 24 horas en total).
- Un mismo evento puede llegar más de una vez. Usa
X-Conectate-Delivery(igual en todos los reintentos) para ignorar duplicados. - Si tres eventos seguidos agotan todos sus reintentos, desactivamos el endpoint y lo verás marcado en el panel. Corrige tu URL, envía una prueba y vuelve a activarlo.
En el panel, Webhooks › Entregas muestra cada envío con la petición, la respuesta de tu sistema y un botón para reenviarlo.
Requisitos de la URL
Sección titulada «Requisitos de la URL»- Debe usar
https://. - Debe resolver a una dirección pública. No aceptamos redes privadas,
localhostni direcciones de metadatos de la nube.