Skip to content

fix(js-sdk): forward name param and expose names in createSnapshot#1251

Draft
serhiizghama wants to merge 1 commit intoe2b-dev:mainfrom
serhiizghama:fix/issue-1249-snapshot-name-param
Draft

fix(js-sdk): forward name param and expose names in createSnapshot#1251
serhiizghama wants to merge 1 commit intoe2b-dev:mainfrom
serhiizghama:fix/issue-1249-snapshot-name-param

Conversation

@serhiizghama
Copy link
Copy Markdown

Problem

Closes #1249

The JS SDK's createSnapshot() silently ignored any name option:

  • It sent body: {} — the name was never forwarded to the REST API
  • There was no name option exposed in the type signature
  • The names array from the API response was dropped and never returned

This meant users couldn't create named snapshots (addressable as team-slug/my-snapshot) via the SDK — they had to fall back to raw snapshot IDs.

What changed

packages/js-sdk/src/sandbox/sandboxApi.ts

  • Added SnapshotCreateOpts interface (extends SandboxApiOpts) with an optional name field
  • Updated SandboxApi.createSnapshot() to accept SnapshotCreateOpts and conditionally include name in the request body
  • Added names?: string[] to SnapshotInfo to surface the response field (matches schema.gen.ts)

packages/js-sdk/src/sandbox/index.ts

  • Updated Sandbox.createSnapshot() to accept SnapshotCreateOpts instead of SandboxApiOpts
  • Updated JSDoc example to show named snapshot usage

packages/js-sdk/src/index.ts

  • Exported SnapshotCreateOpts from the public API

How to test

const sandbox = await Sandbox.create()
await sandbox.files.write('/app/state.json', '{"step": 1}')

// Create a named snapshot
const snapshot = await sandbox.createSnapshot({ name: 'my-snapshot' })
console.log(snapshot.snapshotId)  // 'team-slug/my-snapshot:default'
console.log(snapshot.names)       // ['team-slug/my-snapshot:default']

// Restore from named snapshot
const restored = await Sandbox.create('team-slug/my-snapshot')

The generated schema (schema.gen.ts) already included both the name request field and names response field — this PR aligns the SDK implementation with the schema.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

⚠️ No Changeset found

Latest commit: 252716b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Crunchyman-ralph
Copy link
Copy Markdown

@serhiizghama seems like a duplicate of #1250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS SDK: createSnapshot does not forward the 'name' parameter to the REST API

2 participants