Skip to main content

commands

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

Overview

Namecommands
TypeResource
Idvercel.sandboxes.commands

Fields

The following fields are returned by SELECT queries:

The command data along with the exit code if the command did finish.

NameDatatypeDescription
idstringThe ID of the command. (example: cmd_123a6c5209bc3778245d011443644c8d27dc2c50)
namestringThe name of the command. (example: npm)
session_idstringThe ID of the session associated with the command. (example: sbx_123a6c5209bc3778245d011443644c8d27dc2c50) (wire: sessionId)
argsarrayThe arguments of the command.
cwdstringThe current working directory of the command. (example: /vercel/sandbox)
duration_msnumberDuration of the command execution in milliseconds. (wire: durationMs)
exit_codenumberIf the command did finish, the exit code. (wire: exitCode)
started_atnumberWhen the command was started, in milliseconds since the epoch. (wire: startedAt)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectsession_id, cmd_idwait, team_id, slugRetrieves the current status and details of a command executed in a session. Use the wait parameter to block until the command finishes execution.
listselectsession_idteam_id, slugRetrieves a list of all commands that have been executed in a session, including their current status, exit codes, and execution times, ordered from the most recent to the oldest.
runexecsession_id, cmdId, commandteamId, slugExecutes a shell command inside a running session. The command runs asynchronously and returns immediately with a command ID that can be used to track its progress and retrieve its output. Optionally, use the wait parameter to stream the command status until completion.
killexeccmd_id, session_id, signalteamId, slugSends a signal to terminate a running command in a session. The signal can be used to gracefully stop (SIGTERM) or forcefully kill (SIGKILL) the process. The command must still be running for this operation to succeed.
get_logsexecsession_id, cmd_idteamId, slugStreams the output of a command in real-time using newline-delimited JSON (ND-JSON). Each entry includes the output data and stream type. Stream types include stdout, stderr, and error (for stream failures).

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
cmdIdstringThe unique identifier of the command to stream logs for.
cmd_idstringThe unique identifier of the command to stream logs for.
session_idstringThe unique identifier of the session containing the command.
slugstringThe Team slug to perform the request on behalf of.
teamIdstringThe Team identifier to perform the request on behalf of.
team_idstringThe Team identifier to perform the request on behalf of. (wire: teamId)
waitstringIf set to "true", the request will block until the command finishes execution. Useful for synchronously waiting for command completion.

SELECT examples

Retrieves the current status and details of a command executed in a session. Use the wait parameter to block until the command finishes execution.

SELECT
id,
name,
session_id,
args,
cwd,
duration_ms,
exit_code,
started_at
FROM vercel.sandboxes.commands
WHERE session_id = '{{ session_id }}' -- required
AND cmd_id = '{{ cmd_id }}' -- required
AND wait = '{{ wait }}'
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

Lifecycle Methods

EXEC variables use wire (API) names.

Executes a shell command inside a running session. The command runs asynchronously and returns immediately with a command ID that can be used to track its progress and retrieve its output. Optionally, use the wait parameter to stream the command status until completion.

EXEC vercel.sandboxes.commands.run
@session_id='{{ session_id }}' --required,
@cmdId='{{ cmdId }}' --required,
@teamId='{{ teamId }}',
@slug='{{ slug }}'
@@json=
'{
"command": "{{ command }}",
"args": "{{ args }}",
"cwd": "{{ cwd }}",
"env": "{{ env }}",
"sudo": {{ sudo }},
"wait": {{ wait }},
"logs": {{ logs }},
"timeout": {{ timeout }}
}'
;