# Rename or move a folder

`PUT /api/v1/vaults/{vault}/knowledge/folders/{folder}`

Rename a folder, move it among the folders of the vault, or both.

A field left out keeps its value, and a name left empty once markup is stripped keeps the one the folder had. The other folders shift so the positions run from 1 without a gap.

The change is written to the account log.

## Parameters

- `vault` (string, required): The vault, named either by the readable name it reports as slug or by its id. A vault of another account answers 404.
- `folder` (uuid, required): The id of the folder. A folder of another vault or of another account answers 404.
- `name` (string, optional): The new name, up to 255 characters.
- `position` (integer, optional): Where the folder goes, 1 for first. A number past the end puts it last.

## Returns

The knowledge folder object as it now reads. A folder of another vault or of another account answers 404.

- `data` (object): The knowledge folder.
- `data.type` (string): Always knowledge_folder.
- `data.id` (string): The id of the folder, which every address naming it takes.
- `data.attributes` (object): Everything the folder holds.
- `data.attributes.name` (string): What the folder is called.
- `data.attributes.position` (integer): Where the folder stands among the folders of the vault, from 1.
- `data.attributes.note_count` (integer): How many notes the folder holds.
- `data.attributes.list_count` (integer): How many lists the folder holds.
- `data.attributes.notes` (array): The notes the folder holds.
- `data.attributes.notes[]` (object): One note.
- `data.attributes.notes[].id` (uuid): The id of the note, which the notes endpoints take.
- `data.attributes.notes[].title` (string): The title of the note.
- `data.attributes.lists` (array): The lists the folder holds.
- `data.attributes.lists[]` (object): One list.
- `data.attributes.lists[].id` (uuid): The id of the list, which the lists endpoints take.
- `data.attributes.lists[].title` (string): The title of the list.
- `data.attributes.created_at` (timestamp): When the folder was added, as a count of seconds since 1970.
- `data.attributes.updated_at` (timestamp): When it last changed, as a count of seconds, or null.
- `data.links` (object): Where to find the folder. A folder is not read on its own, so it has no address of its own.
- `data.links.web` (string): The Knowledge screen of the vault in the application, which opens for somebody signed in rather than for a key.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://my.monicahq.com/api/v1/vaults/dunder-mifflin/knowledge/folders/2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24 \
  -X PUT \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "name": "Office",
      "position": 1
  }'
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/knowledge/folders/2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24', {
  method: 'PUT',
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    name: 'Office',
    position: 1,
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->put('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/knowledge/folders/2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24', [
    'name' => 'Office',
    'position' => 1,
]);
```

## Response

`200`

```json
{
    "data": {
        "type": "knowledge_folder",
        "id": "2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24",
        "attributes": {
            "name": "Office",
            "position": 1,
            "note_count": 1,
            "list_count": 1,
            "notes": [
                {
                    "id": "7a2d9e4f-1c63-4b85-9f07-3e6c8a1d5b92",
                    "title": "Dundies speech"
                }
            ],
            "lists": [
                {
                    "id": "e94b1c37-6a28-4d50-8b3f-2c7e9a4d1f68",
                    "title": "Paper clients"
                }
            ],
            "created_at": 1773331200,
            "updated_at": 1773331200
        },
        "links": {
            "web": "https://my.monicahq.com/vaults/dunder-mifflin/knowledge"
        }
    }
}
```
