---
title: "Create a directory"
method: POST
path: "/v2/sandboxes/sessions/{sessionId}/fs/mkdir"
tags: ["sandboxes"]
---

# Create a directory

`POST /v2/sandboxes/sessions/{sessionId}/fs/mkdir`

## Request

- Base URL: `https://api.vercel.com`
- URL: `https://api.vercel.com/v2/sandboxes/sessions/{sessionId}/fs/mkdir`
- Auth: HTTP bearer

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`).

## Path parameters

- `sessionId` string, required: The unique identifier of the session to create the directory in.

## Query parameters

- `teamId` string
- `slug` string

## Request body

- object
  - `cwd` string: The base directory for resolving relative paths. If not specified, paths are resolved from the sandbox home directory.
  - `path` string, required: The path of the directory to create. Can be absolute or relative to the working directory.
  - `recursive` boolean: If true, creates parent directories as needed (like `mkdir -p`). If false, fails if parent directories do not exist.

## Response `200`

The directory was created successfully.

- object

## Other responses

- `400`: One of the provided values in the request body is invalid. One of the provided values in the request query is invalid.
- `401`: The request is not authorized.
- `403`: You do not have permission to access this resource.
- `404`
- `410`
- `422`
- `429`

## Changes

- **2026-10-23** `0ab54ee1bd2e`: 1 info
  - removed the non-success response with the status `500`
- **2026-06-11** `14b4658f819e`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/vercel/apis/vercel-api/changes/v2/sandboxes/sessions/:sessionId/fs/mkdir/post.md)

---

[API](https://skmtc.dev/vercel/apis/vercel-api.md) - [All operations](https://skmtc.dev/vercel/apis/vercel-api/llms.txt) - [OpenAPI document](https://skmtc.dev/vercel/apis/vercel-api/revisions/60686c0e1f6a?raw)
