Skip to content
Docs

Read a file

POSThttps://api.vercel.com/v2/sandboxes/sessions/{sessionId}/fs/read
Downloads the contents of a file from a session's filesystem. The file content is returned as a binary stream with appropriate Content-Disposition headers for file download.
https://api.vercel.com/v2/sandboxes/sessions/{sessionId}/fs/read
const response = await fetch('https://api.vercel.com/v2/sandboxes/sessions/sessionId/fs/read?teamId=string&slug=string', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"cwd": "/home/vercel-sandbox",
"path": "dist/agent-output.md"
}),
});
const data = await response.json();
console.log(data);
Response
"string"
AuthorizationbearerToken

Default authentication mechanism

sessionIdstringRequired
The unique identifier of the session to read the file from.
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
cwdstringOptional
The base directory for resolving relative paths. If not specified, paths are resolved from the sandbox home directory.
pathstringRequired
The path of the file to read. Can be absolute or relative to the working directory.
200Success
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
410Error
422Error
429Error
500Error