---
title: "Write an item"
method: PUT
path: "/v1/memory/collections/{collection}/items/{key}"
tags: ["Memory"]
---

# Write an item

`PUT /v1/memory/collections/{collection}/items/{key}`

## Request

- Base URL: `https://api.zavu.dev`
- URL: `https://api.zavu.dev/v1/memory/collections/{collection}/items/{key}`
- Auth: HTTP bearer

Store a JSON document under a key. Creates the collection if it does not exist — with **no indexes**, which `query` then cannot use. Declare indexes with `POST /v1/memory/collections` first if you need them.

This replaces the whole document; it does not merge. Pass `If-Match` with the revision from a previous read to make the write conditional.

## Path parameters

- `collection` string, required
- `key` string, required

## Query parameters

- `scope` string: Scope as a query-string value: `contact:<contactId>`, `conversation:<conversationId>`, the literal `project`, or omitted for project scope. Only the SHAPE of the id is validated, never its existence — the partition already carries your project, so an id that matches nothing simply addresses an empty scope rather than returning 404.

## Headers

- `If-Match` string

## Request body

- MemoryItemPutRequest
  - `value` unknown, required
  - `ttlSeconds` integer: Overrides the collection's `defaultTtlSeconds` for this item.

## Response `200`

Existing item replaced.

- object
  - `item` MemoryItem, required: One JSON document in a collection.
    - `key` string, required
    - `value` unknown
    - `rev` integer, required: Revision, incremented on every write. Pass it as `If-Match` on a later write to make that write conditional.
    - `createdAt` string, date-time, required
    - `updatedAt` string, date-time, required
    - `expiresAt` string, date-time

## Other responses

- `201`: Item created.
- `400`: Invalid key, scope, TTL, or `If-Match`.
- `401`: Unauthorized.
- `409`: `revision_conflict`: the item changed since the revision in `If-Match`. Re-read it and retry.
- `413`: `document_too_large`: the serialized value exceeds 200KB. Memory is not a blob store; put media in file storage and keep the URL here.
- `429`: The plan's monthly unit quota is spent.

## Changes

> 80 revisions in range; 1 not diffed.

- **2026-08-26** `6e8c555e1104`: 1 info
  - removed the non-success response with the status `403`
- **2026-08-26** `83caf7165722`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/zavudev/apis/zavu-unified-messaging-layer-api/changes/v1/memory/collections/:collection/items/:key/put.md)

---

[API](https://skmtc.dev/zavudev/apis/zavu-unified-messaging-layer-api.md) - [All operations](https://skmtc.dev/zavudev/apis/zavu-unified-messaging-layer-api/llms.txt) - [OpenAPI document](https://skmtc.dev/zavudev/apis/zavu-unified-messaging-layer-api/revisions/75bc777b0ffb?raw)
