Ir al contenido
Octuvia

Webhooks

Registra una URL HTTPS, elige eventos y verifica la firma. Octuvia entrega cada evento firmado; si tu endpoint falla, reintenta y puedes reconciliar con GET /events.

Los webhooks son del workspace (no de un número concreto). Filtras por events, y opcionalmente por platforms, profile_ids o account_ids.

Endpoints

EndpointUso
Listar endpointsGET /webhook-endpoints
Crear endpointPOST — guarda el signing_secret
Actualizar endpointPATCH — url, events, status…
Eliminar endpointDELETE — cancela entregas pendientes
Rotar secretoPOST …/rotate-secret — doble firma 24 h
Probar endpointPOST …/test — envía webhook.test
Listar eventosGET /events — reconciliación
Entregas de un eventoGET /events/{id}/deliveries
Reintentar entregaPOST /webhook-deliveries/{id}/retry

Firma

HeaderQué es
X-Octuvia-Event-IdId del evento (evt_…). Deduplica con este valor.
X-Octuvia-Delivery-IdId de la entrega (whd_…).
X-Octuvia-Attempt1 = primer intento; hasta 5 (1 min, 5 min, 30 min, 2 h).
X-Octuvia-TimestampEpoch en segundos. Rechaza si |now − ts| > 5 min.
X-Octuvia-Signaturev1=hex(HMAC_SHA256(secret, "<ts>." + raw_body)). En rotación: v1=nuevo,v1=anterior.
Verificar firma (Node.js)javascript
const crypto = require("crypto");

function verifyWebhook(rawBody, headers, signingSecret) {
  const ts = headers["x-octuvia-timestamp"];
  const sigHeader = headers["x-octuvia-signature"] || "";
  if (!ts || !sigHeader) return false;
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;

  const expected =
    "v1=" +
    crypto.createHmac("sha256", signingSecret).update(`${ts}.${rawBody}`).digest("hex");

  return sigHeader.split(",").some((part) => {
    try {
      return crypto.timingSafeEqual(Buffer.from(part.trim()), Buffer.from(expected));
    } catch {
      return false;
    }
  });
}

Responde 2xx rápido

Octuvia espera HTTP 2xx. Si fallas: reintentos a 1 min, 5 min, 30 min y 2 h; luego dead. Tras varios días sin éxito el endpoint puede pasar a disabled_by_failures (reactívalo con PATCH).

Envelope de cada evento

Todas las entregas usan el mismo envelope. Cambia type y data. data.object es el recurso (mismo shape que su GET); en cambios también puede venir data.previous_attributes. request es tu petición (req_…) o null si lo originó WhatsApp/el sistema.

Forma del envelopejson
{
  "object": "event",
  "id": "evt_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "type": "<event.type>",
  "api_version": "v1",
  "created_at": "2026-12-03T22:33:00.000Z",
  "livemode": true,
  "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "platform": "whatsapp",
  "data": {
    "object": {
      "object": "<message|account|template|…>",
      "id": "…"
    },
    "previous_attributes": {
      "status": "PENDING"
    }
  },
  "request": null
}

Catálogo de eventos

Puedes suscribirte a tipos exactos, familias (message.*, account.*, whatsapp.*) o *. Debajo de cada familia: el JSON completo que llega a tu URL.

Mensajes

EventoCuándo
message.receivedEntrante (texto, media, interactivo, etc.)
message.sentSaliente aceptado por WhatsApp (source: api | native_app | …)
message.deliveredEntregado al contacto
message.readLeído por el contacto
message.failedFalló el envío/entrega (data.object.error)
message.revokedBorrado para todos (coexistencia)
message.editedTexto editado (coexistencia)
message.reactionReacción added | removed
POST a tu URL — message.receivedjson
{
  "object": "event",
  "id": "evt_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "type": "message.received",
  "api_version": "v1",
  "created_at": "2026-12-03T22:33:00.000Z",
  "livemode": true,
  "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "platform": "whatsapp",
  "data": {
    "object": {
      "object": "message",
      "id": "msg_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "conversation_id": "conv_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "platform": "whatsapp",
      "platform_message_id": "wamid.HBgLNTE5ODc2NTQzMjEVAgARGBIAAA",
      "direction": "inbound",
      "source": null,
      "from": "+51987654321",
      "to": "+15556433682",
      "contact": {
        "id": "+51987654321",
        "name": "Ana Pérez",
        "whatsapp": {
          "wa_id": "51987654321"
        }
      },
      "type": "text",
      "content": {
        "text": {
          "body": "Hola"
        }
      },
      "reply_to": null,
      "status": "delivered",
      "error": null,
      "metadata": {},
      "request_id": null,
      "created_at": "2026-12-03T22:33:00.000Z",
      "sent_at": null,
      "delivered_at": "2026-12-03T22:33:00.000Z",
      "read_at": null,
      "failed_at": null
    }
  },
  "request": null
}

Conversaciones y conversiones

