Skip to main content
A worker that should exist exactly once is awkward to build on top of plain CreateInstance, because a retry creates a second machine. experimental.uniqueTag solves that: the platform claims the tag for the instance, and a later request carrying the same tag returns the running instance instead of creating another one. Pairing the tag with a CACHE volume gives the replacement instance a warm cache when the previous one is gone, so a restart does not start from scratch.
uniqueTag lives under experimental. Fields there can change or be removed at any time.
1

Claim a unique tag at creation

Repeating this request with the same tag is safe. The response describes the existing instance if one is already running under the tag.
2

Mount a cache volume under a tag

A volume with persistencyKind: CACHE is restored on a best-effort basis from the most recent volume carrying the same tag. The container below writes an index file on first boot only, so a restart that restores the cache keeps the original file.
3

Read the allocated endpoint

The create response lists each container with the endpoint allocated for every exported port. A reused instance returns the endpoint it already has.
HTTP endpoints require Namespace authentication by default. See access controls.
4

Release the tag when you are done

ReleaseUniqueTag gives up the claim so the next request creates a fresh instance. It accepts an optional ifInstanceId matcher, which makes the release safe to call from a worker that may have already been replaced.

Source

go/ensurewithcache in github.com/namespacelabs/examples. The TypeScript version above follows the same request fields; only the Go example ships in the repository. See cache volumes for how volume tags and reuse work, and instance configuration for the rest of CreateInstanceRequest.
Last modified on October 2, 2026