# Write a note

`POST /api/v1/vaults/{vault}/knowledge/notes`

Write a note in a vault's Knowledge.

Every field is optional. A note without a title is called “Untitled note”. Without a folder it goes to the first folder of the vault, and a vault without any folder gets one called “General” to hold it.

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.
- `title` (string, optional): The title of the note, up to 255 characters. Markup is stripped.
- `body` (string, optional): The text of the note in Markdown, up to 200,000 characters: # for a heading, - for a bullet, - [ ] for a task, > for a quote, **bold**. Web addresses become links on their own.
- `folder_id` (uuid, optional): The id of a folder of the vault, as the knowledge folders endpoints give it. A folder of another vault answers 404.

## Returns

The knowledge note object that was written.

- `data` (object): The knowledge note.
- `data.type` (string): Always knowledge_note. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.
- `data.id` (string): The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.
- `data.attributes` (object): Everything the record holds.
- `data.attributes.title` (string): The title of the note.
- `data.attributes.folder` (object): The folder the note sits in.
- `data.attributes.folder.id` (uuid): The id of the folder, as the knowledge folders endpoints give it.
- `data.attributes.folder.name` (string): What the folder is called.
- `data.attributes.created_at` (timestamp): When the note was written, as a count of seconds since 1970.
- `data.attributes.updated_at` (timestamp): When it last changed, as a count of seconds, or null.
- `data.attributes.body` (string): The text of the note in Markdown, exactly as written, or null. It is never drawn: raw HTML in it stays text, and the application escapes it when it shows the note.
- `data.attributes.headings` (array): The headings of the text, from the first level to the third, in reading order.
- `data.attributes.headings[]` (object): One heading.
- `data.attributes.headings[].text` (string): What the heading says.
- `data.attributes.headings[].level` (integer): Its level, 1 to 3.
- `data.attributes.headings[].anchor` (string): The anchor the application gives it, to open the note at that heading with links.web followed by # and the anchor.
- `data.links` (object): Where to find this record.
- `data.links.self` (string): The absolute address this record is read from.
- `data.links.web` (string): The note in the application, which opens for somebody signed in rather than for a key. It is the link to give a person.

## 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/notes \
  -X POST \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "title": "Dundies speech",
      "body": "## Best dressed\nPam, again.\n\n- [x] Book Chili's\n- [ ] Engrave the trophies",
      "folder_id": "2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24"
  }'
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/knowledge/notes', {
  method: 'POST',
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    title: 'Dundies speech',
    body: '## Best dressed
Pam, again.

- [x] Book Chili's
- [ ] Engrave the trophies',
    folder_id: '2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24',
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->post('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/knowledge/notes', [
    'title' => 'Dundies speech',
    'body' => '## Best dressed
Pam, again.

- [x] Book Chili's
- [ ] Engrave the trophies',
    'folder_id' => '2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24',
]);
```

## Response

`201`

```json
{
    "data": {
        "type": "knowledge_note",
        "id": "7a2d9e4f-1c63-4b85-9f07-3e6c8a1d5b92",
        "attributes": {
            "title": "Dundies speech",
            "body": "## Best dressed\nPam, again.\n\n- [x] Book Chili's\n- [ ] Engrave the trophies",
            "headings": [
                {
                    "text": "Best dressed",
                    "level": 2,
                    "anchor": "section-best-dressed"
                }
            ],
            "folder": {
                "id": "2b7e4c91-0d5a-4f38-9c16-8e3a7f1b5d24",
                "name": "Office"
            },
            "created_at": 1773331200,
            "updated_at": 1773417600
        },
        "links": {
            "self": "https://my.monicahq.com/api/v1/vaults/dunder-mifflin/knowledge/notes/7a2d9e4f-1c63-4b85-9f07-3e6c8a1d5b92",
            "web": "https://my.monicahq.com/vaults/dunder-mifflin/knowledge/notes/7a2d9e4f-1c63-4b85-9f07-3e6c8a1d5b92"
        }
    }
}
```
