# Update Doc Folder

`PATCH /api/v1/docs/folders/{folderId}`

## Description
Rename a doc folder, move it under another folder, or both. Pass `parentId: null` to move it to the top level. A folder cannot be moved into itself or one of its descendants.

## Parameters

- **folderId** (path) (required) — `string`: The folder ID.

## Request Body

```json
{
  "type": "object",
  "required": [
    "workspaceId"
  ],
  "properties": {
    "workspaceId": {
      "type": "string",
      "description": "The workspace ID."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "New folder name."
    },
    "parentId": {
      "type": [
        "string",
        "null"
      ],
      "description": "New parent folder ID, or `null` for the top level."
    }
  }
}
```

## Responses

### 200 — Folder updated.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Indicates whether the request was successful."
    },
    "data": {
      "type": "object",
      "properties": {
        "folder": {
          "type": "object",
          "description": "A workspace folder used to organize docs.",
          "properties": {
            "id": {
              "type": "string",
              "description": "Folder ID."
            },
            "workspaceId": {
              "type": "string",
              "description": "Owning workspace ID."
            },
            "parentId": {
              "type": [
                "string",
                "null"
              ],
              "description": "Parent folder ID, or null for top-level."
            },
            "name": {
              "type": "string",
              "description": "Display name."
            },
            "isSystem": {
              "type": "boolean",
              "description": "Whether this is a system-managed folder."
            },
            "sortOrder": {
              "type": "integer",
              "description": "Display sort order."
            },
            "color": {
              "type": [
                "string",
                "null"
              ],
              "description": "Optional accent color."
            },
            "createdBy": {
              "type": [
                "string",
                "null"
              ],
              "description": "User ID of the creator."
            },
            "createdAt": {
              "type": "string",
              "format": "date-time"
            },
            "updatedAt": {
              "type": "string",
              "format": "date-time"
            }
          },
          "required": [
            "id",
            "workspaceId",
            "parentId",
            "name",
            "isSystem",
            "sortOrder",
            "createdAt",
            "updatedAt"
          ]
        }
      },
      "description": "Response payload."
    }
  }
}
```

### 400 — Invalid request parameters. Check the details array for specific validation errors.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message describing the validation failure."
    },
    "details": {
      "type": "array",
      "description": "List of specific validation errors with field-level details.",
      "items": {
        "type": "object"
      }
    }
  }
}
```

### 401 — Invalid or missing API key. Ensure the X-API-Key header is set with a valid key.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 403 — Access denied. You do not have permission to access this resource. For audit log endpoints, this requires an Enterprise subscription and organization admin/owner role.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 404 — The requested resource was not found. Verify the ID is correct and belongs to your workspace.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 409 — A sibling folder already has that name (`code: "duplicate_name"`).

### 429 — Rate limit exceeded. Wait for the duration specified in the Retry-After header before retrying.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message with rate limit details."
    }
  }
}
```
