Founding churches get 50% off for 12 monthsFounding churches: 50% offApply as a founding churchApply

Webhooks

A webhook is a signed HTTPS request that Lectern sends to your server when something finishes. Use webhooks instead of polling: one event replaces dozens of requests.

Before you start

  • A key with webhooks:manage.
  • A public HTTPS address that can receive a POST.

Create an endpoint#

POST/webhookswebhooks:manage

Give the endpoint a name, a public https address on port 443, and the events you want. A church can have up to 20 endpoints. Localhost, private networks, and names that resolve to them are refused with 422 webhook_url_not_allowed.

curl -X POST "$LECTERN_BASE_URL/v1/api/o/$LECTERN_SLUG/webhooks" \
  -H "Authorization: Bearer $LECTERN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "Website sync",
    "url": "https://example.org/hooks/lectern",
    "events": ["teaching.ready", "teaching.failed", "note.approved"]
  }'

The response includes secret, a value starting with whsec_. It is shown once, when the endpoint is created or its secret is rotated. Store it before you do anything else.

{
  "status": true,
  "message": "ok",
  "data": {
    "id": "whk_01m4h8mp75fw3vegabgcc7ad7k",
    "name": "Website sync",
    "url": "https://example.org/hooks/lectern",
    "events": [
      "teaching.ready",
      "teaching.failed",
      "note.approved",
      "ask.answered",
      "scripture.detected"
    ],
    "status": "active",
    "created_at": "2026-10-09T21:20:54Z",
    "updated_at": "2026-10-09T21:20:54Z",
    "secret": "whsec_...",
    "consecutive_failures": 0,
    "deliveries": []
  },
  "meta": {
    "request_id": "req_01m4h8nry7eq2bfwf822ry0vwm"
  }
}
Treat the secret like a password

Anyone who has it can forge events to your server. Keep it in a secrets manager, never in the repository, and rotate it if it may have leaked. Retrying the create request with the same Idempotency-Key does not return the secret again: the response has secret_shown_once: true.

Events#

EventSent whendata
teaching.readyA teaching has a transcript and can be searched.teaching
teaching.failedA teaching could not be prepared.teaching, with teaching.error
note.approvedA person on the team approved a note.note and teaching
ask.answeredA question asked through the API has an answer.conversation_id, message_id, kind, question, short_answer, answer
scripture.detectedScripture citations were found in an approved note.teaching, note_id, citations
pingYou called the test route. You cannot subscribe to it.message

The event envelope#

Every event has the same outer shape. id identifies the event and stays the same on every retry and replay.

FieldMeaning
idThe event id, evt_....
typeThe event name.
api_versionv1.
created_atWhen the event was created, UTC.
orgThe church: id and slug.
dataThe payload for this event type.

Payload examples#

