Webhooks
Qué es
Lotus puede llamar a su servidor (HTTPS) cuando cambian datos sincronizados: productos, contactos o ventas. Usted registra la URL en Integraciones → Partner API → Webhooks.
Esto es independiente de la Partner API Bearer (ltk_live_…): la key sirve para que usted llame a Lotus; el webhook es para que Lotus llame a usted.
Configuración
- En Lotus: Integraciones → Partner API.
- Sección Webhooks: URL
https://…, opcionalmente un secreto compartido, y Habilitado. - Probar envía un evento
webhook.test. - Su endpoint debe responder 2xx en pocos segundos.
Entrega
| Header | Valor |
|---|---|
Content-Type | application/json |
User-Agent | Lotus-Webhooks/1.0 |
X-Lotus-Event | tipo del evento (p. ej. sale.updated) |
X-Lotus-Delivery | id del evento (evt_…) |
X-Lotus-Signature | solo si configuró secreto: sha256=<hmac_hex_del_body> |
Firma (si hay secreto): HMAC-SHA256 del body crudo con el secreto; prefijo sha256=.
Reintentos: cola con backoff (varios intentos). Use id / X-Lotus-Delivery para idempotencia.
Eventos MVP
| Tipo | Cuándo |
|---|---|
product.updated | Upsert/patch/deactivate Partner o pull ERP de productos |
contact.updated | Upsert Partner o pull de clientes ERP |
sale.updated | Upsert Partner o pull de facturas / anulación (VOID) |
webhook.test | Botón Probar en Integraciones |
Ejemplo de payload
{
"id": "evt_01hxyz…",
"type": "sale.updated",
"createdAt": "2026-10-21T22:00:00.000Z",
"accountNumber": 1001,
"data": {
"saleId": "uuid",
"contactId": "uuid",
"externalId": "fv-900",
"status": "POSTED",
"provider": "ERP_SIIGO",
"created": false
}
}
El campo data varía por tipo; siempre incluye identificadores útiles (externalId, ids Lotus, provider).
Verificación HMAC (Node)
import { createHmac, timingSafeEqual } from "node:crypto";
function verify(secret, rawBody, header) {
const expected = "sha256=" + createHmac("sha256", secret).update(rawBody).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(header || "");
return a.length === b.length && timingSafeEqual(a, b);
}
Más eventos y filtros por suscripción se irán añadiendo; el contrato de envoltorio (id, type, createdAt, accountNumber, data) se mantiene estable.