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

# Batch Update

> PATCH /v1/memories/batch — Update multiple memories in a single request.

<Snippet file="snippets/x402-callout.mdx" />

**Price:** \$0.005 USDC

Update multiple memories at once. Each update object must include the memory `id` and at least one field to change. If `content` is changed on any memory, its embedding is regenerated.

## Request Body

<ParamField body="updates" type="array" required>
  Array of update objects. Min 1, max 100. Each must include `id` plus at least one field to change.

  <Expandable title="Update object fields">
    <ParamField body="updates[].id" type="string" required>
      UUID of the memory to update.
    </ParamField>

    <ParamField body="updates[].content" type="string">
      New memory text. Max 8,192 characters. Triggers re-embedding.
    </ParamField>

    <ParamField body="updates[].metadata" type="object">
      Replace metadata entirely. Max 4 KB, 20 keys, 3 levels deep.
    </ParamField>

    <ParamField body="updates[].importance" type="number">
      Float between 0 and 1.
    </ParamField>

    <ParamField body="updates[].memory_type" type="string">
      One of: `correction`, `preference`, `decision`, `project`, `observation`, `general`.
    </ParamField>

    <ParamField body="updates[].namespace" type="string">
      Move memory to a different namespace. Max 255 characters.
    </ParamField>

    <ParamField body="updates[].pinned" type="boolean">
      Pin or unpin the memory.
    </ParamField>

    <ParamField body="updates[].expires_at" type="string | null">
      ISO 8601 date string or `null` to clear expiration.
    </ParamField>

    <ParamField body="updates[].immutable" type="boolean">
      Lock the memory permanently. One-way operation.
    </ParamField>
  </Expandable>
</ParamField>

<Warning>
  Immutable memories in the batch are skipped and returned in the `errors` array with a 409 status. The rest of the batch still processes.
</Warning>

## Response (200)

<ResponseField name="updated" type="number">
  Number of memories successfully updated.
</ResponseField>

<ResponseField name="errors" type="array">
  Array of error objects for memories that failed to update.

  <Expandable title="Error object fields">
    <ResponseField name="errors[].id" type="string">
      UUID of the memory that failed.
    </ResponseField>

    <ResponseField name="errors[].status" type="number">
      HTTP status code (404, 409, 422).
    </ResponseField>

    <ResponseField name="errors[].message" type="string">
      Error description.
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

<CodeGroup>
  ```bash curl theme={null}
  curl -X PATCH https://api.memoclaw.com/v1/memories/batch \
    -H "Content-Type: application/json" \
    -d '{
      "updates": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "importance": 0.95,
          "pinned": true
        },
        {
          "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
          "content": "Updated: team now uses pnpm instead of npm",
          "metadata": { "tags": ["stack", "tooling"] }
        }
      ]
    }'
  ```

  ```bash CLI theme={null}
  memoclaw update 550e8400-e29b-41d4-a716-446655440000 \
    --importance 0.95 --pinned

  memoclaw update 6ba7b810-9dad-11d1-80b4-00c04fd430c8 \
    --content "Updated: team now uses pnpm instead of npm" \
    --tags stack,tooling
  ```

  ```python Python theme={null}
  from memoclaw import MemoClaw

  client = MemoClaw()
  result = client.update_batch([
      {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "importance": 0.95,
          "pinned": True,
      },
      {
          "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
          "content": "Updated: team now uses pnpm instead of npm",
          "metadata": {"tags": ["stack", "tooling"]},
      },
  ])
  ```

  ```typescript TypeScript theme={null}

  import { MemoClawClient } from "memoclaw";

  const client = new MemoClawClient();
  const result = await client.updateBatch({
    updates: [
      {
        id: "550e8400-e29b-41d4-a716-446655440000",
        importance: 0.95,
        pinned: true,
      },
      {
        id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
        content: "Updated: team now uses pnpm instead of npm",
        metadata: { tags: ["stack", "tooling"] },
      },
    ],
  });
  ```
</CodeGroup>

```json Response theme={null}
{
  "updated": 2,
  "errors": []
}
```

## Errors

| Status | Description                                          |
| ------ | ---------------------------------------------------- |
| 404    | Memory not found (skipped, reported in `errors`).    |
| 409    | Memory is immutable (skipped, reported in `errors`). |
| 422    | Invalid request body or field validation failed.     |
