# Create a folder (/reference/api/folders/create-folder)

```json
[
  {
    "method": "POST",
    "path": "/api/v1/folders",
    "operationId": "createFolder",
    "tags": [
      "Folders"
    ],
    "summary": "Create a folder",
    "description": "Creates a folder. Omit `id` to have one generated; pass `documentIds` to move documents into it in the same step.",
    "x-required-scope": "documents:write",
    "security": [
      {
        "oauth": [
          "documents:write"
        ]
      },
      {
        "sessionCookie": []
      },
      {
        "secureSessionCookie": []
      }
    ],
    "responses": {
      "201": {
        "description": "Created folder.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Folder"
            }
          }
        },
        "headers": {
          "Location": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "429": {
        "description": "Compute admission or usage is limited.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds until retry.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      },
      "default": {
        "description": "Request failed. Inspect error.code and error.message.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "requestBody": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9-]{1,100}$"
              },
              "name": {
                "type": "string",
                "minLength": 1
              },
              "documentIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "maxItems": 200
              }
            },
            "required": [
              "name"
            ]
          },
          "examples": {
            "folder": {
              "summary": "New folder",
              "value": {
                "name": "Research",
                "documentIds": [
                  "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
                ]
              }
            }
          }
        }
      }
    }
  }
]
```

## Components

```json
{
  "#/components/schemas/Error": {
    "type": "object",
    "properties": {
      "error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryAfterMs": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    },
    "required": [
      "error"
    ]
  },
  "#/components/schemas/Folder": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-zA-Z0-9-]{1,100}$"
      },
      "name": {
        "type": "string"
      },
      "position": {
        "type": "integer"
      },
      "createdAt": {
        "type": "number"
      },
      "updatedAt": {
        "type": "number"
      }
    },
    "required": [
      "id",
      "name",
      "position",
      "createdAt",
      "updatedAt"
    ]
  }
}
```