Sandboxes — a thin helper over Miosa.Computers that defaults
template_type to "miosa-sandbox" (ephemeral code-exec rootfs, no
desktop).
Mirrors the one-resource product model used by E2B and Daytona: the
computer is the single resource type, and template_type selects its
flavour. A sandbox is just a computer with the lightweight template;
every other module (Miosa.Computer, Miosa.Exec, Miosa.Files,
Miosa.Desktop) works identically.
Example
client = Miosa.client("msk_u_...")
{:ok, sandbox} = Miosa.Sandboxes.create(client, %{name: "quick-exec"})
:ok = Miosa.Computer.start(client, sandbox.id)
{:ok, %{output: out}} = Miosa.Exec.run(client, sandbox.id, command: "echo hi")
:ok = Miosa.Computer.destroy(client, sandbox.id)
Summary
Functions
Create a sandbox — a computer provisioned with the miosa-sandbox template.
Destroy a sandbox. Alias for Miosa.Computers.delete/2.
Fork a sandbox from an existing snapshot or a running sandbox.
Get a sandbox by ID. Alias for Miosa.Computers.get/2.
List sandboxes — filtered to computers whose template_type is
"miosa-sandbox".
Mint a short-lived preview token for a sandbox.
Return the readiness-probe state for a sandbox
(GET /sandboxes/:sandbox_id/readiness).
Template slug used for the lightweight code-exec sandbox rootfs.
Update mutable sandbox fields.
Block until the sandbox reports ready, or timeout seconds elapse.
Functions
@spec create(Miosa.Client.t(), map()) :: Miosa.Client.result(Miosa.Types.Computer.t())
Create a sandbox — a computer provisioned with the miosa-sandbox template.
Accepts the same attributes as Miosa.Computers.create/2; the
template_type key defaults to "miosa-sandbox" when omitted.
White-label attribution
Pass :external_workspace_id, :external_user_id, :external_project_id
to tag the sandbox with your platform's customer/user/project IDs. These
fields never authorize anything — tenancy is always derived server-side
from the API key — but they let your list/usage APIs group by attribution.
{:ok, sandbox} = Miosa.Sandboxes.create(client, %{
name: "smile-dental",
external_workspace_id: "dental-office-123",
external_user_id: "dr-smith-456",
external_project_id: "landing-page-789"
})
@spec delete(Miosa.Client.t(), String.t()) :: Miosa.Client.result(map())
Destroy a sandbox. Alias for Miosa.Computers.delete/2.
@spec fork(Miosa.Client.t(), String.t(), keyword()) :: Miosa.Client.result(map())
Fork a sandbox from an existing snapshot or a running sandbox.
POST /api/v1/sandboxes/:id/fork
Options
:snapshot_id— optional snapshot to fork from.:name— name for the new sandbox.:external_user_id— attribution for the forked sandbox.
Returns the new sandbox object.
@spec get(Miosa.Client.t(), String.t()) :: Miosa.Client.result(Miosa.Types.Computer.t())
Get a sandbox by ID. Alias for Miosa.Computers.get/2.
@spec list(Miosa.Client.t()) :: Miosa.Client.result([Miosa.Types.Computer.t()])
List sandboxes — filtered to computers whose template_type is
"miosa-sandbox".
@spec preview_token(Miosa.Client.t(), String.t(), keyword()) :: Miosa.Client.result(map())
Mint a short-lived preview token for a sandbox.
Wraps POST /api/v1/sandboxes/:id/preview-token.
Options
:expires_in— token lifetime in seconds. Defaults to3600.:scope— token scope string. Defaults to"read".
Returns {:ok, %{"token" => _, "url" => _, "expires_at" => _, "scope" => _}}.
@spec readiness(Miosa.Client.t(), String.t()) :: Miosa.Client.result(map())
Return the readiness-probe state for a sandbox
(GET /sandboxes/:sandbox_id/readiness).
Useful to poll after creation before issuing exec commands.
@spec template() :: String.t()
Template slug used for the lightweight code-exec sandbox rootfs.
@spec update(Miosa.Client.t(), String.t(), map()) :: Miosa.Client.result(map())
Update mutable sandbox fields.
Wraps PATCH /api/v1/sandboxes/:id. Accepted keys:
:name, :slug, :tags, :metadata, :always_on,
:timeout_sec, :idle_timeout_sec.
Returns the updated sandbox map on success.
@spec wait_until_ready(Miosa.Client.t(), String.t(), keyword()) :: {:ok, boolean()} | {:error, Miosa.Error.t()}
Block until the sandbox reports ready, or timeout seconds elapse.
Options
:timeout— seconds to wait. Defaults to30.:stream— whentrue(the default) the SDK first attempts the server-side SSE endpointGET /sandboxes/:id/readiness/streamwhich pushesevent: readyas soon as the sandbox boots (and immediately if it is already ready). Whenfalsethe SDK only polls.
Returns {:ok, true} once ready, {:ok, false} on the server-emitted
event: timeout frame or when the local timeout elapses before ready.
If the SSE endpoint returns 404 (server pre-dates the streaming endpoint)
this transparently falls back to polling readiness/2 every 10 ms.