teaching.ready
{
  "id": "evt_01m4h8mq26ebwtb83nc7wnrhah",
  "type": "teaching.ready",
  "api_version": "v1",
  "created_at": "2026-10-09T21:20:55Z",
  "org": {
    "id": "org_01m4h7y09deqsvf1tayjt3sedf",
    "slug": "grace-community-church"
  },
  "data": {
    "teaching": {
      "id": "tch_01m4h7zbsve4ybxjarahd3fpkh",
      "title": "Forgiveness that frees",
      "status": "done",
      "duration_s": 242,
      "language": "en",
      "branch": {
        "id": "brn_01m4h7y09deqtamqgs56j3gmb5",
        "name": "Grace Community Church",
        "slug": "hq"
      }
    }
  }
}
teaching.failed
{
  "id": "evt_01m4h8mq26ebwtb83nc7wnrhah",
  "type": "teaching.failed",
  "api_version": "v1",
  "created_at": "2026-10-09T21:20:55Z",
  "org": {
    "id": "org_01m4h7y09deqsvf1tayjt3sedf",
    "slug": "grace-community-church"
  },
  "data": {
    "teaching": {
      "id": "tch_01m4h7zbsve4ybxjarahd3fpkh",
      "title": "Forgiveness that frees",
      "status": "failed",
      "duration_s": 242,
      "language": "en",
      "branch": {
        "id": "brn_01m4h7y09deqtamqgs56j3gmb5",
        "name": "Grace Community Church",
        "slug": "hq"
      },
      "error": "The video could not be processed."
    }
  }
}
note.approved
{
  "id": "evt_01m4h8mq26ebwtb83nc7wnrhah",
  "type": "note.approved",
  "api_version": "v1",
  "created_at": "2026-10-09T21:13:20Z",
  "org": {
    "id": "org_01m4h7y09deqsvf1tayjt3sedf",
    "slug": "grace-community-church"
  },
  "data": {
    "note": {
      "id": "nte_01m4h83v9rejdvxnkpsh0wjxzk",
      "title": "Forgiveness that frees",
      "kind": "study_note",
      "version": 2
    },
    "teaching": {
      "id": "tch_01m4h7zbsve4ybxjarahd3fpkh",
      "title": "Forgiveness that frees",
      "status": "done",
      "duration_s": 242,
      "language": "en",
      "branch": {
        "id": "brn_01m4h7y09deqtamqgs56j3gmb5",
        "name": "Grace Community Church",
        "slug": "hq"
      }
    }
  }
}
scripture.detected
{
  "id": "evt_01m4h8mq26ebwtb83nc7wnrhah",
  "type": "scripture.detected",
  "api_version": "v1",
  "created_at": "2026-10-09T21:13:20Z",
  "org": {
    "id": "org_01m4h7y09deqsvf1tayjt3sedf",
    "slug": "grace-community-church"
  },
  "data": {
    "teaching": {
      "id": "tch_01m4h7zbsve4ybxjarahd3fpkh",
      "title": "Forgiveness that frees",
      "status": "done",
      "duration_s": 242,
      "language": "en",
      "branch": {
        "id": "brn_01m4h7y09deqtamqgs56j3gmb5",
        "name": "Grace Community Church",
        "slug": "hq"
      }
    },
    "note_id": "nte_01m4h83v9rejdvxnkpsh0wjxzk",
    "citations": [
      {
        "reference": "Matthew 18:21-22",
        "point": "Jesus answers Peter with seventy times seven, which removes the counting from forgiveness."
      },
      {
        "reference": "Colossians 3:13",
        "point": "We forgive because the Lord has first forgiven us."
      }
    ]
  }
}
ask.answered
{
  "id": "evt_01m4h8mq26ebwtb83nc7wnrhah",
  "type": "ask.answered",
  "api_version": "v1",
  "created_at": "2026-10-09T21:13:42Z",
  "org": {
    "id": "org_01m4h7y09deqsvf1tayjt3sedf",
    "slug": "grace-community-church"
  },
  "data": {
    "conversation_id": "cnv_01m4h87fpyerrr62f654bpj1dc",
    "message_id": "msg_01m4h87fqjf0h8g1xqg16mvsh9",
    "kind": "answer",
    "question": "What did the pastor teach about forgiveness?",
    "short_answer": "The church teaches that forgiveness is a decision not to collect a debt, grounded in the fact that God in Christ has already forgiven us.",
    "answer": "## Forgiveness in this church's teaching\n\nIn Forgiveness that frees, the pastor starts with Peter's question about how often to forgive and Jesus' answer of seventy times seven, which takes the counting away.\n\n> Then came Peter to him, and said, Lord, how oft shall my brother sin against me, and I forgive him? till seven times? Jesus saith unto him, I say not unto thee, Until seven times: but, Until seventy times seven.\n\nIn short: Forgiveness is not pretending it did not hurt. It is deciding that the debt will not be collected, because we have first been forgiven."
  }
}
ping
{
  "id": "evt_01m4h8mq26ebwtb83nc7wnrhah",
  "type": "ping",
  "api_version": "v1",
  "created_at": "2026-10-09T21:20:54Z",
  "org": {
    "id": "org_01m4h7y09deqsvf1tayjt3sedf",
    "slug": "grace-community-church"
  },
  "data": {
    "message": "Lectern webhook test"
  }
}
Do not depend on formatting

JSON key order and whitespace in the body can differ from these examples. Parse the body, but verify the signature over the exact bytes you received.

What a delivery looks like#

POST /hooks/lectern HTTP/1.1
Content-Type: application/json
User-Agent: Lectern-Webhooks/1.0
Lectern-Signature: t=1791580855,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
Lectern-Event-Id: evt_01m4h8mq26ebwtb83nc7wnrhah
Lectern-Delivery-Id: whd_01m4h8mq29f2va9jxhxnd07w72
Lectern-Event-Type: teaching.ready
HeaderMeaning
Lectern-Signaturet=<unix seconds>,v1=<hex>. During a secret rotation there are two v1 values.
Lectern-Event-IdThe event id, the same as id in the body.
Lectern-Delivery-IdThis attempt’s delivery. A replay has a new one.
Lectern-Event-TypeThe event name.

Verify the signature#

