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

# Write items in bulk

> Up to 25 sets and deletes in one call, in one scope.

**Not a transaction.** Each operation succeeds or fails on its own and is reported separately; the call returns `200` even when some failed. Check every entry's `ok` — treating a 200 as "all 25 landed" is the mistake this endpoint invites.



## OpenAPI

````yaml /openapi.json post /v1/memory/collections/{collection}/items/batch
openapi: 3.0.3
info:
  title: Zavu Unified Messaging Layer API
  version: 0.2.0
  description: >
    Unified multi-channel messaging API for Zavu.


    Supported channels:

    - **SMS**: Simple text messages

    - **WhatsApp**: Rich messaging with media, buttons, lists, CTA URL buttons,
    location requests, and templates

    - **Telegram**: Bot messaging with text, media, and interactive elements

    - **Email**: Transactional emails via Amazon SES


    Design goals:

    - Simple `send()` entrypoint for developers

    - Project-level authentication via Bearer token

    - Support for all WhatsApp message types (text, image, video, audio,
    document, sticker, location, contact, buttons, list, cta_url,
    location_request, reaction, template)

    - If a non-text message type is sent, WhatsApp channel is used automatically

    - 24-hour WhatsApp conversation window enforcement

    - Universal `to` field accepts phone numbers (E.164), email addresses, or
    numeric chat IDs (Telegram/Instagram/Messenger)
servers:
  - url: https://api.zavu.dev
security:
  - bearerAuth: []
paths:
  /v1/memory/collections/{collection}/items/batch:
    post:
      tags:
        - Memory
      summary: Write items in bulk
      description: >-
        Up to 25 sets and deletes in one call, in one scope.


        **Not a transaction.** Each operation succeeds or fails on its own and
        is reported separately; the call returns `200` even when some failed.
        Check every entry's `ok` — treating a 200 as "all 25 landed" is the
        mistake this endpoint invites.
      operationId: batchMemoryItems
      parameters:
        - $ref: '#/components/parameters/MemoryCollectionParam'
        - $ref: '#/components/parameters/MemoryScopeParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemoryItemBatchRequest'
            example:
              ops:
                - op: set
                  key: ORD-1
                  value:
                    status: shipped
                - op: delete
                  key: ORD-0
      responses:
        '200':
          description: Every operation was attempted. Inspect each result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MemoryItemBatchResponse'
        '400':
          description: Invalid body, scope, or more than 25 operations.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Collection not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: The plan's monthly unit quota is spent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  parameters:
    MemoryCollectionParam:
      name: collection
      in: path
      required: true
      description: Collection name.
      schema:
        type: string
    MemoryScopeParam:
      name: scope
      in: query
      required: false
      description: >-
        Which scope to address: `contact:<contactId>`,
        `conversation:<conversationId>`, or omitted for the project scope.


        Note the asymmetry with `POST /v1/memory` and `POST /v1/memory/search`,
        which take the scope in the request BODY as `scope` plus
        `contactId`/`conversationId`. Every other Memory endpoint takes it here.
      schema:
        $ref: '#/components/schemas/MemoryScopeQuery'
  schemas:
    MemoryItemBatchRequest:
      type: object
      description: >-
        Up to 25 writes and deletes in one call. Operations are NOT atomic: each
        is reported on its own, and a failure in one does not roll the others
        back.
      required:
        - ops
      properties:
        ops:
          type: array
          minItems: 1
          maxItems: 25
          items:
            type: object
            required:
              - op
              - key
            properties:
              op:
                type: string
                enum:
                  - set
                  - delete
              key:
                type: string
              value:
                description: The document, for `set`.
              ttlSeconds:
                type: integer
                minimum: 60
                maximum: 63072000
    MemoryItemBatchResponse:
      type: object
      required:
        - results
      properties:
        results:
          type: array
          description: >-
            One entry per submitted operation, in order. Check every `ok`: the
            call returns 200 even when some operations failed.
          items:
            type: object
            required:
              - key
              - ok
            properties:
              key:
                type: string
              ok:
                type: boolean
              rev:
                type: integer
                description: New revision, on a successful `set`.
              error:
                type: string
                description: Why this operation failed. Present when `ok` is false.
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: invalid_request
        message:
          type: string
          example: Phone number is invalid
        details:
          type: object
          additionalProperties: true
    MemoryScopeQuery:
      type: string
      description: >-
        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.
      example: contact:jd7x2k3m4n5p6q7r8s9t0abc
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````