Factordocs

Webhooks

Have Factor tell your systems what happened.

A webhook posts a signed JSON body to a URL of yours when something happens — a run finishing, a spend cap being reached, a machine failing.

Creating one

Dashboard, Webhooks → Add. Give it an HTTPS URL and pick the events you care about. The signing secret is shown once; store it then.

The events

EventWhen
sandbox.startedA sandbox began running.
sandbox.succeededIt exited zero.
sandbox.failedIt exited non-zero, or the machine failed.
factory.deployedA factory came up, or was redeployed.
factory.suspendedSuspended, by you or by its idle timeout.
factory.resumedResumed.
factory.failedIt stopped in a way nobody asked for.
factory.terminatedDestroyed.
artifacts.downloadedSomebody pulled a run's results.
billing.spend_cap_reachedThe cap was hit, and machines were stopped.
billing.credits_lowCredit is running out.
abuse.flaggedA machine was flagged for review.
member.joined / member.removedTeam membership changed.

What arrives

{"event": "sandbox.succeeded","id": "whd_01M0P4K2ZQ8N","created_at": "2026-09-05T09:41:12Z","data": {  "factory_id": "fac_01M0AM8702EJN8VV2QPQGQ55SJ",  "exit_code": 0,  "started_at": "2026-09-05T09:22:48Z",  "finished_at": "2026-09-05T09:41:10Z"}}

With these headers:

Header
Factory-EventThe event name, so you can route without parsing the body.
Factory-DeliveryA unique id for this delivery — use it to deduplicate.
Factory-TimestampUnix seconds, and part of what is signed.
Factory-Signaturev1= followed by the HMAC.

Verifying the signature

Do this before you read the body. A webhook endpoint is a public URL, and without verification anybody who finds it can tell you a job succeeded.

The signature is HMAC-SHA256 over <timestamp>.<raw body>, keyed with your signing secret.

Node
import { createHmac, timingSafeEqual } from "node:crypto"; export function verify(secret, headers, rawBody) {const timestamp = Number(headers["factory-timestamp"]);const signature = headers["factory-signature"]; // Refuse anything outside five minutes, whatever the digest says: a valid// signature on an old request is exactly what a replay is.if (Math.abs(Date.now() / 1000 - timestamp) > 300) return false; const expected = "v1=" + createHmac("sha256", secret)  .update(timestamp + "." + rawBody)  .digest("hex"); const a = Buffer.from(signature);const b = Buffer.from(expected);return a.length === b.length && timingSafeEqual(a, b);}
Python
import hashlib, hmac, time def verify(secret: str, headers, raw_body: bytes) -> bool:  timestamp = int(headers["Factory-Timestamp"])  if abs(time.time() - timestamp) > 300:      return False   expected = "v1=" + hmac.new(      secret.encode(),      f"{timestamp}.".encode() + raw_body,      hashlib.sha256,  ).hexdigest()   return hmac.compare_digest(expected, headers["Factory-Signature"])

Retries

Answer 2xx and the delivery is done. Answer 5xx, 429 or 408 and it is retried with a widening gap. Any other 4xx is abandoned: a body your endpoint rejects will be rejected the same way next time.

Deliveries that keep failing eventually disable the endpoint, and the dashboard says which failure did it.

Checking it works

Send test on the webhook posts a webhook.test event immediately. Every attempt, its response and its status are listed under Deliveries, and you can replay any of them.