Write to command stdin
POST
/__remote/api.vercel.com/v2/sandboxes/sessions/{sessionId}/cmd/{cmdId}/stdinWrites 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
application/json
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.
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.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