Webhooks#

Get results sent to you instead of checking for them. Add a webhook URL to a project in the dashboard, then send code as usual with an API key from that project. When a run finishes, rustbox sends its result to the project's active webhooks.

How it works#

  1. You add a webhook URL to a project in the dashboard
  2. You send code with an API key from that project
  3. Your code runs in a fresh box
  4. Rustbox sends the result to the project's active webhooks, signed with HMAC-SHA256
  5. You check the signature and use the result

Example#

# 1. Add https://your-app.com/hooks/result to the project in the dashboard.
# 2. Submit with a key scoped to that project.
curl -X POST "https://api.rustbox.sh/api/submit" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: rb_live_your_project_key_here" \
  -d '{"language": "python", "code": "print(42)"}'

What rustbox sends#

When a run finishes, rustbox sends (POSTs) the full result to your URL:

{
  "id": "a0928c83-0a1d-4f5e-b724-7ecad619538f",
  "schema_version": "2.0",
  "language": "python",
  "profile": "judge",
  "status": "completed",
  "timestamps": {
    "created_at": "2026-04-02T12:00:00.000Z",
    "started_at": "2026-04-02T12:00:00.001Z",
    "completed_at": "2026-04-02T12:00:00.026Z"
  },
  "result": {
    "verdict": "AC",
    "cause": "normal_exit",
    "actor": "runtime",
    "exit_code": 0,
    "signal": null,
    "error_message": null
  },
  "output": {
    "stdout": "42\n",
    "stderr": "",
    "integrity": "complete"
  },
  "metrics": {
    "cpu_time_secs": 0.009,
    "wall_time_secs": 0.025,
    "memory_peak_bytes": 3858432,
    "cpu_wall_ratio": 0.36,
    "divergence": "cpu_bound"
  },
  "evidence": {
    "isolation": {
      "mode": "strict",
      "controls_applied": ["pid_namespace", "mount_namespace", "network_namespace", "memory_limit", "process_limit", "no_new_privileges"],
      "controls_missing": [],
      "proc_policy": "hardened",
      "sys_policy": "builtin-deny",
      "pidfd_mode": "native",
      "reason": "All configured controls applied"
    },
    "limits": {
      "rlimits": {
        "cpu_secs": { "soft": 4, "hard": 4 },
        "as_bytes": { "soft": 1073741824, "hard": 1073741824 },
        "nofile": { "soft": 32, "hard": 32 },
        "nproc": { "soft": 10, "hard": 10 }
      },
      "cgroup_backend": "cgroup_v2",
      "cgroup": {
        "memory_limit_bytes": 268435456,
        "memory_peak_bytes": 3858432,
        "oom_events": 0,
        "oom_kill_events": 0,
        "cpu_usage_usec": 9000,
        "process_count": 0,
        "process_limit": 10
      }
    },
    "teardown": {
      "reap_status": "clean",
      "descendant_containment": "ok",
      "zombie_count": 0,
      "cleanup_verified": true,
      "residual_mounts": [],
      "collection_errors": []
    }
  }
}

Checking the signature#

The signature proves a webhook really came from rustbox and was not changed on the way. We follow the Standard Webhooks spec, the same one OpenAI, Stripe and Svix use.

Headers#

HeaderValue
webhook-idA unique id for this message (the run's id)
webhook-timestampUnix timestamp (seconds)
webhook-signaturev1,<base64-encoded-hmac>

What is signed#

The HMAC-SHA256 signature covers:

{webhook-id}.{webhook-timestamp}.{body}

Example check (Python)#

import hmac, hashlib, base64

def verify_webhook(body: bytes, headers: dict, secret: str) -> bool:
    msg_id = headers["webhook-id"]
    timestamp = headers["webhook-timestamp"]
    signature = headers["webhook-signature"]

    signed_content = f"{msg_id}.{timestamp}.".encode() + body
    expected = hmac.new(
        secret.encode(), signed_content, hashlib.sha256
    ).digest()
    expected_b64 = "v1," + base64.b64encode(expected).decode()

    return hmac.compare_digest(signature, expected_b64)

How sending works#

  • Only if you ask. No URL, no webhook.
  • Always signed. A webhook URL needs a secret. Rustbox never sends an unsigned webhook.
  • HTTPS only. Webhook URLs must use HTTPS.
  • Never holds up the run. If a webhook fails, the run's result is still saved as normal.
  • 3 tries. At once, then after 1 s, then after 5 s. A server error (5xx) gets another try; a client error (4xx) does not. If all three fail, get the result from /api/result/{id}.

Private addresses are blocked (SSRF protection)#

So a webhook can't be pointed at private systems, every URL is checked:

  • Must use HTTPS
  • Private network addresses blocked: 10.x, 172.16-31.x, 192.168.x, 169.254.x
  • This machine's own address blocked: 127.0.0.1, ::1, localhost