> ## Documentation Index
> Fetch the complete documentation index at: https://docs.danubeai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upsert Personal Context

> Write one of your personal context documents by name, creating it when missing

## Overview

Creates or changes the caller's personal context document called `name`. This is what an agent calls to remember something about you (the MCP `update_context` tool uses it). Every change keeps the previous text as a revision, which you can see and restore in [Dashboard > Context](https://danubeai.com/dashboard/context).

Organization context can't be written here. Organization documents are edited by the organization's owners and admins in the dashboard; `/v1/organizations/{org_id}/context/documents` answers `403` to any API key, an admin's included.

**Auth:** API key (`danube-api-key` header) or dashboard session (JWT). An agent writing on your behalf sends `x-danube-via: agent` so the revision is labeled as the agent's; SDKs and scripts leave it off.

## Body Parameters

<ParamField body="name" type="string" required>
  Document name: 1 to 80 letters, digits, spaces, dots, dashes or underscores. `.md` is added when there is no extension.
</ParamField>

<ParamField body="content" type="string" required>
  Markdown. At most 32,000 characters per document. Content that contains a credential (an API key, token or private key) is refused with `400`; store secrets as a credential instead.
</ParamField>

<ParamField body="mode" type="string" default="replace">
  `replace` overwrites the document; `append` adds `content` as a new paragraph at the end
</ParamField>

<ParamField body="expected_version" type="integer">
  The version you read. If the document changed since then, nothing is written and the answer is `409` with the current document in `detail.current`.
</ParamField>

## Response

The document after the write: `id`, `name`, `content`, `version`, `position`, `updated_at`, `updated_via`, `updated_by`, plus `created` (true when the document did not exist before).

## Limits

* 10 documents per layer; a new document past that answers `400`.
* 32,000 characters per document, after an append too.

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.danubeai.com/v1/context/personal/upsert" \
    -H "danube-api-key: YOUR_DANUBE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "notes.md",
      "content": "Prefers weekly summaries on Mondays.",
      "mode": "append"
    }'
  ```

  ```python Python SDK theme={null}
  from danube import DanubeClient

  with DanubeClient(api_key="YOUR_DANUBE_API_KEY") as client:
      doc = client.context.remember("Prefers weekly summaries on Mondays.")
      print(doc.version)
  ```

  ```bash CLI theme={null}
  danube context remember "Prefers weekly summaries on Mondays."
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "id": "77aa...",
    "name": "notes.md",
    "content": "I lead the support team.\n\nPrefers weekly summaries on Mondays.",
    "version": 3,
    "position": 0,
    "updated_at": "2026-09-27T10:15:00Z",
    "updated_via": "api",
    "updated_by": "a8e1...",
    "created": false
  }
  ```
</ResponseExample>

## Related endpoints

| Endpoint                                                                   | Purpose                                                                  |
| -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `POST /v1/context/personal/documents`                                      | Create a document (`name`, `content`)                                    |
| `PUT /v1/context/personal/documents/{id}`                                  | Change `name`, `content` or `position`, with `expected_version`          |
| `DELETE /v1/context/personal/documents/{id}`                               | Delete a document                                                        |
| `GET /v1/context/personal/documents/{id}/revisions`                        | List earlier versions                                                    |
| `POST /v1/context/personal/documents/{id}/revisions/{revision_id}/restore` | Restore one (the restore is itself a new version)                        |
| `PUT /v1/context/timezone`                                                 | Set your IANA timezone (`{"timezone": "Europe/Oslo"}`, or null to clear) |
| `GET /v1/organizations/{org_id}/context/documents`                         | Read the organization's documents (any member)                           |
