# MakeDir (/docs/api-reference/filesystem/makedir)

<!-- agent-signals: reading_time_min: 4 · est_tokens: 2348 · updated: 2026-07-30 -->
Related: [Download a file](/docs/api-reference/filesystem/download-a-file.md), [Upload a file and ensure the parent directories exist. If the file exists, it will be overwritten.](/docs/api-reference/filesystem/upload-a-file-and-ensure-the-parent-directories-exist-if-the-file-exists-it-will-be-overwritten.md), [CreateWatcher](/docs/api-reference/filesystem/createwatcher.md), [GetWatcherEvents](/docs/api-reference/filesystem/getwatcherevents.md), [ListDir](/docs/api-reference/filesystem/listdir.md), [Move](/docs/api-reference/filesystem/move.md)

# MakeDir

`POST /filesystem.Filesystem/MakeDir`

MakeDir

## OpenAPI

```json
{
  "security": [
    {
      "SandboxAccessTokenAuth": [],
      "SandboxUserAuth": []
    }
  ],
  "parameters": [
    {
      "name": "E2b-Sandbox-Id",
      "in": "header",
      "required": true,
      "description": "Identifier of the target sandbox. Routes the request to that sandbox's envd over the shared sandbox host.",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "E2b-Sandbox-Port",
      "in": "header",
      "required": true,
      "description": "Port envd listens on inside the sandbox (default 49983).",
      "schema": {
        "type": "integer",
        "default": 49983
      }
    },
    {
      "name": "Connect-Protocol-Version",
      "in": "header",
      "required": true,
      "schema": {
        "type": "number",
        "title": "Connect-Protocol-Version",
        "description": "Define the version of the Connect protocol",
        "const": 1
      }
    },
    {
      "name": "Connect-Timeout-Ms",
      "in": "header",
      "schema": {
        "type": "number",
        "title": "Connect-Timeout-Ms",
        "description": "Define the timeout, in ms"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "path": {
              "type": "string",
              "title": "path"
            }
          },
          "title": "MakeDirRequest",
          "additionalProperties": false
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "Success",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "entry": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "title": "name"
                  },
                  "type": {
                    "type": "string",
                    "title": "FileType",
                    "enum": [
                      "FILE_TYPE_UNSPECIFIED",
                      "FILE_TYPE_FILE",
                      "FILE_TYPE_DIRECTORY"
                    ]
                  },
                  "path": {
                    "type": "string",
                    "title": "path"
                  },
                  "size": {
                    "type": [
                      "integer",
                      "string"
                    ],
                    "title": "size",
                    "format": "int64",
                    "description": "File size in bytes. Encoded as string for values exceeding JSON number precision (int64)."
                  },
                  "mode": {
                    "type": "integer",
                    "title": "mode"
                  },
                  "permissions": {
                    "type": "string",
                    "title": "permissions"
                  },
                  "owner": {
                    "type": "string",
                    "title": "owner"
                  },
                  "group": {
                    "type": "string",
                    "title": "group"
                  },
                  "modifiedTime": {
                    "type": "string",
                    "examples": [
                      "2023-01-15T01:30:15.01Z",
                      "2024-12-25T12:00:00Z"
                    ],
                    "format": "date-time",
                    "description": "A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are \"smeared\" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n     Timestamp timestamp;\n     timestamp.set_seconds(time(NULL));\n     timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n     struct timeval tv;\n     gettimeofday(&tv, NULL);\n\n     Timestamp timestamp;\n     timestamp.set_seconds(tv.tv_sec);\n     timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n     FILETIME ft;\n     GetSystemTimeAsFileTime(&ft);\n     UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n     // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n     // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n     Timestamp timestamp;\n     timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n     timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n     long millis = System.currentTimeMillis();\n\n     Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n         .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n Example 5: Compute Timestamp from Java `Instant.now()`.\n\n     Instant now = Instant.now();\n\n     Timestamp timestamp =\n         Timestamp.newBuilder().setSeconds(now.getEpochSecond())\n             .setNanos(now.getNano()).build();\n\n Example 6: Compute Timestamp from current time in Python.\n\n     timestamp = Timestamp()\n     timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is \"{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z\"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The \"Z\" suffix indicates the timezone (\"UTC\"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n \"Z\") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, \"2017-01-15T01:30:15.01Z\" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use\n the Joda Time's [`ISODateTimeFormat.dateTime()`](\n http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()\n ) to obtain a formatter capable of generating timestamps in this format."
                  },
                  "symlinkTarget": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "title": "symlink_target",
                    "description": "If the entry is a symlink, this field contains the target of the symlink."
                  },
                  "metadata": {
                    "type": "object",
                    "title": "metadata",
                    "additionalProperties": {
                      "type": "string",
                      "title": "value"
                    },
                    "description": "User-defined metadata stored as extended attributes (xattrs) on the file.\n Keys live under the `user.e2b.` xattr namespace; the prefix is stripped here.\n Plain `user.*` xattrs written by other tooling are not reflected."
                  }
                },
                "title": "EntryInfo",
                "additionalProperties": false
              }
            },
            "title": "MakeDirResponse",
            "additionalProperties": false
          }
        }
      }
    },
    "502": {
      "description": "Sandbox not found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "sandboxID",
              "message",
              "code"
            ],
            "properties": {
              "message": {
                "type": "string",
                "description": "Error message"
              },
              "code": {
                "type": "integer",
                "description": "Error code"
              },
              "sandboxID": {
                "type": "string",
                "description": "Identifier of the sandbox"
              }
            }
          }
        }
      }
    }
  }
}
```
