sandboxes

Write to command stdin

Changed on

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.

post/v2/sandboxes/sessions/{sessionId}/cmd/{cmdId}/stdin

Request

  • Base URL: https://api.vercel.com
  • URL: https://api.vercel.com/v2/sandboxes/sessions/{sessionId}/cmd/{cmdId}/stdin
  • Auth: HTTP bearer

Path parameters

cmdIdstring required

The unique identifier of the command to write to.

Example:cmd_abc123
sessionIdstring required

The unique identifier of the session containing the command.

Example:sbx_abc123

Query parameters

teamIdstring
Example:team_1a2b3c4d5e6f7g8h9i0j1k2l

The Team identifier to perform the request on behalf of.

slugstring
Example:my-team-url-slug

The Team slug to perform the request on behalf of.

Request body

datastring

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.

offsetinteger

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.

closeboolean

If true, closes the command stdin after writing data. Use this for commands that wait for end of input.

Example request

{
  "data": "aGVsbG8K"
}

Response

The data was written to the command's stdin.

bytesWrittennumber

Example response

{
  "command": {
    "args": [
      "run",
      "build"
    ],
    "cwd": "/vercel/sandbox",
    "durationMs": 1234,
    "id": "cmd_123a6c5209bc3778245d011443644c8d27dc2c50",
    "name": "npm",
    "sessionId": "sbx_123a6c5209bc3778245d011443644c8d27dc2c50",
    "startedAt": 1673123456789
  }
}

Changes