Skip to main content

snapshots

Creates, updates, deletes, gets or lists a snapshots resource.

Overview

Namesnapshots
TypeResource
Idvercel.sandboxes.snapshots

Fields

The following fields are returned by SELECT queries:

This object contains information related to a Snapshot of a Vercel Sandbox session (v2 API).

NameDatatypeDescription
idstringThe unique identifier of the snapshot. (example: snap_123a6c5209bc3778245d011443644c8d27dc2c50)
parent_idstringThe unique identifier of the parent snapshot, if this snapshot was created from another snapshot. (example: snap_parent123) (wire: parentId)
source_session_idstringThe unique identifier of the session from which the snapshot was created. (example: sbx_123a6c5209bc3778245d011443644c8d27dc2c50) (wire: sourceSessionId)
created_atnumberThe time when the snapshot was created, in milliseconds since the epoch. (wire: createdAt)
creation_methodstringThe method used to create the snapshot. (automatic, manual) (example: manual) (wire: creationMethod)
expires_atnumberThe time when the snapshot will expire, in milliseconds since the epoch. If not set, the snapshot does not have any expiration. (wire: expiresAt)
last_used_atnumberThe last time the snapshot was used (e.g. to resume or create a sandbox), in milliseconds since the epoch. Falls back to createdAt for older snapshots that predate this field. (wire: lastUsedAt)
regionstringThe region where the snapshot is stored. (example: iad1)
regionsarrayThe regions where the snapshot is available.
size_bytesnumberThe size of the snapshot in bytes. (wire: sizeBytes)
statusstringThe status of the snapshot. (created, deleted, failed) (example: created)
updated_atnumberThe last time the snapshot was updated, in milliseconds since the epoch. (wire: updatedAt)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectsnapshot_idteam_id, slugRetrieves detailed information about a specific snapshot, including its creation time, size, expiration date, and the source session it was created from.
listselectproject, name, limit, cursor, sort_order, team_id, slugRetrieves a paginated list of snapshots for a specific project.
createinsertsession_idteam_id, slugCreates a point-in-time snapshot of a running session's filesystem. Snapshots can be used to quickly restore a session to a previous state or to create new sessions with pre-configured environments. The session must be running and able to accept commands for a snapshot to be created. The session will be terminated after the snapshot is created. Unlike v2, snapshots expire after 7 days when neither the request nor the sandbox configuration specifies an expiration.
deletedeletesnapshot_idteam_id, slugPermanently deletes a snapshot and frees its associated storage. This action cannot be undone. After deletion, the snapshot can no longer be used to create new sessions.
create_v2execsession_idteamId, slugCreates a point-in-time snapshot of a running session's filesystem. Snapshots can be used to quickly restore a session to a previous state or to create new sessions with pre-configured environments. The session must be running and able to accept commands for a snapshot to be created. The session will be terminated after the snapshot is created.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
session_idstringThe unique identifier of the session to snapshot.
snapshot_idstringThe unique identifier of the snapshot to delete.
cursorstringOpaque pagination cursor from a previous response.
limitnumberMaximum number of snapshots to return in the response. Used for pagination.
namestringName for the sandbox. Must be unique per project and URL-safe (alphanumeric, hyphens, underscores).
projectstringThe unique identifier or name of the project to list snapshots for.
slugstringThe Team slug to perform the request on behalf of.
sort_orderstringSort direction for results by creation time. (wire: sortOrder)
teamIdstringThe Team identifier to perform the request on behalf of.
team_idstringThe Team identifier to perform the request on behalf of. (wire: teamId)

SELECT examples

Retrieves detailed information about a specific snapshot, including its creation time, size, expiration date, and the source session it was created from.

SELECT
id,
parent_id,
source_session_id,
created_at,
creation_method,
expires_at,
last_used_at,
region,
regions,
size_bytes,
status,
updated_at
FROM vercel.sandboxes.snapshots
WHERE snapshot_id = '{{ snapshot_id }}' -- required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

INSERT examples

Creates a point-in-time snapshot of a running session's filesystem. Snapshots can be used to quickly restore a session to a previous state or to create new sessions with pre-configured environments. The session must be running and able to accept commands for a snapshot to be created. The session will be terminated after the snapshot is created. Unlike v2, snapshots expire after 7 days when neither the request nor the sandbox configuration specifies an expiration.

INSERT INTO vercel.sandboxes.snapshots (
expiration,
session_id,
team_id,
slug
)
SELECT
{{ expiration }},
'{{ session_id }}',
'{{ team_id }}',
'{{ slug }}'
RETURNING
session,
snapshot
;

DELETE examples

Permanently deletes a snapshot and frees its associated storage. This action cannot be undone. After deletion, the snapshot can no longer be used to create new sessions.

DELETE FROM vercel.sandboxes.snapshots
WHERE snapshot_id = '{{ snapshot_id }}' --required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

Lifecycle Methods

EXEC variables use wire (API) names.

Creates a point-in-time snapshot of a running session's filesystem. Snapshots can be used to quickly restore a session to a previous state or to create new sessions with pre-configured environments. The session must be running and able to accept commands for a snapshot to be created. The session will be terminated after the snapshot is created.

EXEC vercel.sandboxes.snapshots.create_v2
@session_id='{{ session_id }}' --required,
@teamId='{{ teamId }}',
@slug='{{ slug }}'
@@json=
'{
"expiration": {{ expiration }}
}'
;