---
title: "Upload (or replace) the mailbox's `.mv2` memory file"
method: POST
path: "/v1/mailboxes/{mailbox_id}/memory/upload"
tags: ["memory"]
---

# Upload (or replace) the mailbox's \`.mv2\` memory file

`POST /v1/mailboxes/{mailbox_id}/memory/upload`

## Request

- Base URL: `https://mbag.ai/api`
- URL: `https://mbag.ai/api/v1/mailboxes/{mailbox_id}/memory/upload`
- Auth: HTTP bearer

Upserts by `storage_key` (one file per mailbox); overwrites any existing file and metadata row.

## Path parameters

- `mailbox_id` integer, required

## Response `200`

Stored.

- MemoryMetadataResponse
  - `checksum_sha256` string, required
  - `customer_id` integer, required
  - `file_size` integer, required
  - `last_modified` string, date-time, required
  - `mailbox_id` integer, required
  - `storage_key` string, required

## Other responses

- `400`: Malformed multipart body, or no `file` field present. Plain-text body.
- `401`: Missing or invalid credential, raised by the `ApiKeyAuth` extractor (`backend/src/api_keys.rs`) before the handler runs: no `Authorization` header, a non-`Bearer` scheme, a key that doesn't hash-match any row, or a key whose status isn't `active`. A header that isn't valid UTF-8, has no scheme token, or has `Bearer` with no key value returns 400 with this same JSON shape instead of 401.
- `404`: Mailbox not found (or not owned by the caller). Plain-text body.
- `500`: Database error checking mailbox ownership or upserting the metadata row. Plain-text body.
- `502`: Object storage error writing the file. Plain-text body.

---

[API](https://skmtc.dev/mailbuttons/apis/mailbuttons-agent-mail-api.md) · [All operations](https://skmtc.dev/mailbuttons/apis/mailbuttons-agent-mail-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mailbuttons/apis/mailbuttons-agent-mail-api/revisions/fe2761823978?raw)