Check every delivery before you trust it. Anyone can send a request to a public address; only Lectern and you know the secret.

  1. Read the exact raw bytes of the request body. Do not parse the JSON and serialise it again, because any change to spacing or key order breaks the signature.
  2. Split Lectern-Signature on commas. Take t as the timestamp and every v1 value as a candidate signature.
  3. Reject the request if the timestamp is more than 5 minutes from your clock, in either direction.
  4. Build the signed payload as the timestamp, a dot, then the raw body: <t>.<body>.
  5. Compute HMAC-SHA256 of that string, keyed with the whole endpoint secret string including the whsec_ prefix. Take the hex digest.
  6. Compare it to each v1 value in constant time. One match is enough.
  7. Only then parse the body. Remember the event id and ignore one you have already handled.

These functions follow those steps. Each was run against signatures produced by Lectern’s own signer, including a two-secret rotation header, a tampered body, a stale timestamp and a malformed header.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyLecternSignature({ secret, header, rawBody, toleranceSeconds = 300, nowSeconds = Date.now() / 1000 }) {
  let timestamp = 0;
  const signatures = [];
  for (const part of header.split(",")) {
    const [key, value] = part.trim().split("=");
    if (key === "t") timestamp = Number(value);
    else if (key === "v1") signatures.push(value);
  }
  if (!Number.isInteger(timestamp) || timestamp <= 0 || signatures.length === 0) return false;
  if (Math.abs(nowSeconds - timestamp) > toleranceSeconds) return false;

  const expected = createHmac("sha256", secret).update(timestamp + ".").update(rawBody).digest("hex");
  return signatures.some((signature) => signature.length === expected.length && timingSafeEqual(Buffer.from(signature), Buffer.from(expected)));
}

In Go, put the function in its own package (the receiver below imports it as lectern). A receiver wires verification, de-duplication and a fast response together:

import express from "express";
import { verifyLecternSignature } from "./verify.js";

const app = express();
const handled = new Set();

app.post("/hooks/lectern", express.raw({ type: "application/json" }), (req, res) => {
  const valid = verifyLecternSignature({
    secret: process.env.LECTERN_WEBHOOK_SECRET,
    header: req.get("Lectern-Signature") ?? "",
    rawBody: req.body,
  });
  if (!valid) return res.sendStatus(400);

  const event = JSON.parse(req.body.toString("utf8"));
  res.sendStatus(200);
  if (handled.has(event.id)) return;
  handled.add(event.id);
  setImmediate(() => handleEvent(event));
});

function handleEvent(event) {
  switch (event.type) {
    case "teaching.ready":
      console.log("Teaching ready", event.data.teaching.id);
      break;
    case "note.approved":
      console.log("Note approved", event.data.note.id);
      break;
    default:
      console.log("Ignoring", event.type);
  }
}

app.listen(process.env.PORT ?? 3000);
Answer first, work later

Return 200 as soon as the signature checks out and do the real work afterwards, from a queue. Lectern waits 10 seconds for an answer.

Check a signature by hand#

To compare your code with a real delivery, set TIMESTAMP, RAW_BODY and LECTERN_WEBHOOK_SECRET from a request you received. This prints the digest that should appear in one of the v1 entries:

printf '%s.%s' "$TIMESTAMP" "$RAW_BODY" \
  | openssl dgst -sha256 -hmac "$LECTERN_WEBHOOK_SECRET" -hex

Delivery, retries and failure#

  • Accepting. Answer with any 2xx status. Anything else, a timeout of 10 seconds, a connection error or a redirect counts as a failure. Lectern does not follow redirects.
  • Retries. A failed delivery is retried with exponential backoff starting at 30 seconds, doubling each time and capped at 30 minutes. After 10 attempts the delivery is marked failed.
  • Disabling. After 25 consecutive failed attempts the endpoint is disabled and its remaining deliveries are skipped. Fix the receiver, then turn it back on with PATCH /webhooks/{id} and {"status": "active"}.
  • At least once. The same event can arrive more than once. Make your handler idempotent and de-duplicate on the event id.
  • Order. Events are not guaranteed to arrive in the order they happened. Use the data in each event, or read the current state from the API, rather than assuming order.
  • Size. Event bodies are at most 64 KB.
  • Tolerate new things. Ignore event types and fields you do not know. See Versioning.

Test, inspect and replay#

curl -X POST "$LECTERN_BASE_URL/v1/api/o/$LECTERN_SLUG/webhooks/$WEBHOOK_ID/test" \
  -H "Authorization: Bearer $LECTERN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

curl "$LECTERN_BASE_URL/v1/api/o/$LECTERN_SLUG/webhooks/$WEBHOOK_ID/deliveries" \
  -H "Authorization: Bearer $LECTERN_API_KEY"

