Getting Started
Authenticate with Namespace
The SDK has no login of its own. It reads the credential written by the Devbox CLI, so install the Devbox CLI and log in once:For automated workloads, use workload identity federation instead. Applications running inside a Namespace workload already receive a credential and need no setup.
Install the SDK
Add the SDK to your project:The Devbox API lives at
@namespacelabs/sdk/devbox. The package root re-exports the same API.Create a client
The client holds the connection to Namespace. See Create a client for configuration options.
createDevboxClient() resolves the credential from step 1 automatically when tokenSource is omitted.Create a Devbox
devboxes.create() provisions a Devbox and returns a handle you operate on. Devboxes start by default, and the call waits for the Devbox to become ready.repository checks out that repository in the Devbox, which requires a connected GitHub organization.Run a command
devbox.exec() runs a command in the Devbox and resolves once it finishes, giving you its output and exit code.exitCode yourself.The complete script
The steps above assemble into one file:Other ways to run commands
exec() covers most cases. Use one of these when it does not.
- shell
- terminal
- terminal (attached)
devbox.shell() runs a script through the Devbox’s configured shell. Use it for pipes, redirects, variable expansion, or chained commands.exec() over shell(), and Use interactive terminals for the full terminal interface.
TypeScript SDK reference
The reference documents the complete SDK surface, starting with installation and a first Devbox.Devboxes
Creation options and lifecycle operations.
Commands
exec(), shell(), their options, and their results.Authentication
Workload identity federation, local credentials, and token sources.
Set this up with a coding agent
Hand your agent the prompt below instead of following the steps above. It installs the Namespace devboxes agent skill, which covers the CLI setup, then points the agent at the SDK reference so it writes against the current API. You will need to complete the login in your browser when the agent reaches that step.Agent Prompt
Next steps
Devbox CLI
Create and connect to Devboxes from your terminal.
Agent Skills
Let a coding agent create and drive Devboxes for you.
Blueprints
Reusable Devbox configurations.