Skip to main content
Receive generation status changes at your HTTPS endpoint, for node runs, Cast videos and Ditto videos. Include a callback when starting a generation, or register one afterward, including when the generation has already finished. Each path is under /api/v1. A GET on the same /webhook path reads its delivery status.

Start a generation with a callback

Add webhook to POST /api/v1/nodes/{nodeId}/runs, alongside your generation options:
The callback is saved together with the run. Invalid destinations are rejected before generation starts. Requests made through an agent approval session must register the callback after the approved run starts. POST /cast/videos and POST /ditto take the same webhook object. Resending a Cast video’s attemptId, or a request with the same Idempotency-Key, keeps the webhook the first request registered.

Register a callback afterward

Call the generation’s /webhook path, such as POST /api/v1/node-runs/{nodeRunId}/webhook, with your usual bearer API key and team header:
Generate the signing secret in your application with crypto.randomBytes(32).toString("hex"), and store it securely. Use the exact string as the HMAC key. Melius encrypts the destination and secret in storage. An accepted registration returns HTTP 202:
You need editor access to register a webhook and access to the generation: the run’s canvas, the Cast video you started, or a Ditto video you can read. The destination must use HTTPS and resolve to public IP addresses. URLs containing credentials or fragments are rejected. Redirects are not followed. One webhook can be registered per generation. Another registration returns 409 and keeps the original destination. If registration times out, read its status before trying again. Each new generation needs its own registration. Bulk-run IDs use their existing polling endpoint.

Receive an event

Melius sends a JSON POST when a node run becomes finished, failed, or cancelled:
createdAt records the run update represented by this event. Use GET /api/v1/node-runs/{nodeRunId} to retrieve output versions and error details. Preserve nodeRunId when reading outputs: a node may have started another generation since this event. A Cast or Ditto video sends an event when it becomes ready or failed. Its data names the generationId:
A Ditto video’s type is ditto.status_changed. Read GET /api/v1/cast/videos/{generationId} or GET /api/v1/ditto/{generationId} for the video’s URL or failure message. A failed Ditto video can later finish once its finalization is retried, which sends a new ready event. The event ID and body stay the same on retries. Deliveries may arrive more than once or out of order. Store processed event IDs and the highest sequence for each generation. Apply each event only once and ignore sequences lower than the highest you have processed. A failed run can later finish successfully; that recovery produces a new event with a higher sequence. Acknowledge with any 2xx response after durably accepting the event; perform slow processing separately.

Verify the signature

Each delivery includes:
  • x-melius-webhook-id: the event ID.
  • x-melius-webhook-timestamp: the delivery attempt’s Unix timestamp in seconds.
  • x-melius-webhook-signature: v1= followed by a hexadecimal HMAC-SHA256 signature.
The signed value is eventId.timestamp.rawBody, joined with literal periods. Verify the raw request bytes before parsing JSON. Check the timestamp to reject replayed requests, and compare signatures in constant time:
Keep the receiver’s clock synchronized. Every retry has a fresh timestamp and signature.

Delivery timing and failures

Melius saves a notification in the same transaction as the status change it reports. Pending notifications are dispatched about once a second; worker load may delay delivery. A callback can wait for a long-running generation. Each notification has its own delivery deadline. Registration does not change generation charges. Each delivery attempt has a ten-second request timeout. Network failures, HTTP 408, 429, and 5xx responses retry with increasing delays, starting at ten seconds and capped at one hour. Delivery stops after 30 attempts or 24 hours, whichever comes first. Other non-2xx responses stop delivery immediately. Read the generation’s /webhook path with GET, such as GET /api/v1/node-runs/{nodeRunId}/webhook, to inspect the latest notification: A 404 means the generation is inaccessible or the webhook was never registered. Registration and delivery status remain available while the generation exists, independently of worker history. Keep your own event IDs for deduplication. For a failed delivery, retrieve the generation through its existing GET endpoint.
Last modified on November 24, 2026