Webhooks

Webhooks to your app: receive signed events

How to register a webhook endpoint in OpenSequence, verify the Standard Webhooks signature with or without the SDK, dedupe by event id and handle retries.

Edit on GitHub

Webhooks tell your backend what happened: sent, replied, exited, task created. Register one HTTPS endpoint, then verify every delivery.

What it gives you

  • Signed events for every enrollment, step, task and inbound reply or opt-out.
  • Retries with backoff, ordering per enrollment, and replay of anything that failed.

What you need

  • A public HTTPS URL on your backend that reads the raw request body.
  • An OpenSequence admin key.

Steps

Register the endpoint

curl
curl -X POST $SEQ/v1/webhooks -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://app.example.com/hooks/opensequence","event_types":["*"]}'
# {"success":true,"data":{"endpoint":{"id":"wep_…",…},"secret":"whsec_…"}}

The secret is shown once. Store it encrypted. event_types is a list of event names, or ["*"] (the default).

Verify each delivery

With the SDK
import express from 'express';
import { verifyWebhook, WebhookVerificationError } from '@opensequence/sdk';

app.post('/hooks/opensequence', express.raw({ type: 'application/json' }), async (req, res) => {
  try {
    const event = verifyWebhook({ secret: process.env.OSEQ_WEBHOOK_SECRET!, headers: req.headers, body: req.body });
    if (await alreadyHandled(event.id)) return res.sendStatus(200); // dedupe by event id
    await handle(event);
    res.sendStatus(200);
  } catch (err) {
    if (err instanceof WebhookVerificationError) return res.status(401).send(err.code);
    res.sendStatus(500); // OpenSequence retries
  }
});

Use the raw body: a parsed and re-serialized body will not verify. Answer any 2xx within 10 seconds.

The events

EventWhen
enrollment.createdA contact was enrolled.
enrollment.exitedIt left early, with exit_reason.
enrollment.completedIt reached the end.
enrollment.paused, enrollment.resumedIt was paused or resumed, with pause_reason.
run.doneA step ran, such as an email sent.
run.skipped, run.failed, run.needs_reviewA step did not run, with a reason.
task.created, task.expiredA task appeared, or closed without the rep.
signal.receivedA reply, bounce, opt-out, out-of-office, booked meeting or connected call arrived.
sender.channel_statusA mailbox or number changed status, for example credentials_needed.
endpoint.disabledAn endpoint was disabled after three days of failures.

Every payload field: Webhook events.

Check it works

Enroll a test contact, then read GET /v1/webhooks/{id}/deliveries (oseq.webhooks.deliveries(id)). Each delivery shows its status, attempts and your last response code.

Retries and duplicates

A non-2xx, a timeout or a connection error is retried: nine attempts over about a day and a half. Deliveries for one enrollment arrive in order. A delivery can arrive twice, so dedupe by event.id. Replay one with POST /v1/webhooks/deliveries/{id}/replay, or everything that failed since a time with POST /v1/webhooks/{id}/recover. Details: Retries and recovery.

Common errors

ErrorFix
422 UNSAFE_URLThe URL must be https, carry no credentials and resolve to a public address.
WebhookVerificationError NO_MATCHING_SIGNATUREYou verified a parsed body, or used an old secret. Verify the raw bytes with the current secret.
TIMESTAMP_OUT_OF_TOLERANCEYour server's clock is off by more than five minutes.
Endpoint status: "disabled"It failed for three days. Fix it, then POST /v1/webhooks/{id}/enable replays what was held.

On this page