---
title: "Create a directory"
description: "Creates one directory, optionally including missing parent directories."
canonical: "https://www.cool.computer/docs/api-reference/files/create-a-directory"
---
# Create a directory

> Creates one directory, optionally including missing parent directories.

```http
POST https://api.cool.computer/api/computers/{id}/files/mkdir
```

Creates one directory, optionally including missing parent directories. A published site with no VM has no empty folders, so it answers 409 site_has_no_folders: a folder appears there when a file is written or uploaded into it.

## Authorization

- A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.

## Parameters

- `id` (path, string, at least 1 characters, required): The computer's name, such as agent-atlas, or its id (cmp_…). Every caller may use either, the computer's own runtime token included.

## Request body

Required.

- `application/json` (object)
  - `path` (string, at least 1 characters, required)
  - `recursive` (boolean, default false)
  - `mode` (string, pattern `^[0-7]{3,4}$`)
  - `uid` (integer, at least 0)
  - `gid` (integer, at least 0)

## Responses

- `200`: File metadata.
  - `application/json` (object)
    - `name` (string, required)
    - `type` ("file" or "directory" or "symlink", required)
    - `size` (integer, int64, at least 0, required)
    - `mtime` (string, date-time, required)
    - `mode` (string, required)
    - `uid` (integer, at least 0, required)
    - `gid` (integer, at least 0, required)
- `400`: Bad Request.
- `401`: Unauthorized.
- `402`: Payment Required. `pro_required`: this computer has a VM and the account is not Pro, which fences it; a site without a VM works on Free. Start Pro with cool billing upgrade, or fix a lapsed subscription with cool billing portal, or use the Account page.
- `403`: Forbidden.
- `404`: Not Found. `computer_not_found`: the computer does not exist or is not yours. `file_not_found`: the path does not exist on it.
- `409`: Conflict. `already_exists`: the path exists; send recursive=true to accept an existing directory. `not_a_directory`: a parent of the path is a file. `site_has_no_folders`: the computer is a published site with no VM; write or upload a file into the folder instead.
- `413`: Payload Too Large.
- `429`: Too Many Requests. If the problem code is api_request_rate_exceeded, wait for Retry-After seconds; other problem codes describe a separate limit.
- `500`: Internal Server Error.
- `503`: Service Unavailable. `computer_starting` means the computer is starting, or stopped and being started again; wait for Retry-After seconds, then retry. Otherwise inspect the problem code and resolution.
- `default`: A machine-readable API error with a stable code and recovery instruction.

An error is an `application/problem+json` document with a stable `code`; [API errors](/docs/api-reference/errors) says how to handle one.

## Example

```sh
curl -X POST "https://api.cool.computer/api/computers/$PARAM_ID/files/mkdir" \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  --data '{"path":"string"}'
```
