Skip to main content

sessions

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

Overview

Namesessions
TypeResource
Idvercel.sandboxes.sessions

Fields

The following fields are returned by SELECT queries:

The session was retrieved successfully.

NameDatatypeDescription
idstringThe unique identifier of the sandbox. (example: sbx_123a6c5209bc3778245d011443644c8d27dc2c50)
project_idstringThe unique identifier of the project associated with this session. (example: prj_123a6c5209bc3778245d011443644c8d27dc2c50) (wire: projectId)
source_snapshot_idstringThe unique identifier of the snapshot associated with this sandbox, if any. (example: snap_123a6c5209bc3778245d011443644c8d27dc2c50) (wire: sourceSnapshotId)
source_sandbox_namestringThe name of the source sandbox. (example: my-sandbox) (wire: sourceSandboxName)
aborted_atnumberThe time when the sandbox was aborted, in milliseconds since the epoch. (wire: abortedAt)
active_cpu_duration_msnumberThe amount of CPU time the sandbox consumed, if available, in milliseconds. This value is only available once the sandbox is stopped, and only if it stopped successfully. (wire: activeCpuDurationMs)
created_atnumberThe time when the sandbox was created, in milliseconds since the epoch. (wire: createdAt)
cwdstringThe working directory of the sandbox. (example: /vercel/sandbox)
durationnumberThe duration of the sandbox in milliseconds.
memorynumberMemory allocated to this sandbox in MB.
network_policyobjectThe network policy applied to this sandbox, if any. (wire: networkPolicy)
network_transferobjectThe quantity of data transfered to and from the sandbox, in bytes. This value is only available once the sandbox is stopped, and only if it stopped successfully. (wire: networkTransfer)
regionstringThe region where the sandbox is hosted. (example: iad1)
requested_atnumberThe time when the sandbox was requested, in milliseconds since the epoch. (wire: requestedAt)
requested_stop_atnumberThe time when the sandbox was requested to stop, in milliseconds since the epoch. (wire: requestedStopAt)
runtimestringThe runtime of the sandbox. (example: node22)
snapshotted_atnumberThe time when a snapshot was requested, in milliseconds since the epoch. (wire: snapshottedAt)
started_atnumberThe time when the sandbox was started, in milliseconds since the epoch. (wire: startedAt)
statusstringThe status of the sandbox. (aborted, failed, pending, running, snapshotting, stopped, stopping) (example: running)
stopped_atnumberThe time when the sandbox was stopped, in milliseconds since the epoch. (wire: stoppedAt)
timeoutnumberThe maximum amount of time the sandbox will run for in milliseconds.
updated_atnumberThe last time the sandbox was updated, in milliseconds since the epoch. (wire: updatedAt)
vcpusnumberNumber of vCPUs allocated to this sandbox.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectsession_idteam_id, slugRetrieves detailed information about a specific session, including its current status, resource configuration, and exposed routes.
listselectproject, name, limit, cursor, sort_order, team_id, slugRetrieves a paginated list of sessions belonging to a specific sandbox. Results are sorted by creation time and paginated using an opaque cursor.
stopexecsession_idteamId, slugStops a running session and releases its allocated resources. All running processes within the session will be terminated. This action cannot be undone. A stopped session cannot be restarted.
extend_timeoutexecsession_id, durationteamId, slugExtends the maximum execution time of a running session. The session must be active and able to accept commands. The total timeout cannot exceed the maximum allowed limit for your account.
update_network_policyexecsession_id, modeteamId, slugReplaces the network access policy of a running session. Use this to control which external hosts the session can communicate with. This is a full replacement. Any previously configured network rules will be overwritten.

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 update the network policy for.
cursorstringOpaque pagination cursor from a previous response.
limitnumberMaximum number of sessions to return in the response. Used for pagination.
namestringFilter sessions by sandbox name. Only sessions belonging to the specified sandbox are returned.
projectstringThe unique identifier or name of the project to list sessions 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 session, including its current status, resource configuration, and exposed routes.

SELECT
id,
project_id,
source_snapshot_id,
source_sandbox_name,
aborted_at,
active_cpu_duration_ms,
created_at,
cwd,
duration,
memory,
network_policy,
network_transfer,
region,
requested_at,
requested_stop_at,
runtime,
snapshotted_at,
started_at,
status,
stopped_at,
timeout,
updated_at,
vcpus
FROM vercel.sandboxes.sessions
WHERE session_id = '{{ session_id }}' -- required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

Lifecycle Methods

EXEC variables use wire (API) names.

Stops a running session and releases its allocated resources. All running processes within the session will be terminated. This action cannot be undone. A stopped session cannot be restarted.

EXEC vercel.sandboxes.sessions.stop
@session_id='{{ session_id }}' --required,
@teamId='{{ teamId }}',
@slug='{{ slug }}'
;