Webhooks
Webhooks
Sublaunch envía una solicitud HTTPS a tu servidor en cuanto un miembro se une, cancela o se va, se completa un pago, un lead deja su email, se publica un post o un comentario, o se une un afiliado. Va firmada, para que sepas que viene de nosotros.
Configura un endpoint
Añade un endpoint en la app, en la página API del Sublaunch, o con Crear un endpoint de webhook. Dale una URL HTTPS pública y los tipos de evento que quieras, y guarda el secret que devuelve para verificar las firmas.
- Solo HTTPS, en el puerto 443 u 8443, sin credenciales en la URL y sin direcciones privadas, loopback ni link local.
- Hasta 10 endpoints por Sublaunch.
filters.tier_idslimita los eventos de miembros y de pagos que recibe un endpoint a los miembros de ciertos niveles. Un evento sin nivel, como un lead o un post, siempre se envía.- Envía un evento de prueba para comprobar tu servidor antes de que lleguen los eventos reales.
Los webhooks vienen con los planes Business y Premium. Si el propietario del Sublaunch pasa a un plan inferior, sus endpoints se conservan pero no envían nada hasta que vuelva a Business o Premium.
curl -X POST https://api.sublaunch.com/v1/webhook_endpoints \
-H "Authorization: Bearer $SUBLAUNCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/sublaunch",
"events": ["member.joined", "payment.succeeded"],
"description": "CRM sync",
"filters": {
"tier_ids": ["tier1"]
}
}'Tipos de evento
Todos los eventos comparten la misma estructura. Su data depende de su type.
| Tipo | Se envía cuando |
|---|---|
member.joined | Se activa una membresía, de pago o gratuita, de un miembro nuevo. Se envía una sola vez por membresía. |
member.left | Una membresía activa termina, con su status ahora en canceled. Se envía una sola vez por membresía. |
subscription.canceled | Un miembro pide cancelar. Su membresía sigue activa hasta cancel_at. |
payment.succeeded | El pago de un miembro se completa. Se envía una sola vez por pago. |
lead.created | Un lead magnet gratuito o un formulario del Sublaunch recoge un email nuevo. |
post.published | Se publica un post en la Comunidad del Sublaunch, de su creador o de un miembro. |
comment.created | Alguien comenta un post de la Comunidad o responde a un comentario. |
affiliate.joined | Alguien se une al programa de afiliados del Sublaunch. |
El objeto event
- idstringIdentificador único del evento,
evt_seguido de 24 caracteres. También en el encabezadoSublaunch-Event-Id. - objectstringSiempre
event. - typestringEl tipo de evento.
member.joinedmember.leftsubscription.canceledpayment.succeededlead.createdpost.publishedcomment.createdaffiliate.joined - created_atstringCuándo ocurrió el evento, en ISO 8601.
- sublaunch_idstringEl Sublaunch en el que ocurrió.
- dataobjectEl contenido del evento, empezando por su
object. Un evento de prueba llevatestentrue.
member.joined
Se activa una membresía, de pago o gratuita, de un miembro nuevo. Se envía una sola vez por membresía.
Datos
- objectobjectEl miembro, tal como lo devuelve Obtener un miembro.
{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "member.joined",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "Ms8kL2QpXz",
"object": "member",
"email": "sam@example.com",
"name": "Sam Carter",
"first_name": "Sam",
"last_name": "Carter",
"user_id": "Us4kP9xQ2M",
"status": "active",
"type": "recurring",
"tier": {
"id": "tier1",
"name": "Inner Circle"
},
"price": {
"id": "pR8sK2xLmQ",
"amount": 29,
"currency": "usd",
"interval": "month"
},
"payments_count": 3,
"joined_at": "2026-09-02T18:41:07.000Z",
"cancel_at": null,
"canceled_at": null,
"affiliate_id": null
}
}
}member.left
Una membresía activa termina, con su status ahora en canceled. Se envía una sola vez por membresía.
Datos
- objectobjectEl miembro, con
canceled_at.
{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "member.left",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "Ms8kL2QpXz",
"object": "member",
"email": "sam@example.com",
"name": "Sam Carter",
"first_name": "Sam",
"last_name": "Carter",
"user_id": "Us4kP9xQ2M",
"status": "canceled",
"type": "recurring",
"tier": {
"id": "tier1",
"name": "Inner Circle"
},
"price": {
"id": "pR8sK2xLmQ",
"amount": 29,
"currency": "usd",
"interval": "month"
},
"payments_count": 3,
"joined_at": "2026-09-02T18:41:07.000Z",
"cancel_at": null,
"canceled_at": "2026-11-17T09:30:00.000Z",
"affiliate_id": null
}
}
}subscription.canceled
Un miembro pide cancelar. Su membresía sigue activa hasta cancel_at.
Datos
- objectobjectEl miembro, con
cancel_at. - reasonstring o nullPor qué canceló, si lo indicó.
{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "subscription.canceled",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "Ms8kL2QpXz",
"object": "member",
"email": "sam@example.com",
"name": "Sam Carter",
"first_name": "Sam",
"last_name": "Carter",
"user_id": "Us4kP9xQ2M",
"status": "active",
"type": "recurring",
"tier": {
"id": "tier1",
"name": "Inner Circle"
},
"price": {
"id": "pR8sK2xLmQ",
"amount": 29,
"currency": "usd",
"interval": "month"
},
"payments_count": 3,
"joined_at": "2026-09-02T18:41:07.000Z",
"cancel_at": "2026-12-02T18:41:07.000Z",
"canceled_at": null,
"affiliate_id": null
},
"reason": "Too expensive"
}
}payment.succeeded
El pago de un miembro se completa. Se envía una sola vez por pago.
Datos
- objectobjectEl pago, con tu parte en
amount_creator.
{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "payment.succeeded",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "In7pQ2xKLm",
"object": "payment",
"amount": 29,
"currency": "usd",
"amount_creator": 26.1,
"status": "paid",
"type": "subscription",
"member_id": "Ms8kL2QpXz",
"email": "sam@example.com",
"tier_id": "tier1",
"affiliate_id": null,
"paid_at": "2026-11-02T18:41:09.000Z"
}
}
}lead.created
Un lead magnet gratuito o un formulario del Sublaunch recoge un email nuevo.
Datos
- objectobjectEl lead.
{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "lead.created",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "Ld3xQ8mKpR",
"object": "lead",
"email": "alex@example.com",
"first_name": "Alex",
"last_name": null,
"phone": null,
"source": "lead_magnet",
"lead_magnet_id": "lm2K9x",
"fields": [
{
"name": "Experience",
"value": "Two years"
}
],
"created_at": "2026-11-16T08:11:05.000Z"
}
}
}post.published
Se publica un post en la Comunidad del Sublaunch, de su creador o de un miembro.
Datos
- objectobjectEl post, tal como lo devuelve Obtener un post.
{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "post.published",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "Pt9xK3mQ2L",
"object": "post",
"title": "Weekly outlook",
"text": "Three levels I watch this week on the S&P.\n\nCharts below, questions welcome.",
"category_id": "x7Lp2QaZ",
"access": "members",
"price": null,
"pinned": true,
"comments_off": false,
"author_id": null,
"by_creator": true,
"media": [
{
"kind": "image",
"url": "https://example.com/weekly-chart.png"
}
],
"attachments": [],
"poll": null,
"likes": 48,
"comments_count": 12,
"status": "published",
"url": "https://sublaunch.com/alphadesk/community/weekly-outlook",
"published_at": "2026-11-15T17:02:40.000Z",
"updated_at": "2026-11-16T08:11:05.000Z"
}
}
}comment.created
Alguien comenta un post de la Comunidad o responde a un comentario.
Datos
- objectobjectEl comentario.
{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "comment.created",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "Cm2kX8pQ7R",
"object": "comment",
"post_id": "Pt9xK3mQ2L",
"parent_id": null,
"text": "Thanks, the 4 hour chart helps a lot.",
"author_id": "Us4kP9xQ2M",
"likes": 3,
"status": "published",
"created_at": "2026-11-15T18:20:13.000Z"
}
}
}{
"id": "evt_8kQ2vXr4LmT9wPz1Hc6YbN3d",
"object": "event",
"type": "affiliate.joined",
"created_at": "2026-11-17T09:30:00.000Z",
"sublaunch_id": "q7RkX2LmPv",
"data": {
"object": {
"id": "Af6tR2kQxM",
"object": "affiliate",
"user_id": "Us7mQ2kX9P",
"code": "482913",
"commission_rate": 30,
"status": "active",
"members_active": 0,
"members_total": 0,
"joined_at": "2026-11-17T09:30:00.000Z"
}
}
}Envío
Sublaunch envía cada evento como un POST en JSON y espera tu respuesta durante 10 segundos. Cualquier 2xx cuenta como entregado. Una redirección, cualquier otro estado, un timeout o un error de conexión cuentan como fallo, y el evento se reintenta.
| Encabezado | Valor |
|---|---|
Sublaunch-Signature | El timestamp y la firma, t=1763371800,v1=5f2b... |
Sublaunch-Event-Id | El id del evento, para ignorar los eventos que ya procesaste. |
Sublaunch-Event-Type | El type del evento. |
User-Agent | Sublaunch-Webhooks/1.0 |
POST /webhooks/sublaunch HTTP/1.1
Content-Type: application/json; charset=utf-8
User-Agent: Sublaunch-Webhooks/1.0
Sublaunch-Event-Id: evt_8kQ2vXr4LmT9wPz1Hc6YbN3d
Sublaunch-Event-Type: member.joined
Sublaunch-Signature: t=1763371800,v1=58ca5e964b92d617c979d3f067cdc2035a1a1a9d3f848d7d927c2db09b8e9baaVerificar firmas
Cualquiera puede enviar una solicitud a tu URL. Comprueba que cada una viene de Sublaunch antes de fiarte de ella.
- Lee el cuerpo en bruto como bytes, antes de parsear el JSON. Parsearlo y volver a serializarlo cambia los bytes.
- Separa el encabezado
Sublaunch-Signaturepor las comas.tes un timestamp Unix en segundos, yv1, la firma. - Calcula el HMAC SHA256 de
t, un punto y el cuerpo en bruto, con el secreto completo del endpoint como clave,whsec_incluido, y exprésalo en hexadecimal. - Compáralo con cada
v1en tiempo constante. - Rechaza un
tque se aleje más de 5 minutos de tu reloj, para que nadie pueda reenviar una solicitud antigua. Cada reintento se firma con untnuevo.
Responde 400 si la verificación falla. Guarda el secreto en una variable de entorno como SUBLAUNCH_WEBHOOK_SECRET.
const crypto = require("crypto");
const express = require("express");
// rawBody: the request body exactly as received, before any JSON parsing.
function verifySublaunchSignature(rawBody, header, secret, toleranceSeconds = 300) {
if (typeof header !== "string") return false;
let timestamp = null;
const signatures = [];
for (const part of header.split(",")) {
const [key, value] = part.split("=", 2).map((s) => (s || "").trim());
if (key === "t") timestamp = value;
if (key === "v1" && value) signatures.push(value);
}
if (!/^\d+$/.test(timestamp || "") || signatures.length === 0) return false;
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > toleranceSeconds) return false;
const expected = crypto.createHmac("sha256", secret).update(`${timestamp}.`).update(rawBody).digest();
return signatures.some((signature) => {
const given = Buffer.from(signature, "hex");
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
}
const app = express();
// The body must stay raw on this route.
app.post("/webhooks/sublaunch", express.raw({ type: "application/json" }), (req, res) => {
const ok = verifySublaunchSignature(
req.body,
req.get("Sublaunch-Signature"),
process.env.SUBLAUNCH_WEBHOOK_SECRET,
);
if (!ok) return res.status(400).send("Invalid signature");
const event = JSON.parse(req.body.toString("utf8"));
// Already handled? Skip it, retries send the same event.id again.
if (event.type === "member.joined") {
// event.data.object is the new member
} else if (event.type === "payment.succeeded") {
// event.data.object is the payment
} else if (event.type === "subscription.canceled") {
// event.data.object is the member, event.data.reason why they canceled
}
res.sendStatus(200);
});
app.listen(3000);Reintentos
Cuando un envío falla, Sublaunch lo reintenta 7 veces, cada vez tras una espera más larga. Después del 8.º intento, unas 45 horas después del primero, el envío se marca como fallido.
| Intento | Se envía |
|---|---|
| 1 | Al instante |
| 2 | 1 minuto después del fallo anterior |
| 3 | 5 minutos después del fallo anterior |
| 4 | 30 minutos después del fallo anterior |
| 5 | 2 horas después del fallo anterior |
| 6 | 6 horas después del fallo anterior |
| 7 | 12 horas después del fallo anterior |
| 8 | 24 horas después del fallo anterior |
Un endpoint que falla 3 días seguidos, con al menos 8 intentos fallidos, se desactiva. Su status pasa a disabled, su disabled_reason a failing, y los envíos pendientes terminan como fallidos. Arregla tu servidor y vuelve a activarlo en la app o con Actualizar un endpoint de webhook. El recuento vuelve a empezar con el primer envío que acepte tu servidor. Los eventos de prueba se envían una sola vez y nunca entran en el recuento.
Listar envíos muestra el código de estado y el error de cada intento, para ver qué respondió tu servidor.
Buenas prácticas
- Responde 2xx en menos de 10 segundos y haz el trabajo después, en una cola.
- Cada evento se entrega al menos una vez. Usa el
iddel evento, también enSublaunch-Event-Id, para ignorar un evento que ya procesaste. - Los eventos pueden llegar desordenados. Compara
created_at, o vuelve a pedir el miembro para tener su último estado. - Verifica todas las firmas y rechaza los timestamps antiguos.
- Renovar el secreto lo reemplaza al instante. Despliega el nuevo justo después, los envíos que fallen mientras tanto se reintentan firmados con él.
- Los eventos y los envíos se guardan 30 días.