remagicaDocs home

Webhooks

Get an HTTPS request when a generation, run or clip job ends, and verify that it came from Remagica.

Instead of polling, give Remagica an HTTPS URL and pick the events you care about. When one happens, Remagica sends a signed POST to that URL.

Add an endpoint

  • In the app: go to Settings → Webhooks, add your URL and tick its events. Send test event checks it works, and the delivery log shows every attempt.
  • With the API: POST /webhook-endpoints with url and events (webhooks:write). The Webhooks section of the API reference covers listing, changing, testing and deleting endpoints, reading deliveries (webhooks:read) and redelivering them.

The URL must be https:// on the public internet. Private, loopback and link-local addresses are refused, and redirects aren't followed.

When you create an endpoint you get its signing secret, which starts with whsec_. It's shown once, so store it on your server. You can rotate it (POST /webhook-endpoints/{endpointId}/secret); the old secret stops working straight away.

Events

EventWhen
generation.succeeded, generation.failed, generation.canceledA generation finished, failed or was canceled.
workflow_run.succeeded, workflow_run.failed, workflow_run.canceledA workflow run finished, failed or was stopped.
app_run.succeeded, app_run.failed, app_run.canceledAn app run finished, failed or was stopped.
clip_job.succeeded, clip_job.failedA clip job finished or failed.
clip_export.succeeded, clip_export.failedA clip re-export finished or failed.
webhook.testYou sent a test event. It goes to the endpoint whatever events it has picked.

The API reference lists each event's payload under Webhook events.

What a delivery looks like

Each delivery is a JSON POST with these headers:

HeaderValue
Content-Typeapplication/json
Remagica-Signaturet=<unix seconds>,v1=<signature>
Remagica-Event-IdThe event's id (evt_…). It's the same in every retry and redelivery.
Remagica-Event-TypeThe event's type, as in the body.

The body names the event and carries the resource exactly as its GET returns it. For example, GET /generations/{generationId} for a generation, or GET /workflow-runs/{runId} for a workflow run:

{
  "id": "evt_…",
  "type": "generation.succeeded",
  "createdAt": "2026-10-21T12:00:00.000Z",
  "organizationId": "…",
  "data": {
    "id": "7a1c9e42-…",
    "kind": "image",
    "status": "completed",
    "outputs": [{ "key": "…", "url": "https://…", "contentType": "image/png" }]
  }
}

A webhook never shows more than an API key could read with GET.

Verify signatures

Check every delivery before you trust it. v1 is the hex HMAC-SHA256 of <t>.<raw body>, keyed with your endpoint's whsec_ secret. Compute it from the raw request body before you parse it, compare in constant time, and refuse old timestamps:

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

/** How old a delivery may be, against replays. */
const TOLERANCE_SECONDS = 300;

export function verifyRemagicaSignature(
  rawBody: string,
  header: string,
  secret: string
): boolean {
  const fields = header.split(",").map((part) => part.trim().split("="));
  const timestamp = Number(fields.find(([name]) => name === "t")?.[1]);
  const signatures = fields
    .filter(([name]) => name === "v1")
    .map(([, value]) => value ?? "");
  if (
    !Number.isInteger(timestamp) ||
    Math.abs(Date.now() / 1000 - timestamp) > TOLERANCE_SECONDS
  ) {
    return false;
  }
  const expected = createHmac("sha256", secret)
    .update(`${timestamp}.${rawBody}`)
    .digest("hex");
  return signatures.some(
    (signature) =>
      signature.length === expected.length &&
      timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
  );
}

For example, with Express:

import express from "express";

const app = express();

app.post(
  "/webhooks/remagica",
  express.raw({ type: "application/json" }),
  (request, response) => {
    const body = request.body.toString("utf8");
    const header = request.get("Remagica-Signature") ?? "";
    if (!verifyRemagicaSignature(body, header, process.env.REMAGICA_WEBHOOK_SECRET)) {
      return response.status(400).send("Bad signature");
    }
    const event = JSON.parse(body);
    // Answer quickly; do slow work after.
    response.sendStatus(200);
    handle(event);
  }
);

Retries

  • Answer with any 2xx status within 10 seconds. Anything else, or no answer, counts as a failed attempt.
  • A failed delivery is retried with backoff, from 30 seconds up to 12 hours between attempts. That's 8 attempts over about 22 hours. After the last one, the delivery is marked failed.
  • An endpoint is switched off after 20 failed deliveries in a row, or after 3 days of failing. Settings shows why. Fix your endpoint, then turn it back on.
  • Deliveries can arrive more than once, and out of order. Use Remagica-Event-Id to skip events you've already handled. If you need the latest state, read the resource again with the API.
  • To send one again, use the delivery log in Settings → Webhooks or POST /webhook-deliveries/{deliveryId}/redeliver.

On this page