Can I use template names instead of IMAGE_ID when creating sandboxes?

Last updated: January 21, 2026

NEEDS TO BE REVIEWED

Context

When creating sandboxes programmatically using the Blaxel SDK, you may wonder whether you need to use the specific IMAGE_ID or if you can use the template name directly. This is particularly relevant when working across different workspaces (like development and production environments) where you want to use consistent, readable template names rather than looking up specific image IDs.

Answer

Yes, you can use the template name directly instead of the IMAGE_ID when creating sandboxes. This approach works safely across different workspaces as long as you have deployed the template with the same name in each workspace.

Here's how to create a sandbox using a template name:

import { SandboxInstance } from "@blaxel/core";

// Create a new sandbox using template name
const sandbox = await SandboxInstance.create({
  name: "my-sandbox",
  image: "my-template", // Use template name instead of IMAGE_ID
  memory: 4096,
  ports: [{ name: "nextjs-dev", target: 3000 }, { name: "another-api", target: 8888 }]
});

Requirements:

  • The template must be deployed in each workspace where you want to use it

  • The template name must be consistent across workspaces

Benefits of using template names:

  • More readable and maintainable code

  • No need to look up IMAGE_IDs with commands like bl get sandboxes mytemplate -ojson | jq -r '.[0].spec.runtime.image'

  • Consistent across different environments

This eliminates the need to retrieve and hardcode specific IMAGE_IDs, making your code more portable and easier to manage across different workspaces.