CreateInstance call declares both the machine and the workload that runs on it, and returns while the instance boots.
Nothing is long-lived by default: when an instance reaches its deadline the platform sends SIGTERM and then shuts the machine down.
Workloads are declared in one of two fields.
containers runs OCI containers and is available on Linux.
applications runs processes directly on the host, which is how macOS workloads are declared.
Getting Started
Authenticate with Namespace
The SDKs have no login of their own. They read the credential written by
nsc login, so install the CLI and authenticate once:Code that runs somewhere you can’t log in, such as a script on another machine, can use a development token from
nsc auth generate-dev-token instead. The curl examples below send it as a bearer token. See Build on your own workspace to pass one to an SDK client.Inside a Namespace instance, the SDKs read the token from NSC_TOKEN_FILE, which is set automatically.Add a client library
The Compute API is a Connect service, so a plain HTTP client works as well and needs no SDK.
Create an instance
The example below requests a 2 vCPU Linux machine with 4 GB of memory, runs a command in a container, and waits for the instance to become ready.
CreateInstance returns as soon as the instance is accepted, before the workload is running.
The response carries metadata.instanceId and a dashboard link in instanceUrl.
WaitInstanceSync blocks until the instance is ready. WaitInstance streams boot progress instead.Requests over plain HTTP use the Connect protocol: POST {baseUrl}/{service}/{method} with a JSON body in protojson form, which is why the field names above are camelCase and enums are sent as strings.
Server-streaming methods have unary Sync variants, so an HTTP client never has to stream.Next steps
Configuration
Placement selectors, exported ports, volumes, macOS applications, and idempotent creation.
Run commands
Execute a command inside a container with the CommandService.
SSH access
Fetch per-instance credentials and open an interactive session.