---
title: "Create a context folder"
method: POST
path: "/api/v1/context/folders"
tags: ["Context"]
---

# Create a context folder

`POST /api/v1/context/folders`

## Request

- Base URL: `https://app.khotan.com`
- URL: `https://app.khotan.com/api/v1/context/folders`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Creates a folder under an optional parent (omit or null for the organization root). The name must be unique among active sibling folders; a collision responds 409 folder_conflict. An unknown parent responds 404 folder_not_found.

## Request body

- object
  - `name` string, required
  - `parentId` string, nullable: Parent folder; omit or null for the organization root.

## Response `201`

The created folder.

- object
  - `folder` object, required
    - `id` string, required
    - `parentId` string, nullable, required: null at the organization root.
    - `name` string, required
    - `slug` string, required
    - `path` string, required: Slash-joined ancestor slugs.
    - `depth` integer, required: 0 at the organization root.
    - `documentCount` integer, required: Active documents directly in this folder.
    - `createdAt` string, required
    - `updatedAt` string, required

## Other responses

- `400`: The request was malformed or failed validation.
- `401`: Authentication is missing or invalid.
- `404`: The resource was not found.
- `409`: Response.
- `422`: Response.
- `429`: Too many requests; retry after the indicated delay.

---

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