> The index of all pages is at https://docs.afffast.com/llms.txt.

# Notes

Write notes on programs, conversions, deals and other objects. Mention team members. Read and change notes with the API.

A note is a short text that a member of your workspace writes on an object. Use notes to talk with your team about a program, a conversion, a deal or a payout. A note can mention other members. A mentioned member gets an email.

You can put a note on these objects: programs, conversions, deals, brands, links, payouts, connections, network accounts, sites, tags and product feeds. Each of these objects has a field `note_count`. It is the number of notes on the object.

## Write a note

Send `POST /v1/notes` with the ID of the object (`subject`) and the text (`body`).

```bash
curl https://api.example.com/v1/notes \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{"subject": "prog_0Yx3kqW7sRzL1nH8aBcD4e", "body": "Ask the network about the new cookie window."}'
```

The text is Markdown. Use 10,000 characters at most. The dashboard shows the text as safe text: HTML in a note is never run.

A dashboard user is the author of a note that they write in the dashboard. An API key is the author of a note that it makes. The field `author` shows the type (`user` or `api_key`), the ID and the name.

## Read the notes of an object

Send `GET /v1/notes?subject=<id>`. The list is newest first. It uses [pagination](https://docs.afffast.com/docs/pagination.md). Use `q` to search the text. A `subject` that does not exist in your workspace and mode gives the error `404`.

## Mention a member

A mention has the form `@[Name](user:<user ID>)` in the text. Send the same IDs in the list `mentions`. Each ID must be a member of your workspace. When you do not send `mentions`, the API reads the mentions from the text.

Each mentioned member gets one email with the text of the note and a link to the object. A member that you mention in a later edit gets an email too. A member that the note mentioned already does not get a second email. The author gets no email for a mention of themselves.

## Who can change a note

- Each member can write a note. An API key needs the scope `notes:write`.
- Only the author can change a note (`PATCH /v1/notes/{id}`).
- The author can delete a note. An owner or an admin can delete any note in the dashboard.
- An API key changes and deletes only its own notes.

## Events

The API sends these [events](https://docs.afffast.com/docs/webhooks.md) to the webhook endpoints that select them:

| Event type     | When                                                                 |
| -------------- | -------------------------------------------------------------------- |
| `note.created` | Someone writes a note.                                               |
| `note.updated` | The author changes a note. `previous_attributes` has the old values. |
| `note.deleted` | Someone deletes a note. `data.object` is the note before the delete. |

A note event is not historic. A [destination or a notification channel](https://docs.afffast.com/docs/destinations.md) can select note events too. A Slack or Telegram message for a note event names the author and the object. It does not have the text of the note.
