## Update folder

`PATCH /v1/sites/:id/folders/:folderId`

Changes the name, symbolic code, parent folder or home page of a folder. Pass only the fields you change.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Site identifier — a positive integer. List: [`GET /v1/sites`](/docs/entities/sites/list) |
| `folderId` (path) | number | yes | Identifier of a folder on this site. List: [`GET /v1/sites/:id/folders`](/docs/entities/sites/folders/list) |
| `scope` (query) | string | no | Internal landing scope: `KNOWLEDGE` / `GROUP` / `MAINPAGE`. Specify it if the site belongs to the corresponding scope. Otherwise `404 ENTITY_NOT_FOUND` is returned |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `title` | string | no | New folder name, a non-empty string |
| `code` | string | no | New folder symbolic code — the URL segment of its pages |
| `parentId` | number \| null | no | Identifier of the new parent folder on this site. List: [`GET /v1/sites/:id/folders`](/docs/entities/sites/folders/list). `null` moves the folder to the site root. If the field is omitted, the folder keeps its current parent |
| `indexPageId` | number \| null | no | Identifier of the folder home page — a page of the same site. List: [`GET /v1/pages?filter[siteId]=:id`](/docs/entities/pages/list). `null` clears the assignment |

Pass at least one field.

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/sites/109/folders/109" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"indexPageId": 1073}'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/sites/109/folders/109" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"indexPageId": 1073}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/109/folders/109', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ indexPageId: 1073 }),
})

const { success, data } = await res.json()
console.log('Folder home page:', data.indexPageId)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/109/folders/109', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ indexPageId: 1073 }),
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` on success |
| `data.id` | number | Folder identifier |
| `data.parentId` | number \| null | Parent folder identifier. `null` — the folder is at the site root |
| `data.siteId` | number | Site identifier |
| `data.indexPageId` | number \| null | Identifier of the folder home page — a page from [`GET /v1/pages`](/docs/entities/pages/list). `null` when not assigned |
| `data.active` | boolean | Whether the folder is published |
| `data.deleted` | boolean | Whether the folder is in the trash |
| `data.title` | string | Folder name |
| `data.code` | string | Folder symbolic code — the URL segment of its pages |
| `data.createdById` | number \| null | Identifier of the user who created the folder. List: [`GET /v1/users`](/docs/entities/users/list) |
| `data.modifiedById` | number \| null | Identifier of the user who last modified the folder |
| `data.dateCreate` | string \| null | Creation date in ISO 8601 without a time zone, in the Bitrix24 account's local time, e.g. `2026-10-16T11:44:24` |
| `data.dateModify` | string \| null | Last modification date in the same format |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 109,
    "parentId": null,
    "siteId": 109,
    "indexPageId": 1073,
    "active": false,
    "deleted": false,
    "title": "Docs test catalog",
    "code": "docstestcatalog",
    "createdById": 1317,
    "modifiedById": 1317,
    "dateCreate": "2026-10-16T11:44:24",
    "dateModify": "2026-10-16T11:45:06"
  }
}
```

## Error response example

404 — parent folder not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Parent folder not found in this site or not visible"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `MISSING_REQUIRED_FIELDS` | The request body is empty or not an object |
| 400 | `READONLY_FIELD` | The body contains a read-only field: `id`, `siteId`, `active`, `deleted`, `createdById`, `modifiedById`, `dateCreate`, `dateModify` |
| 400 | `INVALID_PARAMS` | The body contains a field other than `title`, `code`, `parentId`, `indexPageId` |
| 400 | `INVALID_PARAMS` | `title` is empty, `title` or `code` is not a string, `parentId` or `indexPageId` is neither a positive integer nor `null` |
| 400 | `INVALID_PARAMS` | `id` or `folderId` is not a positive integer |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 404 | `ENTITY_NOT_FOUND` | No site with this `id`, the site is not accessible to the key's user, or it belongs to a different `scope` |
| 404 | `ENTITY_NOT_FOUND` | No folder with this `folderId` on this site, or it is not accessible |
| 404 | `ENTITY_NOT_FOUND` | The `parentId` folder does not exist on this site or is not accessible |
| 404 | `ENTITY_NOT_FOUND` | The folder was not found after the operation: a concurrent request moved or deleted it |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the change, for example `indexPageId` points to a missing page or a page of another site. The reason is in `message` |
| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is unavailable on this Bitrix24 account. Ask a Bitrix24 account administrator to enable it — until then a retry returns the same refusal |
| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denied access: the key's user is not an administrator, or the feature is unavailable on the Bitrix24 account |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The API key is read-only |
| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |

The full list of common API errors — [Errors](/docs/errors).

## Known specifics

- **Assigning a home page does not move the page into the folder.** After `indexPageId` is set, the page's `folderId` in [`GET /v1/pages/:id`](/docs/entities/pages/get) stays the same.

## See also

- [List site folders](/docs/entities/sites/folders/list)
- [Create folder](/docs/entities/sites/folders/create)
- [Get a page](/docs/entities/pages/get)
