Events (SSE)

Several long-running operations stream progress over Server-Sent Events. The SSE stream for a resource is always at:


GET /api/v1/{resource-type}/{id}/events

Because the browser EventSource API does not support custom headers, SSE endpoints use a one-time ticket for authentication instead of the Authorization header:

Event types vary by resource. Common event shapes:

// Build log line
{ "type": "log", "stream": "stdout", "data": "Installing dependencies...", "ts": 1748390460 }

// Status change
{ "type": "status_changed", "previous": "building", "current": "ready", "ts": 1748390462 }

// Error
{ "type": "error", "code": "BUILD_FAILED", "message": "Exit code 1", "ts": 1748390465 }

Sandbox lifecycle events

EventWhen
sandbox.createdSandbox resource created (not yet booted)
sandbox.readyBoot complete, exec and file endpoints available
sandbox.errorFatal boot or runtime error
sandbox.destroyedSandbox stopped and resources released
sandbox.share.createdA share token was minted for the sandbox
sandbox.share.revokedA share token was revoked

Deployment lifecycle events

EventWhen
deployment.createdDeployment object created
deployment.build_startedBuilder VM booted, build in progress
deployment.build_succeededRelease artifact ready
deployment.build_failedBuild exited non-zero
deployment.publishedActive version updated, traffic cut over
deployment.rollbackActive version reset to a prior version

Tenant-wide SSE stream

To receive all lifecycle events for your organization without polling per-resource endpoints, subscribe to the tenant stream:

# Mint a ticket
TICKET=$(curl -s -X POST https://api.miosa.ai/api/v1/events/ticket 
  -H "Authorization: Bearer msk_u_..." | jq -r '.ticket')

# Stream all org events
curl -N "https://api.miosa.ai/api/v1/events?ticket=$TICKET"

Each event on the tenant stream includes a resource_type and resource_id field so you can route to the right handler:

{
  "type": "sandbox.ready",
  "resource_type": "sandbox",
  "resource_id": "sbx_abc123",
  "external_user_id": "alice@acme.com",
  "ts": 1748390462
}

See Events (SSE) API Reference and Tenant Events for the complete event catalog and filtering options.

Was this page helpful?