# Webhooks Get a signed HTTPS POST when a sandbox starts, pauses, resumes or ends. ## 1. Add a webhook 1. Open **Webhooks** at [compute.fdtn.dev](https://compute.fdtn.dev) (owners and admins only). 2. Enter an HTTPS URL on port 443 or 8443 at a public address, and select events. 3. Copy the signing secret. The page shows it once. 4. Click **Send test event** to get a signed sample. ## 2. Events | Event | `event_label` | When sent | |---|---|---| | `sandbox.lifecycle.created` | `create` | A sandbox started. | | `sandbox.lifecycle.paused` | `pause` | You paused it, or the sandbox spending limit paused it. | | `sandbox.lifecycle.resumed` | `resume` | A paused sandbox started again. | | `sandbox.lifecycle.killed` | `kill` | A kill, the end of its lifetime, or 72 hours after its last pause. | ## 3. Payload A JSON body. This sandbox reached the end of its lifetime: (sandbox.lifecycle.killed): ``` { "id": "6f1c2a9e-...", "version": "v2", "type": "sandbox.lifecycle.killed", "timestamp": "2026-11-05T10:15:00Z", "event_category": "lifecycle", "event_label": "kill", "event_data": { "sandbox_metadata": { "run": "eval-1" }, "execution": { "started_at": "2026-11-05T10:10:00Z", "vcpu_count": 2, "memory_mb": 512 }, "kill_reason": "timeout" }, "sandbox_id": "i8x3k...", "sandbox_execution_id": "i8x3k...", "sandbox_template_id": "base", "sandbox_build_id": "", "sandbox_team_id": "", "events_ttl_days": 30 } ``` | Field | Meaning | |---|---| | `id` | Event ID, the same on every retry | | `timestamp` | Event time, UTC | | `event_data.sandbox_metadata` | Metadata from create, or `{}` | | `event_data.execution` | `killed` only: `started_at`, `vcpu_count`, `memory_mb`, `execution_time` when known | | `event_data.kill_reason` | `killed` only: `request`, `timeout` or `paused_retention` | | `sandbox_template_id`, `sandbox_build_id` | Template and build; can be empty | | `sandbox_team_id` | Your workspace ID | ## 4. Verify the signature | Header | Value | |---|---| | `fdtn-timestamp` | Send time in Unix seconds. New on each retry. | | `fdtn-signature` | `v1=` and the hex HMAC-SHA256 of `.`, keyed with your signing secret. | | `user-agent` | `FDTN-Compute-Webhooks/1` | Sign the raw body, not parsed JSON. Compare in constant time. Refuse a timestamp more than 5 minutes old. Python (verify.py): ```python import hashlib, hmac, time def verify(secret: str, headers: dict, body: bytes) -> bool: ts = headers["fdtn-timestamp"] if abs(time.time() - int(ts)) > 300: return False # older than 5 minutes: maybe a replay want = hmac.new(secret.encode(), ts.encode() + b"." + body, hashlib.sha256).hexdigest() return hmac.compare_digest("v1=" + want, headers["fdtn-signature"]) ``` TypeScript (verify.mjs): ```typescript import { createHmac, timingSafeEqual } from 'node:crypto' export function verify(secret, headers, body) { const ts = headers['fdtn-timestamp'] if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false // older than 5 minutes: maybe a replay const want = 'v1=' + createHmac('sha256', secret).update(`${ts}.${body}`).digest('hex') const got = headers['fdtn-signature'] ?? '' return got.length === want.length && timingSafeEqual(Buffer.from(got), Buffer.from(want)) } ``` ## 5. Delivery and retries | Rule | Detail | |---|---| | Success | A `2xx` within 10 seconds | | Failure | Any other status (redirects too), a network error or no answer in 10 seconds | | Retries | After 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours; then the page shows **Failed** | | No retry | A host name that points to a private address | | Order | Messages can arrive out of order or twice. Sort by `timestamp`; drop duplicates by `id`. | Answer `200` first, then do slow work. ## Next - [**Pause, resume and snapshots**: The states behind events.](https://fdtn.dev/docs/lifecycle.md) - [**HTTP API**: Call the sandbox API directly.](https://fdtn.dev/docs/api.md) Source: https://fdtn.dev/docs/webhooks/