Skip to content
Docs

Create a directory

POSThttps://api.vercel.com/v2/sandboxes/sessions/{sessionId}/fs/mkdir
Creates a new directory in a session's filesystem. By default, parent directories are created recursively if they don't exist (similar to mkdir -p).
Request
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.sandboxes.createSessionDirectory({
sessionId: "sbx_abc123",
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
requestBody: {
cwd: "/home/vercel-sandbox",
path: "src/components",
},
});
console.log(result);
}
run();
Response
"value"
AuthorizationbearerToken

Default authentication mechanism

sessionIdstringRequired
The unique identifier of the session to create the directory in.
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 directory to create. Can be absolute or relative to the working directory.
recursivebooleanOptional
If true, creates parent directories as needed (like mkdir -p). If false, fails if parent directories do not exist.
200The directory was created successfully.
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