https://<slug>.<domain> and stays the same when you change the target.
Create a Service
Select a remote destination withMSB_BACKEND=remote or a remote profile. With the local destination selected, Service lookup, list, and creation return an unsupported error before sending a provider request, even when MSB_API_KEY is set.
Start the target sandbox, then create the Service:
404 not_found for a short time.
Move, disable, or enable a Service
A Service isenabled, disabled, or detached (it has no target). Disabling keeps the target. Enabling the Service, or setting a target, turns it back on; the target sandbox must be running.
service_detached reason, so set a target instead.
If the target sandbox stops, the Service keeps its target and requests return 503 sandbox_not_running until the sandbox runs again. If the target sandbox is removed, the Service becomes detached and keeps its slug. After a few seconds, requests return 503 no_target or 404 not_found until you set a new target.
Handle requests
In the sandbox, your application must listen on the target port at0.0.0.0 or 127.0.0.1. Services support HTTP, WebSocket, and server-sent events (SSE). Set your own timeouts for slow responses, and keep long-lived connections active. Your application receives the original method, path, query, and body, plus these headers:
Host: the Service hostnameX-Forwarded-Host: the Service hostnameX-Forwarded-Proto:httpsX-Forwarded-For: the client IP address
msb- or x-msb-, and cookies named msb_* or __Host-msb_*, are reserved for Microsandbox: they never reach your application, and your responses cannot set those cookies.
On the Free plan, a browser’s first visit shows a notice page before your application. Automated browsers, such as end-to-end tests, can skip it by sending an msb-skip-browser-warning header with any value.
Error responses
When Microsandbox answers instead of your application, the response has anx-msb-error header. Microsandbox removes this header from your application’s responses, so it always means Microsandbox answered. The body is JSON with the same code in error.code, or an HTML page when the client asks for text/html.
Only
service_unavailable means Microsandbox itself cannot serve the request. The other codes describe the Service, its target sandbox, your application, or the request.
Get a Service
Get a Service by its slug to read its URL, its status (enabled, disabled or detached), its target, and when it was created and last changed. A Service object holds the state from the response that returned it; refresh returns a current copy.
--format json to any msb service command except remove. A Service prints as an object with slug, url, status, target, created_at, and updated_at.
List Services
Lists are in slug order and include disabled and detached Services. Filter by sandbox to find its Services.msb service ls lists every Service.
Remove a Service
Removing a Service releases its slug.When a change fails
Create, update, enable, disable, and remove each send one request and never retry. Most errors mean nothing changed. If an error says the change may have been applied, get the Service and check it before trying again. An update, enable, or disable that is already in effect succeeds without a change. See SDK errors.Audit events
Each committed Service change records one event in the organization’s audit log. A change that is already in effect records nothing. Read Service events with the audit-log API. Authenticate with an API key.since, until, cursor, and limit. Each event has id, org_id, category (audit), event_type, actor, payload, and timestamp.
Every payload also has
org_id. A service_rotated event means the Service was pointed at a new target. Its from_sandbox_id is null when the Service had no target.
The sandbox_id on service_disabled and service_enabled is null when the target sandbox was deleted during the change. On service_deleted, it is null when the Service was detached.
Events contain sandbox IDs, not sandbox names. Deleting a target sandbox automatically detaches its Service without recording a service_* event.
Limits
Service limits
Service limits
You can request a higher limit for your organization. If a limit drops below your current usage, existing Services keep working; creating a Service, or moving one to a sandbox at its limit, is refused until you are under it.Going over these limits fails with
service_quota_exceeded or sandbox_service_limit_exceeded (see Service changes). Disabled Services count toward both limits, and detached Services count toward the organization limit. Too many concurrent requests to one sandbox return 429 service_busy_inflight.