On this page

Sandbox events in real time

~10 min Python TypeScript

Goal: 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

WebhooksSSE stream
DeliveryMIOSA calls your URLYour process pulls
DurabilityRetried on failureLost if process dies
AuthHMAC-SHA256 signatureYour msk_* key
Latency~100ms~50ms
Best forBackground jobs, billing triggers, Slack alertsDashboard 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 typeTrigger
sandbox.runningSandbox finished booting
sandbox.pausedSandbox suspended (idle timeout or manual pause)
sandbox.destroyedSandbox deleted
sandbox.errorUnrecoverable sandbox failure
sandbox.snapshot.readySnapshot upload completed
sandbox.share.createdPreview share token minted
sandbox.share.revokedPreview share token revoked
deployment.liveDeployment promoted to live
deployment.failedDeployment 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

Was this helpful?