curl -X POST "$LECTERN_BASE_URL/v1/api/o/$LECTERN_SLUG/webhooks/$WEBHOOK_ID/deliveries/$DELIVERY_ID/replay" \
  -H "Authorization: Bearer $LECTERN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

curl -X POST "$LECTERN_BASE_URL/v1/api/o/$LECTERN_SLUG/webhooks/$WEBHOOK_ID/rotate-secret" \
  -H "Authorization: Bearer $LECTERN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"grace_hours": 24}'

curl -X PATCH "$LECTERN_BASE_URL/v1/api/o/$LECTERN_SLUG/webhooks/$WEBHOOK_ID" \
  -H "Authorization: Bearer $LECTERN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"status": "active"}'
  • POST /webhooks/{id}/test queues a signed ping, delivered like a real event. It is the quickest check that your receiver verifies correctly.
  • GET /webhooks/{id}/deliveries returns the last 50 attempts with the status your server answered, how long it took, the next retry time, and a short copy of your response body.
  • POST /webhooks/{id}/deliveries/{delivery_id}/replay sends the same event again as a new delivery with the same event id and a fresh signature.
  • PATCH /webhooks/{id} changes the name, address, events or status. Use paused to stop deliveries without deleting the endpoint.
GET /webhooks/{id}/deliveries
{
  "status": true,
  "message": "ok",
  "data": [
    {
      "id": "whd_01m4h8mq29f2va9jxhxnd07w72",
      "event_id": "evt_01m4h8mq26ebwtb83nc7wnrhah",
      "event_type": "teaching.ready",
      "status": "pending",
      "attempts": 1,
      "response_code": 405,
      "duration_ms": 16,
      "response_body": "<!doctype html><html lang=\"en\"><head><title>Example Domain</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><style>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style><body><div><h1>Example Domain</h1><p>This domain is for use in documentation examples without needing permission. Avoid use in operations.<p><a href=\"https://iana.org/domains/example\">Learn more</a></div></body></html>",
      "error": "endpoint answered 405",
      "next_retry_at": "2026-10-09T21:21:25Z",
      "created_at": "2026-10-09T21:20:55Z"
    }
  ],
  "meta": {
    "request_id": "req_01m4h8nry7eq2bfwf822ry0vwm",
    "total": 2
  }
}

A delivery’s status is pending (waiting or being retried), delivered, failed or skipped (the endpoint was disabled).

Rotate the secret#

POST/webhooks/{id}/rotate-secretwebhooks:manage

Rotating returns a new secret once. For grace_hours (24 by default, up to 168) every delivery carries two signatures, one made with each secret, so you can deploy the new secret without losing events. Your verification already handles this: it accepts the delivery if any v1 value matches the secret you hold.

  1. Rotate and copy the new secret.
  2. Deploy it to your receiver. Until you do, deliveries still verify with the old secret.
  3. After previous_secret_valid_until only the new secret signs.
{
  "status": true,
  "message": "ok",
  "data": {
    "id": "whk_01m4h8mp75fw3vegabgcc7ad7k",
    "name": "Website sync",
    "url": "https://example.org/hooks/lectern",
    "events": [
      "teaching.ready",
      "teaching.failed",
      "note.approved",
      "ask.answered",
      "scripture.detected"
    ],
    "status": "active",
    "created_at": "2026-10-09T21:20:54Z",
    "updated_at": "2026-10-09T21:21:14Z",
    "secret": "whsec_...",
    "previous_secret_valid_until": "2026-10-10T21:21:14Z",
    "consecutive_failures": 0,
    "last_failure_at": "2026-10-09T21:20:55Z",
    "deliveries": []
  },
  "meta": {
    "request_id": "req_01m4h8nry7eq2bfwf822ry0vwm"
  }
}

Local development#

  • Lectern only delivers to public HTTPS addresses, so localhost will not work. Run a tunnel such as ngrok or cloudflared and register the public address it gives you.
  • Send POST /webhooks/{id}/test to see a ping arrive, then trigger a real event, for example by uploading a short transcript file.
  • Use the delivery log to see what status your server returned, and replay an event after you fix a bug.
  • Store the raw body of a real delivery in a test and run your verifier over it with a fixed clock.

Production checklist#

  • Verify the signature over the raw bytes, with a 5 minute tolerance.
  • Answer quickly with a 2xx, then process from a queue.
  • De-duplicate on the event id in durable storage, not memory.
  • Ignore unknown event types and fields.
  • Alert on repeated failures. After 25 in a row Lectern stops sending.
  • Keep the secret out of logs and source control, and rotate it on a schedule.

Next steps