Cloudflare Worker for a social video pipeline: SDK verifyWebhook

@sume-com/sdk 0.2.0 needs only fetch and WebCrypto, so verifyWebhook runs in a Cloudflare Worker. Verify the raw body, then answer 2xx before you post.

5 min readSume
All posts

@sume-com/sdk 0.2.0 has no runtime dependencies and needs only fetch and WebCrypto, so it runs on Node 18+, Bun, Deno and Cloudflare Workers. Its verifyWebhook is async, takes the raw body, headers and secret, and returns false instead of throwing, which fits a small Worker that receives a Sume webhook and starts a social post.

Read the secret from the dashboard Webhooks tab or GET /v1/webhooks/signing-secret with an account:read key, and store it as SUME_COM_WEBHOOK_SIGNING_SECRET.

What does the helper need?

From Sume's SDK docs.

verifyWebhook inputs (read 2026-10-05)
FieldNotes
bodyThe raw body: string, ArrayBuffer or typed array
headersA Headers, Map or plain object; case-insensitive
secretYour Sume webhook signing secret
toleranceSecondsReplay window; default 300; 0 skips the timestamp check

What does the Worker look like?

Read the body as text before any JSON parse, refuse a missing secret, and return a fast 2xx.

import { verifyWebhook } from "@sume-com/sdk";

export default {
  async fetch(request: Request, env: { SUME_COM_WEBHOOK_SIGNING_SECRET?: string }) {
    const secret = env.SUME_COM_WEBHOOK_SIGNING_SECRET;
    if (!secret) return new Response("not configured", { status: 500 });
    const body = await request.text();
    const ok = await verifyWebhook({ body, headers: request.headers, secret });
    if (!ok) return new Response("bad signature", { status: 401 });
    const event = JSON.parse(body);
    if (event.event === "job.completed") {
      // enqueue the platform posts here, keyed by event.job_id
    }
    return new Response(null, { status: 204 });
  },
};

What should happen after the 2xx?

Do the platform posts from a queue, not inside the request: Sume allows 10 seconds for each attempt, and a slow endpoint spends that budget and is retried. Dedupe on job_id, since a delivery can arrive more than once.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume