> ## 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.

# Recall facts by meaning

> Embed the query and return the closest facts in the scope, ranked by cosine similarity.

**Scope goes in the body**, like `POST /v1/memory`: `scope` plus the matching id.

Without `minScore`, a scope always answers with its `limit` closest facts however distant they are — a search that found nothing relevant is indistinguishable from one that found the right thing. Set `minScore` when your code branches on "did I know this?".



## OpenAPI

````yaml /openapi.json post /v1/memory/search
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/search:
    post:
      tags:
        - Memory
      summary: Recall facts by meaning
      description: >-
        Embed the query and return the closest facts in the scope, ranked by
        cosine similarity.


        **Scope goes in the body**, like `POST /v1/memory`: `scope` plus the
        matching id.


        Without `minScore`, a scope always answers with its `limit` closest
        facts however distant they are — a search that found nothing relevant is
        indistinguishable from one that found the right thing. Set `minScore`
        when your code branches on "did I know this?".
      operationId: searchMemories
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemorySearchRequest'
            examples:
              contact:
                summary: What do I know about this person?
                value:
                  query: how do they prefer to be contacted
                  scope: contact
                  contactId: jd7x2k3m4n5p6q7r8s9t0abc
                  limit: 5
                  minScore: 0.3
      responses:
        '200':
          description: >-
            Matching facts, closest first. An empty `items` means nothing
            cleared `minScore`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - items
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Memory'
        '400':
          description: Invalid body or a scope without its id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    MemorySearchRequest:
      type: object
      description: >-
        Retrieve facts by meaning. The query is embedded and compared against
        every fact in the scope.
      required:
        - query
      properties:
        query:
          type: string
          description: >-
            What to recall. Max 8,192 bytes. Phrase it as the fact you hope to
            find, not as a keyword: the match is semantic.
          example: when is a good time to reach them
        scope:
          $ref: '#/components/schemas/MemoryScope'
        contactId:
          type: string
          description: Required when `scope` is `contact`.
        conversationId:
          type: string
          description: Required when `scope` is `conversation`.
        limit:
          type: integer
          description: Maximum hits to return, closest first.
          default: 5
          minimum: 1
          maximum: 20
        minScore:
          type: number
          description: >-
            Drop hits below this similarity. Without it every scope returns its
            `limit` closest facts, however far away they are — an empty-handed
            search still answers with something. Set it (0.3 or above is a
            reasonable floor) when "nothing relevant" must be distinguishable
            from "the least irrelevant thing I hold".
          minimum: 0
          maximum: 1
    Memory:
      type: object
      description: >-
        A stored fact as returned by a read. `score` appears only on search
        results.
      required:
        - id
        - createdAt
      properties:
        id:
          type: string
        text:
          type: string
          description: The remembered text.
        metadata:
          type: object
          additionalProperties:
            type: string
        score:
          type: number
          description: >-
            Cosine similarity to the query, 0 to 1, higher being closer. Present
            on search results only — a list or a single read has no query to
            score against.
          example: 0.83
        createdAt:
          type: string
          format: date-time
        expiresAt:
          type: string
          format: date-time
    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
    MemoryScope:
      type: string
      description: >-
        Which namespace a memory belongs to. Scopes are isolated: a search in
        one never returns a memory from another.


        - `project`: shared by the whole project. What the agent knows in
        general.

        - `contact`: what the agent knows about one person, across every
        conversation with them.

        - `conversation`: what the agent knows about one inbox thread.


        Defaults to `project` everywhere. `contact` and `conversation` require
        the matching id.
      enum:
        - project
        - contact
        - conversation
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````