Sandboxes

Write a file into the sandbox. Accepts two body shapes — the SDK picks one based on `Content-Type`:

  • application/json (temps-native): {path, contents_b64, mode} — one file, base64-encoded.
  • application/gzip (@vercel/sandbox): a gzipped tarball of one-or-more entries, with the target extract dir carried in the x-cwd header. The SDK's writeFile and writeFiles both post here; they differ only in how many entries the tarball contains.

Why merge them on one route: the SDK is hardcoded to POST /fs/write, so splitting tar uploads onto a separate path would force us to break SDK compat. Instead we dispatch on Content-Type, preserve JSON for native callers, and add tar for SDK callers.

post/v1/sandboxes/{id}/fs/write

Request

  • Base URL: /api (relative, and the document was published on a file host, not at the API’s origin)
  • URL: /api/v1/sandboxes/{id}/fs/write
  • Auth: HTTP bearer

Path parameters

idstring required

Request body

contents_b64string required

File contents, base64-encoded. Required — lets callers ship binary data over JSON without charset games.

modeinteger nullable

Unix permission mask (e.g. 0o644). Defaults to 0o644 when absent.

pathstring required

Absolute path inside the sandbox. Must start with /.

Response

File(s) written

Changes

No recorded changes to this operation across all 53 revisions of this API.