---
title: "Rename or move a context folder"
method: PATCH
path: "/api/v1/context/folders/{id}"
tags: ["Context"]
---

# Rename or move a context folder

`PATCH /api/v1/context/folders/{id}`

## Request

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

Renames the folder when name is provided and moves it when parentId is provided (null moves it to the organization root). Sibling name collisions respond 409 folder_conflict; moving a folder into itself or a descendant responds 422 folder_cycle.

## Path parameters

- `id` string, required

## Request body

- object
  - `name` string
  - `parentId` string, nullable: Pass null to move to the organization root.

## Response `200`

The updated 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)
