Sandbox events in real time
~10 min Python TypeScriptGoal: React to sandbox lifecycle events -
sandbox.running,sandbox.destroyed,deployment.live, and others - using either webhooks (durable, server-to-server) or the SSE stream (ephemeral, in-process).What you’ll use: Webhooks, Tenant SSE event stream
Two patterns - choose one
| Webhooks | SSE stream | |
|---|---|---|
| Delivery | MIOSA calls your URL | Your process pulls |
| Durability | Retried on failure | Lost if process dies |
| Auth | HMAC-SHA256 signature | Your msk_* key |
| Latency | ~100ms | ~50ms |
| Best for | Background jobs, billing triggers, Slack alerts | Dashboard UIs, dev-time debugging |
Both patterns carry the same event payloads. You can use both simultaneously - webhooks for the durable server-side reaction, SSE for the live frontend widget.
Pattern A - Webhooks
Register a webhook endpoint
Verify the signature
Every delivery includes a Miosa-Signature header: t=<unix-timestamp>,v1=<hex-digest>. The signed payload is <timestamp>.<raw-body>.
Idempotency
MIOSA retries webhook delivery on failure (5xx, timeout). Your handler must be idempotent. The simplest approach is to persist event.id in a seen-events table before processing:
Pattern B - SSE event stream
Use the tenant SSE stream for in-process listeners - dashboard backends, dev-time monitoring, or any scenario where you want to react inside your running process rather than receive callbacks.
Filter by event type
The stream accepts a types filter to reduce noise:
Event catalog
| Event type | Trigger |
|---|---|
sandbox.running | Sandbox finished booting |
sandbox.paused | Sandbox suspended (idle timeout or manual pause) |
sandbox.destroyed | Sandbox deleted |
sandbox.error | Unrecoverable sandbox failure |
sandbox.snapshot.ready | Snapshot upload completed |
sandbox.share.created | Preview share token minted |
sandbox.share.revoked | Preview share token revoked |
deployment.live | Deployment promoted to live |
deployment.failed | Deployment build or promotion failed |
Choosing between patterns
Use webhooks when:
- You need durability (your process may restart)
- You’re triggering background jobs, billing events, or Slack notifications
- You want MIOSA to push rather than your process to pull
Use the SSE stream when:
- You’re building a live dashboard widget
- You’re writing a short-lived script or dev tool
- You want the simplest possible integration with no webhook endpoint to deploy