EventoCuándo
conversation.createdPrimer mensaje con un contacto en un número
conversation.attribution_addedClic en anuncio Click-to-WhatsApp
conversion.sentMeta aceptó la conversión
conversion.failedMeta rechazó la conversión
POST a tu URL — conversation.createdjson
{
  "object": "event",
  "id": "evt_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "type": "conversation.created",
  "api_version": "v1",
  "created_at": "2026-12-03T22:33:00.000Z",
  "livemode": true,
  "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "platform": "whatsapp",
  "data": {
    "object": {
      "object": "conversation",
      "id": "conv_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "platform": "whatsapp",
      "contact": {
        "id": "+51987654321",
        "name": "Ana Pérez",
        "whatsapp": {
          "wa_id": "51987654321"
        }
      },
      "status": "open",
      "unread_count": 1,
      "last_message_at": "2026-12-03T22:33:00.000Z",
      "last_inbound_at": "2026-12-03T22:33:00.000Z",
      "window_expires_at": "2026-12-04T22:33:00.000Z",
      "free_window_expires_at": null,
      "first_attribution": null,
      "last_attribution": null,
      "attributions_count": 0,
      "metadata": {},
      "created_at": "2026-12-03T22:33:00.000Z",
      "updated_at": "2026-12-03T22:33:00.000Z"
    }
  },
  "request": null
}

Cuentas

EventoCuándo
account.connectedNúmero conectado (connect link o BYO)
account.updatedCambió calidad, tier, throughput o nombre verificado
account.reauthorization_requiredToken/webhooks revocados; hay que reconectar
account.disconnectedNúmero desconectado
POST a tu URL — account.connectedjson
{
  "object": "event",
  "id": "evt_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "type": "account.connected",
  "api_version": "v1",
  "created_at": "2026-12-03T22:33:00.000Z",
  "livemode": true,
  "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "platform": "whatsapp",
  "data": {
    "object": {
      "object": "account",
      "id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "platform": "whatsapp",
      "status": "connected",
      "connection_method": "connect_link",
      "name": "Clínica Sonrisa — Ventas",
      "reference": "clinica-ventas",
      "capabilities": {
        "templates": true,
        "reactions": true,
        "typing_indicator": true,
        "read_receipts": true,
        "calling": false,
        "conversions": true
      },
      "whatsapp": {
        "phone_number": "+15556433682",
        "verified_name": "Clínica Sonrisa",
        "waba_id": "102938475610293",
        "phone_number_id": "109876543210987",
        "quality_rating": "GREEN",
        "messaging_limit_tier": "TIER_1K",
        "throughput": "STANDARD",
        "coexistence": false
      },
      "metadata": {},
      "connected_at": "2026-11-01T10:00:00.000Z",
      "created_at": "2026-11-01T10:00:00.000Z",
      "updated_at": "2026-12-03T22:33:00.000Z"
    }
  },
  "request": null
}

WhatsApp (avisos finos)

EventoCuándo
whatsapp.template.status_changedPlantilla APPROVED / REJECTED / PAUSED / …
whatsapp.template.status_updatedAlias de status_changed
whatsapp.template.category_updatedMeta reclasificó la categoría
whatsapp.call_permission.updatedPermiso de llamada granted | revoked
whatsapp.account.quality_updatedCalidad GREEN / YELLOW / RED
whatsapp.account.name_status_updatedNombre verificado o decisión de review
whatsapp.account.status_updatedTier, throughput o restricción
whatsapp.account.alert_receivedAlerta Meta (account_alerts / violaciones)
whatsapp.contact.identity_changedEl contacto cambió de número/identidad
whatsapp.number.activatedNúmero activado o nombre aprobado
whatsapp.number.declinedNombre o revisión rechazada
whatsapp.number.action_requiredMeta exige una acción
whatsapp.number.verification_requiredVerificación de negocio pendiente
whatsapp.number.suspendedNúmero/cuenta restringida
whatsapp.number.reactivatedReactivado tras review
whatsapp.number.releasedNúmero liberado o eliminado del WABA
whatsapp.number.kyc_submittedKYC / review enviado
whatsapp.automatic_eventEvento Meta no clasificado (incluye meta_event)

account.updated sigue emitiéndose cuando cambia calidad/nombre/tier. Los whatsapp.account.* y whatsapp.number.* son el desglose fino (paridad tipo Zernio).

POST a tu URL — whatsapp.template.status_changedjson
{
  "object": "event",
  "id": "evt_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "type": "whatsapp.template.status_changed",
  "api_version": "v1",
  "created_at": "2026-12-03T22:33:00.000Z",
  "livemode": true,
  "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "platform": "whatsapp",
  "data": {
    "object": {
      "object": "template",
      "id": "tpl_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
      "platform_template_id": "123456789012345",
      "name": "pedido_enviado",
      "language": "es",
      "category": "UTILITY",
      "status": "APPROVED",
      "rejection_reason": null,
      "quality_score": "GREEN",
      "components": [
        {
          "type": "BODY",
          "text": "Hola {{1}}, tu pedido {{2}} ya salió."
        }
      ],
      "created_at": "2026-11-20T12:00:00.000Z",
      "updated_at": "2026-12-03T22:33:00.000Z"
    },
    "previous_attributes": {
      "status": "PENDING"
    }
  },
  "request": null
}

Prueba

EventoCuándo
webhook.testPOST /webhook-endpoints/{id}/test
POST a tu URL — webhook.testjson
{
  "object": "event",
  "id": "evt_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "type": "webhook.test",
  "api_version": "v1",
  "created_at": "2026-12-03T22:33:00.000Z",
  "livemode": true,
  "profile_id": "prf_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "account_id": "acc_01J8Z3K4M5N6P7Q8R9S0T1U2V3",
  "platform": "whatsapp",
  "data": {
    "object": {
      "object": "webhook_test",
      "webhook_endpoint_id": "whe_01J8Z3K4M5N6P7Q8R9S0T1U2V3"
    }
  },
  "request": null
}