Skip to main content
The Python SDK is instabox-sdk on PyPI. It runs on Python 3.9 to 3.13, has one dependency (httpx) and imports as instabox.

Install and authenticate

Create the key on API keys in the dashboard: Full access, or a restricted key with machines:write and machines:delete, which is enough for the quickstart. The snapshot calls also need images:write (create), images:read (list and get) and images:delete (delete). See API keys. Client() reads INSTABOX_API_KEY and INSTABOX_API_URL (default https://api.instabox.sh), or takes Client(api_key=..., base_url=...).

Quickstart

create waits until the machine is ready. exec takes a shell string, run with bash -lc, or an argv list, run with no shell. A non-zero exit code is a result, not an error: read it from r.exit_code.

Pick up a machine later

A machine pauses after 30 idle minutes by default. ensure_running starts or resumes it, whatever its state, and waits until it is ready. This block runs on its own: it makes my-box first, as an earlier run would have, and deletes it at the end:

Calls

Every call that takes machine accepts a machine ID (m_...) or its name. Every argument and model field is in the SDK README.

Errors

Every error is an instabox.InstaboxError. API errors are instabox.APIError subclasses with the API’s code, message, request_id, retryable and status: spec_not_allowed is a plan or size limit and takes the status of what was refused: 400 for a size or disk size the plan does not offer, 403 for another idle time (auto_suspend_after_seconds) on the free plan or starting a paid machine larger than its plan now allows, 409 for restoring a snapshot that does not fit the machine’s disk. A failed operation raises OperationFailedError, a wait that runs out WaitTimeoutError. Every code: Errors.