API docs
Webhooks

API reference

Webhooks

Get a signed message when a Build is done or failed. Verify the HMAC signature in Python or Node, handle retries and repeats.

Instead of polling, send a webhook_url when you create a Build. When the Build is done or failed, we POST a signed JSON message to that address.

Events#

build.done
The Build is done: build.reader.url (PDF) or build.timings_url (Word List) is set. A PDF Build also has build.reader_data_url.
build.failed
The Build failed: see build.failure_reason.

Each Build with a webhook_url sends exactly one event. Builds made on the website send none.

The message#

A POST with a JSON body. build is the same Build object as GET /builds/{build_id}.

POST https://example.org/hooks/shiur-reader
{
  "event": "build.done",
  "delivery_id": "0789e430d68e42719d2782d9b19edd2f",
  "created_at": "2026-10-11T09:41:12Z",
  "build": {
    "id": "cd4e2fd751c84d659936cdf0e0002da0",
    "url": "https://app.shiurreader.com/api/v1/builds/cd4e2fd751c84d659936cdf0e0002da0",
    "title": "Lehavin 6",
    "status": "done",
    "waiting_reason": null,
    "progress": {
      "percent": 100,
      "message": "Done"
    },
    "failure_reason": null,
    "audio_hours": "1.5",
    "visibility": null,
    "reader": {
      "id": "0dibrutk",
      "url": "https://app.shiurreader.com/r/0dibrutk",
      "deleted": false
    },
    "match": {
      "words_timed": 958,
      "words_total": 1012,
      "pages_read": [
        5,
        6,
        7
      ],
      "audio_minutes_matched": 38.4,
      "reading_spans": [
        [
          41.2,
          1820.5
        ],
        [
          1902.0,
          2507.9
        ]
      ],
      "mismatch": false
    },
    "timings_url": null,
    "reader_data_url": "https://app.shiurreader.com/api/v1/readers/0dibrutk/data",
    "created_at": "2026-10-11T09:00:00Z",
    "finished_at": "2026-10-11T09:41:12Z"
  }
}

Headers#

Shiur-Reader-Signature
t=<unix seconds>,v1=<hex signature>. See Verify the signature.
Shiur-Reader-Event
build.done or build.failed, the same as event in the body.
Shiur-Reader-Delivery
The delivery id, the same as delivery_id in the body. It stays the same on every retry.
Content-Type
application/json
User-Agent
ShiurReader-Webhooks/1

Verify the signature#

Anyone can POST to your address, so check every message before you trust it. Your Organization's signing secret (whsec_...) is on the API Keys page, for Owners.

  1. Read t and v1 from the Shiur-Reader-Signature header.
  2. Compute HMAC-SHA256 with the secret as key over t, a dot, and the raw request body (the exact bytes, before any JSON parsing), as lowercase hex.
  3. Compare it with v1 in constant time.
  4. Reject the message if t is more than 300 seconds (5 minutes) from your clock. This stops replays of old messages.
Signature
signature = hex(HMAC_SHA256(secret, t + "." + raw_body))

Python

import hashlib
import hmac
import os
import time

SECRET = os.environ["SHIUR_READER_WEBHOOK_SECRET"]  # whsec_..., from the API Keys page
TOLERANCE = 300  # seconds


def verify(raw_body: bytes, signature_header: str) -> bool:
    """True if the Shiur-Reader-Signature header matches the raw request body."""
    parts = dict(item.split("=", 1) for item in signature_header.split(",") if "=" in item)
    timestamp, received = parts.get("t", ""), parts.get("v1", "")
    if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > TOLERANCE:
        return False
    expected = hmac.new(SECRET.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, received)


# Flask
from flask import Flask, abort, request

app = Flask(__name__)
seen = set()  # use your database in production


@app.post("/hooks/shiur-reader")
def shiur_reader_webhook():
    if not verify(request.get_data(), request.headers.get("Shiur-Reader-Signature", "")):
        abort(400)
    delivery_id = request.headers["Shiur-Reader-Delivery"]
    if delivery_id not in seen:  # a retry repeats the same delivery id
        seen.add(delivery_id)
        message = request.get_json()
        build = message["build"]
        if message["event"] == "build.done":
            print("Ready:", build["reader"]["url"] if build["reader"] else build["timings_url"])
        else:
            print("Failed:", build["failure_reason"])
    return "", 204

JavaScript

import crypto from "node:crypto";
import express from "express";

const SECRET = process.env.SHIUR_READER_WEBHOOK_SECRET; // whsec_..., from the API Keys page
const TOLERANCE = 300; // seconds

function verify(rawBody, signatureHeader = "") {
  const parts = Object.fromEntries(
    signatureHeader.split(",").map((item) => item.split(/=(.*)/s).slice(0, 2)),
  );
  const timestamp = Number(parts.t);
  if (!Number.isInteger(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > TOLERANCE) return false;
  const expected = crypto
    .createHmac("sha256", SECRET)
    .update(`${parts.t}.`)
    .update(rawBody)
    .digest("hex");
  const received = Buffer.from(parts.v1 ?? "", "utf8");
  return received.length === expected.length && crypto.timingSafeEqual(Buffer.from(expected, "utf8"), received);
}

const app = express();
const seen = new Set(); // use your database in production

// express.raw keeps the exact bytes that were signed.
app.post("/hooks/shiur-reader", express.raw({ type: "application/json" }), (req, res) => {
  if (!verify(req.body, req.get("Shiur-Reader-Signature"))) return res.sendStatus(400);
  const deliveryId = req.get("Shiur-Reader-Delivery");
  if (!seen.has(deliveryId)) { // a retry repeats the same delivery id
    seen.add(deliveryId);
    const { event, build } = JSON.parse(req.body);
    if (event === "build.done") console.log("Ready:", build.reader?.url ?? build.timings_url);
    else console.log("Failed:", build.failure_reason);
  }
  res.sendStatus(204);
});

app.listen(3000);

Every attempt, retries included, is signed afresh with the current time and the current secret.

Respond, and retries#

Answer with any 2xx status within 10 seconds. Do slow work after answering. Anything else (an error status, a redirect, a timeout, no connection) is a failed attempt, and we try again after:

  1. 1 minute
  2. 5 minutes
  3. 30 minutes
  4. 2 hours
  5. 8 hours

That is 6 attempts over about 10.5 hours. After the last one fails we give up; the Build itself is not affected, and you can still get it. Redirects are never followed, so give the final address.

Repeats and order#

A message can arrive more than once, for example if your server handled it but the answer was lost. A retry carries the same Shiur-Reader-Delivery id, so store the ids you have handled and ignore repeats, as in the examples above.

Webhook addresses#

Rotate the secret#

On the API Keys page, an Owner can select Rotate secret. The old secret stops working at once, also for retries still pending, so update your server right after rotating.