Docs / Server

WebhooksAvailable

Receive campaign and device events on your server, signed.

Events

EventWhen
notification.startedA campaign started going out
notification.completedIt finished, with the totals
notification.canceledIt was canceled
notification.deletedIt was deleted (numbers already counted stay)
subscriptions.invalidatedDevices stopped receiving (up to 1,000 ids per event)

Verify the signature

Each delivery carries X-VivaPush-Signature: t=<timestamp>,v1=<HMAC-SHA256 of 't.body' with your secret>. Reject invalid signatures or ones older than 5 minutes.

Node.js
import crypto from 'node:crypto';

export function verify(secret, body, header) {
  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}.${body}`).digest('hex');
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}

Deliveries and retries

Answer 2xx within 10 seconds. 5xx, 408, 429, timeouts and network errors are retried after 30 s, 2 min, 10 min, 30 min, 1 h, 3 h, 6 h and 12 h. Other 4xx end the delivery.

Delivery is at least once: use the X-VivaPush-Delivery header to ignore repeats.