Each path is under
/api/v1. A GET on the same /webhook path reads its delivery status.
Start a generation with a callback
Addwebhook to POST /api/v1/nodes/{nodeId}/runs, alongside your generation options:
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:
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:
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 becomesfinished, 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:
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.
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:
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, HTTP408, 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.