Skip to content
Docs

Write to command stdin

POST/__remote/api.vercel.com/v2/sandboxes/sessions/{sessionId}/cmd/{cmdId}/stdin
Writes data to the stdin of a running command, and optionally closes it. The command must have been started with attachStdin set to true. Writes are applied in the order they are received. Send them one at a time to keep the data in order. A write returns once the command has accepted the data, and fails with a 504 after 30 seconds if the command is not reading stdin. Each write counts against the sandbox control plane rate limit, so batch small writes where possible. Set offset to the position in stdin where data starts to make a request safe to resend, for example after a 502 or 504: bytes the command has already received are skipped, and an offset past them fails with a 409. The response returns bytesWritten, the total written so far, and a 504 includes it in the error when the sandbox reports it. A request with no data and no close writes nothing and returns it.
Request
import { Edgenivo } from "@vercel/sdk";
const vercel = new Edgenivo({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.sandboxes.writeSessionCommandStdin({
cmdId: "cmd_abc123",
sessionId: "sbx_abc123",
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
requestBody: {
data: "aGVsbG8K",
offset: 0,
},
});
console.log(result);
}
run();
Response
{
"bytesWritten": "123",
"command": {
"args": [],
"cwd": "/vercel/sandbox",
"durationMs": "1234",
"exitCode": "0",
"id": "cmd_123a6c5209bc3778245d011443644c8d27dc2c50",
"name": "npm",
"sessionId": "sbx_123a6c5209bc3778245d011443644c8d27dc2c50",
"startedAt": "1673123456789"
}
}
AuthorizationbearerToken

Default authentication mechanism

cmdIdstringRequired
The unique identifier of the command to write to.
sessionIdstringRequired
The unique identifier of the session containing the command.
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
datastringOptional
Base64-encoded bytes to write to the command stdin. The request body is limited to 1 MB, so send at most about 700 KB of data per request.
offsetintegerOptional
The position in the command stdin where data starts. Bytes before the total already written are skipped, so a resent request does not write them twice. Fails with 409 if it is past the bytes written so far. Without it, data is appended.
closebooleanOptional
If true, closes the command stdin after writing data. Use this for commands that wait for end of input.
200The data was written to the command's stdin.
bytesWrittennumberOptional
commandobjectRequired
This object represents a command run in a Edgenivo Sandbox session (v2 API).
400One of the provided values in the request body is invalid. One of the provided values in the request query is invalid.
401The request is not authorized.
403You do not have permission to access this resource.
404Error
409Error
410Error
422Error
429Error
502Error
504Error