# Write project memory from meetings and agents

A project's memory is a set of Markdown entries in directories. Meetings, automations and agents write entries by path; people read and search them in Youniton.

## The model

- An **entry** is one Markdown text (CommonMark) at a **path** in its project, for example `meetings/2026-11-20 kickoff.md`. It is a database record, not a file.
- A **directory** is a record too. It can be empty. A write creates the missing parent directories.
- Each entry keeps its **source**: `person`, `meeting` or `agent`, with a name for a meeting or an agent. Youniton shows it as a badge, for example *Agent · Atlas coding agent*. `source` is the first write's; `lastSource` is the last write's.
- There is no version history: an edit replaces the body. `version` exists only for `ETag` and `If-Match`.

## Before you start

Create a [personal token](https://docs.youniton.com/api/authentication.md#personal-tokens) with `memory:read` and `memory:write`. The member needs the rights "Memory read" and "Memory write" on the project; by default Admins, Product managers and Developers have "Memory write".

## Write by path

1. **PUT the entry**

   *PUT /projects/{projectKey}/memory/entries/by-path*

   **curl**

   ```bash
   curl -X PUT "https://app.youniton.example/api/v1/projects/ORB/memory/entries/by-path?path=agents/notes/test" \
     -H "Authorization: Bearer $YOUNITON_TOKEN" -H "Content-Type: application/json" \
     -d '{"body": "# Notes\n\nWritten by the agent.", "source": {"kind": "agent", "name": "Atlas coding agent"}}'
   # 201 on the first call: data.path = "agents/notes/test.md" (".md" is added);
   # the directories agents and agents/notes are created
   ```

   **JavaScript**

   ```js
   async function writeMemory(projectKey, path, markdown, source) {
     const url = new URL(`https://app.youniton.example/api/v1/projects/${projectKey}/memory/entries/by-path`);
     url.searchParams.set("path", path);
     const res = await fetch(url, {
       method: "PUT",
       headers: { Authorization: `Bearer ${process.env.YOUNITON_TOKEN}`, "Content-Type": "application/json" },
       body: JSON.stringify({ body: markdown, source }),
     });
     if (!res.ok) throw new Error((await res.json()).code);
     return res.json(); // { data: {...entry}, meta: { outcome: "created" | "updated" | "unchanged" } }
   }

   await writeMemory("ORB", "meetings/2026-11-20 kickoff", "# Kickoff\n\n- Scope agreed", { kind: "meeting", name: "Kickoff call" });
   ```

   **Python**

   ```python
   def write_memory(project_key, path, markdown, source):
       res = requests.put(
           f"https://app.youniton.example/api/v1/projects/{project_key}/memory/entries/by-path",
           params={"path": path},
           headers={"Authorization": f"Bearer {os.environ['YOUNITON_TOKEN']}"},
           json={"body": markdown, "source": source},
       )
       res.raise_for_status()
       return res.json()["meta"]["outcome"]

   write_memory("ORB", "meetings/2026-11-20 kickoff", "# Kickoff\n\n- Scope agreed", {"kind": "meeting", "name": "Kickoff call"})
   ```

   **PHP**

   ```php
   <?php
   $res = $client->put('https://app.youniton.example/api/v1/projects/ORB/memory/entries/by-path', [
       'query' => ['path' => 'meetings/2026-11-20 kickoff'],
       'headers' => ['Authorization' => 'Bearer ' . getenv('YOUNITON_TOKEN')],
       'json' => ['body' => "# Kickoff\n\n- Scope agreed", 'source' => ['kind' => 'meeting', 'name' => 'Kickoff call']],
   ]);
   ```

   [`PUT /projects/{projectKey}/memory/entries/by-path`](https://docs.youniton.com/api/reference/memory.md#upsertMemoryEntryByPath)

2. **Repeat it safely**

   The same body again changes nothing: `200` with `meta.outcome` `unchanged`. A new body replaces the old one: `200` with `updated`. So a meeting automation can send its notes again after an error.

   `If-Match` is optional here. Send it when you must not overwrite a change by a person: a stale version answers `412`.

3. **Read it back**

   *GET /projects/{projectKey}/memory/entries/by-path*

   ```bash
   curl "https://app.youniton.example/api/v1/projects/ORB/memory/entries/by-path?path=agents/notes/test.md" \
     -H "Authorization: Bearer $YOUNITON_TOKEN"
   ```

   [`GET /projects/{projectKey}/memory/entries/by-path`](https://docs.youniton.com/api/reference/memory.md#getMemoryEntryByPath)

## Path rules

- Youniton adds `.md` to a name without it and changes `.markdown` to `.md`. `Testing by boris` and `Testing by boris.md` are the same entry.
- A path is unique in its project without regard to letter case.
- A segment has 1–80 characters: letters, digits, space, `.` `_` `-` `(` `)`. It does not start or end with a space or a dot.
- A path has at most 8 directories and 512 characters. One leading `/` is removed.
- A path that breaks a rule answers `422 memory.path_invalid`.

## The body

- CommonMark text in UTF-8, with no NUL and no control character other than tab, LF and CR. An empty body is valid.
- At most the tenant setting `memory.entries.maxBytes` (default 1 MiB): `422 memory.body_too_large`.
- Raw HTML stays text. Youniton never shows it as HTML.

## The source

A write with a personal token can set any source. A meeting automation sends `{"kind": "meeting", "name": "…"}`; an agent sends `{"kind": "agent", "name": "…"}`. The name is required for `meeting` and `agent` (1–120 characters) and absent for `person`. A write from the Youniton app is always `person`.

## More operations

- [`GET /projects/{projectKey}/memory/entries`](https://docs.youniton.com/api/reference/memory.md#listMemoryEntries)List or search the project's memory entries
- [`POST /projects/{projectKey}/memory/entries`](https://docs.youniton.com/api/reference/memory.md#createMemoryEntry)Create an entry at a new path
- [`GET /memory/entries/{entryId}`](https://docs.youniton.com/api/reference/memory.md#getMemoryEntry)One entry with its body
- [`PATCH /memory/entries/{entryId}`](https://docs.youniton.com/api/reference/memory.md#changeMemoryEntry)Replace the body and/or move the entry to a new path
- [`DELETE /memory/entries/{entryId}`](https://docs.youniton.com/api/reference/memory.md#deleteMemoryEntry)Delete an entry for good
- [`GET /projects/{projectKey}/memory/directories`](https://docs.youniton.com/api/reference/memory.md#listMemoryDirectories)All directories of the project's memory
- [`POST /projects/{projectKey}/memory/directories`](https://docs.youniton.com/api/reference/memory.md#createMemoryDirectory)Create a directory (and its missing parents)
- [`PATCH /memory/directories/{directoryId}`](https://docs.youniton.com/api/reference/memory.md#moveMemoryDirectory)Rename or move a directory with its contents
- [`DELETE /memory/directories/{directoryId}`](https://docs.youniton.com/api/reference/memory.md#deleteMemoryDirectory)Delete a directory — an empty one, or with everything inside it when recursive

- Search with `q` (words of the path, the title or the body), filter by `source` or `directory`, and sort by `path` or `updated`.
- `PATCH` and `DELETE` need `If-Match`. A delete is for good: there is no trash.
- A directory with entries is not deleted (`409 memory.directory_not_empty`) unless you send `?recursive=true`.
- A project holds at most `memory.entries.perProject` entries (default 5,000) and `memory.directories.perProject` directories (default 1,000): `409 limit.reached`.
- The `.md` file upload is for the Youniton app only; a token uses the JSON operations.

> **Agent identities**
>
> An agent can also write with its own agent identity instead of a member's token. The author is then the identity. Read [Coding agents & MCP](https://docs.youniton.com/api/tools/coding-agents-mcp.md).
