External automation -> Inbound task trigger -> Run -> HTTPS task handler
|
+-> Signed lifecycle event
Provider reply -> Your application -> Reply webhook -> Existing waiting runTrigger a task from an automation
Call POST /v1/triggers/{slug} with an API key from the same environment as the task. Send the JSON object received by the handler as payload. Reuse an event-specific idempotency key if the sender may deliver the same trigger again.
curl --fail-with-body "$SIMPLCRON_BASE_URL/v1/triggers/generate-invoice" \
-H "Authorization: Bearer $SIMPLCRON_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: upstream-event-123" \
--data '{"payload":{"invoiceId":"inv_123"}}'Forward a reply to a waiting run
When your provider sends a reply webhook, verify the provider webhook in your application. Look up the run ID you saved at submission and send POST /v1/runs/{runId}/reply with a JSON payload object and a server-side runs:write key from the run’s environment. The run resumes on the first accepted reply or on timeout. Wait for Reply guide · Send a reply to a run
Receive lifecycle notifications
In Webhooks, or with POST /v1/webhooks, register an allowlisted HTTPS receiver and choose events. Save the subscription’s one-time signing secret.
| Event | When it occurs |
|---|---|
task.execution |
A worker claims an attempt. A retry can produce another execution event for the same run. |
task.completed |
The run succeeds. |
task.failed |
The run reaches terminal failure. |
Each HTTP delivery includes X-Simplcron-Event, X-Simplcron-Delivery, and X-Simplcron-Signature. Events can be delivered more than once. Use the event body’s id as the deduplication key and acknowledge duplicates with a successful response. Use the run ID to read updated status and the trace.
Verify a signature
An outbound delivery or handler request signs the timestamp in Unix seconds, followed by a period and the exact request body. The header has the form t=<timestamp>,v1=<hex>. Verify the raw bytes before parsing JSON and use the secret for the particular task or webhook subscription.
import { createHmac, timingSafeEqual } from "node:crypto";
function validSimplcronSignature(rawBody, header, secret) {
const signature = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? "");
if (!signature || !secret) return false;
const [, timestamp, hex] = signature;
if (Math.abs(Math.floor(Date.now() / 1000) - Number(timestamp)) > 300) return false;
const expected = createHmac("sha256", secret)
.update(timestamp + ".")
.update(rawBody)
.digest();
return timingSafeEqual(expected, Buffer.from(hex, "hex"));
}Task handler requests also carry an Idempotency-Key equal to the run ID. Reuse any committed result for that run before making a second external effect. Application-level idempotency matters because a handler can perform an effect even if its response does not reach Simplcron.