## Rename folder

`PATCH /v1/folders/:id`

Renames a folder. Accepts only the `name` field. To move a folder to a different parent, use [`POST /v1/folders/:id/moveto`](./moveto.md).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Folder ID. List: `GET /v1/folders` |

## Request fields (body)

| Field | Bitrix24 | Type | Required | Description |
|------|----------|-----|:-----:|---------|
| `name` | `NAME` | string | yes | New folder name |

The `parentId` and `code` fields are immutable — passing them returns `400 READONLY_FIELD`. To move a folder to a different parent, use [`POST /v1/folders/:id/moveto`](./moveto.md).

## Examples

### curl — personal key

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

### curl — OAuth application

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

### JavaScript — personal key

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

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

### JavaScript — OAuth application

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

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | object | The folder object after renaming. For all fields, see [Folder fields](./fields.md) |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 9301,
    "name": "Contracts",
    "code": null,
    "storageId": 1,
    "type": "folder",
    "realObjectId": 9301,
    "parentId": 27,
    "deletedType": 0,
    "createdAt": "2026-06-25T12:10:00.000Z",
    "updatedAt": "2026-06-25T12:15:30.000Z",
    "deletedAt": null,
    "createdBy": 1,
    "updatedBy": 1,
    "deletedBy": null,
    "detailUrl": "https://<portal>.bitrix24.com/company/personal/user/1/disk/path/Uploaded files/Contracts"
  }
}
```

## Error response example

400 — attempt to change an immutable field:

```json
{
  "success": false,
  "error": {
    "code": "READONLY_FIELD",
    "message": "Field 'parentId' is read-only and cannot be set"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `READONLY_FIELD` | An immutable field was passed in the body — `parentId` or `code` |
| 404 | `ENTITY_NOT_FOUND` | No folder with the specified `id` |
| 403 | `SCOPE_DENIED` | The API key does not have the `disk` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured portal tokens |

For the full list of common API errors, see [Errors](/docs/errors).

## See also

- [Create folder](/docs/entities/folders/create)
- [Get folder](/docs/entities/folders/get)
- [Delete folder](/docs/entities/folders/delete)
- [Folder fields](/docs/entities/folders/fields)
