Mem0 memories API

The memories API from Mem0 — 12 operation(s) for memories.

OpenAPI Specification

mem0-memories-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Mem0 API Docs agents memories API
  description: mem0.ai API Docs
  contact:
    email: support@mem0.ai
  license:
    name: Apache 2.0
  version: v1
servers:
- url: https://api.mem0.ai/
security:
- ApiKeyAuth: []
tags:
- name: memories
paths:
  /v1/memories/:
    get:
      tags:
      - memories
      description: Get all memories.
      operationId: memories_list
      parameters:
      - name: user_id
        in: query
        schema:
          type: string
        description: Filter memories by user ID.
      - name: agent_id
        in: query
        schema:
          type: string
        description: Filter memories by agent ID.
      - name: app_id
        in: query
        schema:
          type: string
        description: Filter memories by app ID.
      - name: run_id
        in: query
        schema:
          type: string
        description: Filter memories by run ID.
      - name: metadata
        in: query
        schema:
          type: object
        description: Filter memories by metadata (JSON string).
        style: deepObject
        explode: true
      - name: categories
        in: query
        schema:
          type: array
          items:
            type: string
        description: Filter memories by categories.
      - name: org_id
        in: query
        schema:
          type: string
        description: Filter memories by organization ID.
      - name: project_id
        in: query
        schema:
          type: string
        description: Filter memories by project ID.
      - name: fields
        in: query
        schema:
          type: array
          items:
            type: string
        description: Filter memories by fields.
      - name: keywords
        in: query
        schema:
          type: string
        description: Filter memories by keywords.
      - name: page
        in: query
        schema:
          type: integer
        description: 'Page number for pagination. Default: 1.'
      - name: page_size
        in: query
        schema:
          type: integer
        description: 'Number of items per page. Default: 100.'
      - name: start_date
        in: query
        schema:
          type: string
        description: Filter memories by start date.
      - name: end_date
        in: query
        schema:
          type: string
        description: Filter memories by end date.
      responses:
        '200':
          description: Successfully retrieved memories.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    memory:
                      type: string
                    input:
                      type: array
                      items:
                        type: object
                        properties:
                          role:
                            type: string
                          content:
                            type: string
                    created_at:
                      type: string
                      format: date-time
                    updated_at:
                      type: string
                      format: date-time
                    owner:
                      type: string
                    immutable:
                      type: boolean
                      description: Whether the memory is immutable.
                      title: Immutable
                      default: false
                    expiration_date:
                      type: string
                      format: date
                      description: 'The date when the memory will expire. Format: YYYY-MM-DD.'
                      title: Expiration date
                      nullable: true
                      default: null
                    organization:
                      type: string
                    metadata:
                      type: object
                  required:
                  - id
                  - memory
                  - created_at
                  - updated_at
                  - total_memories
                  - owner
                  - organization
                  - type
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: 'One of the filters: app_id, user_id, agent_id, run_id is required!'
      x-code-samples:
      - lang: Python
        source: '# To use the Python SDK, install the package:

          # pip install mem0ai


          from mem0 import MemoryClient

          client = MemoryClient(api_key="your_api_key")


          # Retrieve memories for a specific user

          user_memories = client.get_all(filters={"user_id": "<user_id>"})


          print(user_memories)'
      - lang: JavaScript
        source: "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: \"your-api-key\" });\n\n// Retrieve memories for a specific user\nclient.getAll({ user_id: \"<user_id>\" })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));"
      - lang: cURL
        source: 'curl --location --request GET ''https://api.mem0.ai/v1/memories/'' \

          --header ''Authorization: Token <api-key>'''
      - lang: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v1/memories/\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
      - lang: PHP
        source: "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n  CURLOPT_URL => \"https://api.mem0.ai/v1/memories/\",\n  CURLOPT_RETURNTRANSFER => true,\n  CURLOPT_ENCODING => \"\",\n  CURLOPT_MAXREDIRS => 10,\n  CURLOPT_TIMEOUT => 30,\n  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n  CURLOPT_CUSTOMREQUEST => \"GET\",\n  CURLOPT_HTTPHEADER => [\n    \"Authorization: Token <api-key>\"\n  ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n  echo \"cURL Error #:\" . $err;\n} else {\n  echo $response;\n}"
      - lang: Java
        source: "HttpResponse<String> response = Unirest.get(\"https://api.mem0.ai/v1/memories/\")\n  .header(\"Authorization\", \"Token <api-key>\")\n  .asString();"
    post:
      tags:
      - memories
      description: Add memories.
      operationId: memories_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemoryInput'
        required: true
      responses:
        '200':
          description: Successful memory creation.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    data:
                      type: object
                      properties:
                        memory:
                          type: string
                      required:
                      - memory
                    event:
                      type: string
                      enum:
                      - ADD
                      - UPDATE
                      - DELETE
                  required:
                  - id
                  - data
                  - event
        '400':
          description: Bad Request. Invalid input data. Please refer to the memory creation documentation at https://docs.mem0.ai/platform/quickstart#4-1-create-memories for correct formatting and required fields.
          content:
            application/json:
              schema:
                type: object
                required:
                - error
                - details
                example:
                  error: 400 Bad Request
                  details:
                    message: Invalid input data. Please refer to the memory creation documentation at https://docs.mem0.ai/platform/quickstart#4-1-create-memories for correct formatting and required fields.
      x-code-samples:
      - lang: Python
        source: "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\n\nclient = MemoryClient(api_key=\"your_api_key\")\n\nmessages = [\n    {\"role\": \"user\", \"content\": \"<user-message>\"},\n    {\"role\": \"assistant\", \"content\": \"<assistant-response>\"}\n]\n\nclient.add(messages, user_id=\"<user-id>\")"
      - lang: JavaScript
        source: "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: \"your-api-key\" });\n\nconst messages = [\n  { role: \"user\", content: \"Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts.\" },\n  { role: \"assistant\", content: \"Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions.\" }\n];\n\nclient.add(messages, { user_id: \"<user_id>\" })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));"
      - lang: cURL
        source: "curl --request POST \\\n  --url https://api.mem0.ai/v1/memories/ \\\n  --header 'Authorization: Token <api-key>' \\\n  --header 'Content-Type: application/json' \\\n  --data '{\n  \"messages\": [\n    {}\n  ],\n  \"agent_id\": \"<string>\",\n  \"user_id\": \"<string>\",\n  \"app_id\": \"<string>\",\n  \"run_id\": \"<string>\",\n  \"metadata\": {},\n  \"includes\": \"<string>\",\n  \"excludes\": \"<string>\",\n  \"infer\": true,\n  \"custom_categories\": {}, \n  \"org_id\": \"<string>\",\n  \"project_id\": \"<string>\",\n  \"version\": \"v2\"\n}'"
      - lang: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v1/memories/\"\n\n\tpayload := strings.NewReader(\"{\n  \\\"messages\\\": [\n    {}\n  ],\n  \\\"agent_id\\\": \\\"<string>\\\",\n  \\\"user_id\\\": \\\"<string>\\\",\n  \\\"app_id\\\": \\\"<string>\\\",\n  \\\"run_id\\\": \\\"<string>\\\",\n  \\\"metadata\\\": {},\n  \\\"includes\\\": \\\"<string>\\\",\n  \\\"excludes\\\": \\\"<string>\\\",\n  \\\"infer\\\": true,\n  \\\"custom_categories\\\": {},\n  \\\"org_id\\\": \\\"<string>\\\",\n  \\\"project_id\\\": \\\"<string>\",\n  \\\"version\\\": \"v2\"\n}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
      - lang: PHP
        source: "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n  CURLOPT_URL => \"https://api.mem0.ai/v1/memories/\",\n  CURLOPT_RETURNTRANSFER => true,\n  CURLOPT_ENCODING => \"\",\n  CURLOPT_MAXREDIRS => 10,\n  CURLOPT_TIMEOUT => 30,\n  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n  CURLOPT_CUSTOMREQUEST => \"POST\",\n  CURLOPT_POSTFIELDS => \"{\n  \\\"messages\\\": [\n    {}\n  ],\n  \\\"agent_id\\\": \\\"<string>\\\",\n  \\\"user_id\\\": \\\"<string>\\\",\n  \\\"app_id\\\": \\\"<string>\\\",\n  \\\"run_id\\\": \\\"<string>\\\",\n  \\\"metadata\\\": {},\n  \\\"includes\\\": \\\"<string>\\\",\n  \\\"excludes\\\": \\\"<string>\\\",\n  \\\"infer\\\": true,\n  \\\"custom_categories\\\": {}, \n  \\\"org_id\\\": \\\"<string>\\\",\n  \\\"project_id\\\": \\\"<string>\",\n  \\\"version\\\": \"v2\"\n}\",\n  CURLOPT_HTTPHEADER => [\n    \"Authorization: Token <api-key>\",\n    \"Content-Type: application/json\"\n  ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n  echo \"cURL Error #:\" . $err;\n} else {\n  echo $response;\n}"
      - lang: Java
        source: "HttpResponse<String> response = Unirest.post(\"https://api.mem0.ai/v1/memories/\")\n  .header(\"Authorization\", \"Token <api-key>\")\n  .header(\"Content-Type\", \"application/json\")\n  .body(\"{\n  \\\"messages\\\": [\n    {}\n  ],\n  \\\"agent_id\\\": \\\"<string>\\\",\n  \\\"user_id\\\": \\\"<string>\\\",\n  \\\"app_id\\\": \\\"<string>\\\",\n  \\\"run_id\\\": \\\"<string>\\\",\n  \\\"metadata\\\": {},\n  \\\"includes\\\": \\\"<string>\\\",\n  \\\"excludes\\\": \\\"<string>\\\",\n  \\\"infer\\\": true,\n  \\\"custom_categories\\\": {}, \n  \\\"org_id\\\": \\\"<string>\\\",\n  \\\"project_id\\\": \\\"<string>\",\n  \\\"version\\\": \"v2\"\n}\")\n  .asString();"
      x-codegen-request-body-name: data
    delete:
      tags:
      - memories
      description: Delete memories by filter. At least one filter is required — previously omitting all filters silently deleted everything; now it returns a validation error.
      operationId: memories_delete_all
      parameters:
      - name: user_id
        in: query
        schema:
          type: string
        description: Filter by user ID. Pass `*` to delete memories for all users.
      - name: agent_id
        in: query
        schema:
          type: string
        description: Filter by agent ID. Pass `*` to delete memories for all agents.
      - name: app_id
        in: query
        schema:
          type: string
        description: Filter by app ID. Pass `*` to delete memories for all apps.
      - name: run_id
        in: query
        schema:
          type: string
        description: Filter by run ID. Pass `*` to delete memories for all runs.
      - name: metadata
        in: query
        schema:
          type: object
        description: Filter memories by metadata (JSON string).
        style: deepObject
        explode: true
      - name: org_id
        in: query
        schema:
          type: string
        description: Filter memories by organization ID.
      - name: project_id
        in: query
        schema:
          type: string
        description: Filter memories by project ID.
      responses:
        '204':
          description: Successful deletion of memories.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Memories deleted successfully!
      x-code-samples:
      - lang: Python
        source: '# To use the Python SDK, install the package:

          # pip install mem0ai


          from mem0 import MemoryClient

          client = MemoryClient(api_key="your_api_key")


          # Delete all memories for a specific user

          client.delete_all(user_id="<user_id>")


          # Delete all memories for every user in the project (wildcard)

          client.delete_all(user_id="*")


          # Full project wipe — all four filters must be explicitly set to "*"

          client.delete_all(user_id="*", agent_id="*", app_id="*", run_id="*")


          # NOTE: Calling delete_all() with no filters raises a validation error.

          # At least one filter is required to prevent accidental data loss.'
      - lang: JavaScript
        source: "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: \"your-api-key\" });\n\n// Delete all memories for a specific user\nclient.deleteAll({ user_id: \"<user_id>\" })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));\n\n// Delete all memories for every user in the project (wildcard)\nclient.deleteAll({ user_id: \"*\" })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));\n\n// Full project wipe — all four filters must be explicitly set to \"*\"\nclient.deleteAll({ user_id: \"*\", agent_id: \"*\", app_id: \"*\", run_id: \"*\" })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));"
      - lang: cURL
        source: "# Delete memories for a specific user\ncurl --request DELETE \\\n  --url 'https://api.mem0.ai/v1/memories/?user_id=<user_id>' \\\n  --header 'Authorization: Token <api-key>'\n\n# Delete memories for all users (wildcard)\ncurl --request DELETE \\\n  --url 'https://api.mem0.ai/v1/memories/?user_id=*' \\\n  --header 'Authorization: Token <api-key>'\n\n# Full project wipe — all four filters must be set to *\ncurl --request DELETE \\\n  --url 'https://api.mem0.ai/v1/memories/?user_id=*&agent_id=*&app_id=*&run_id=*' \\\n  --header 'Authorization: Token <api-key>'"
      - lang: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v1/memories/\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
      - lang: PHP
        source: "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n  CURLOPT_URL => \"https://api.mem0.ai/v1/memories/\",\n  CURLOPT_RETURNTRANSFER => true,\n  CURLOPT_ENCODING => \"\",\n  CURLOPT_MAXREDIRS => 10,\n  CURLOPT_TIMEOUT => 30,\n  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n  CURLOPT_CUSTOMREQUEST => \"DELETE\",\n  CURLOPT_HTTPHEADER => [\n    \"Authorization: Token <api-key>\"\n  ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n  echo \"cURL Error #:\" . $err;\n} else {\n  echo $response;\n}"
      - lang: Java
        source: "HttpResponse<String> response = Unirest.delete(\"https://api.mem0.ai/v1/memories/\")\n  .header(\"Authorization\", \"Token <api-key>\")\n  .asString();"
      x-codegen-request-body-name: data
  /v2/memories/:
    post:
      tags:
      - memories
      description: Get all memories.
      operationId: memories_list_v2
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemoryGetInputV2'
        required: true
      responses:
        '200':
          description: Successfully retrieved memories.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    memory:
                      type: string
                    created_at:
                      type: string
                      format: date-time
                    updated_at:
                      type: string
                      format: date-time
                    owner:
                      type: string
                    immutable:
                      type: boolean
                      description: Whether the memory is immutable.
                      title: Immutable
                      default: false
                    expiration_date:
                      type: string
                      format: date
                      description: 'The date when the memory will expire. Format: YYYY-MM-DD.'
                      title: Expiration date
                      nullable: true
                      default: null
                    organization:
                      type: string
                    metadata:
                      type: object
                  required:
                  - id
                  - memory
                  - created_at
                  - updated_at
                  - total_memories
                  - owner
                  - organization
                  - type
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: 'One of the filters: app_id, user_id, agent_id, run_id is required!'
      x-code-samples:
      - lang: Python
        source: "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your_api_key\")\n\n# Retrieve memories with filters\nmemories = client.get_all(\n    filters={\n        \"AND\": [\n            {\n                \"user_id\": \"alex\"\n            },\n            {\n                \"created_at\": {\n                    \"gte\": \"2024-07-01\",\n                    \"lte\": \"2024-07-31\"\n                }\n            }\n        ]\n    }\n)\n\nprint(memories)"
      - lang: JavaScript
        source: "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: \"your-api-key\" });\n\nconst filters = {\n  AND: [\n    { user_id: 'alex' },\n    { created_at: { gte: '2024-07-01', lte: '2024-07-31' } }\n  ]\n};\n\nclient.getAll({ filters })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));"
      - lang: cURL
        source: "curl -X POST 'https://api.mem0.ai/v2/memories/' \\\n-H 'Authorization: Token your-api-key' \\\n-H 'Content-Type: application/json' \\\n-d '{\n  \"filters\": {\n    \"AND\": [\n      { \"user_id\": \"alex\" },\n      { \"created_at\": { \"gte\": \"2024-07-01\", \"lte\": \"2024-07-31\" } }\n    ]\n  },\n  \"org_id\": \"your-org-id\",\n  \"project_id\": \"your-project-id\"\n}'"
      - lang: Go
        source: "package main\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n)\n\nfunc main() {\n\turl := \"https://api.mem0.ai/v2/memories/\"\n\tfilters := map[string]interface{}{\n\t\t\"AND\": []map[string]interface{}{\n\t\t\t{\"user_id\": \"alex\"},\n\t\t\t{\"created_at\": map[string]string{\n\t\t\t\t\"gte\": \"2024-07-01\",\n\t\t\t\t\"lte\": \"2024-07-31\",\n\t\t\t}},\n\t\t},\n\t}\n\tpayload, _ := json.Marshal(map[string]interface{}{\"filters\": filters})\n\treq, _ := http.NewRequest(\"POST\", url, bytes.NewBuffer(payload))\n\treq.Header.Add(\"Authorization\", \"Token your-api-key\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(string(body))\n}"
      - lang: PHP
        source: "<?php\n\n$curl = curl_init();\n\n$filters = [\n  'AND' => [\n    ['user_id' => 'alex'],\n    ['created_at' => ['gte' => '2024-07-01', 'lte' => '2024-07-31']]\n  ]\n];\n\ncurl_setopt_array($curl, [\n  CURLOPT_URL => \"https://api.mem0.ai/v2/memories/\",\n  CURLOPT_RETURNTRANSFER => true,\n  CURLOPT_ENCODING => \"\",\n  CURLOPT_MAXREDIRS => 10,\n  CURLOPT_TIMEOUT => 30,\n  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n  CURLOPT_CUSTOMREQUEST => \"POST\",\n  CURLOPT_POSTFIELDS => json_encode(['filters' => $filters]),\n  CURLOPT_HTTPHEADER => [\n    \"Authorization: Token your-api-key\",\n    \"Content-Type: application/json\"\n  ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n  echo \"cURL Error #:\" . $err;\n} else {\n  echo $response;\n}"
      - lang: Java
        source: "import com.konghq.unirest.http.HttpResponse;\nimport com.konghq.unirest.http.Unirest;\nimport org.json.JSONObject;\n\nJSONObject filters = new JSONObject()\n    .put(\"AND\", new JSONArray()\n        .put(new JSONObject().put(\"user_id\", \"alex\"))\n        .put(new JSONObject().put(\"created_at\", new JSONObject()\n            .put(\"gte\", \"2024-07-01\")\n            .put(\"lte\", \"2024-07-31\")\n        ))\n    );\n\nHttpResponse<String> response = Unirest.post(\"https://api.mem0.ai/v2/memories/\")\n  .header(\"Authorization\", \"Token your-api-key\")\n  .header(\"Content-Type\", \"application/json\")\n  .body(new JSONObject().put(\"filters\", filters).toString())\n  .asString();\n\nSystem.out.println(response.getBody());"
  /v1/memories/events/:
    get:
      tags:
      - memories
      operationId: memories_events_list
      responses:
        '200':
          description: Successfully retrieved memory events.
          content: {}
  /v1/memories/search/:
    post:
      tags:
      - memories
      description: Perform a semantic search on memories.
      operationId: memories_search_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemorySearchInput'
        required: true
      responses:
        '200':
          description: Successfully retrieved search results.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                      format: uuid
                      description: Unique identifier for the memory.
                    memory:
                      type: string
                      description: The content of the memory
                    user_id:
                      type: string
                      description: The identifier of the user associated with this memory
                    metadata:
                      type: object
                      nullable: true
                      description: Additional metadata associated with the memory
                    categories:
                      type: array
                      items:
                        type: string
                      description: Categories associated with the memory
                    immutable:
                      type: boolean
                      description: Whether the memory is immutable.
                      title: Immutable
                      default: false
                    expiration_date:
                      type: string
                      format: date
                      description: 'The date when the memory will expire. Format: YYYY-MM-DD.'
                      title: Expiration date
                      nullable: true
                      default: null
                    created_at:
                      type: string
                      format: date-time
                      description: The timestamp when the memory was created.
                    updated_at:
                      type: string
                      format: date-time
                      description: The timestamp when the memory was last updated.
                  required:
                  - id
                  - memory
                  - user_id
                  - created_at
                  - updated_at
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: 'At least one of the filters: agent_id, user_id, app_id, run_id is required!'
      x-code-samples:
      - lang: Python
        source: '# To use the Python SDK, install the package:

          # pip install mem0ai


          from mem0 import MemoryClient

          client = MemoryClient(api_key="your_api_key")


          query = "Your search query here"


          results = client.search(query, filters={"user_id": "<user_id>"})

          print(results)'
      - lang: JavaScript
        source: "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: \"your-api-key\" });\n\nconst query = \"Your search query here\";\n\nclient.search(query, { user_id: \"<user_id>\" })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));"
      - lang: cURL
        source: "curl --request POST \\\n  --url https://api.mem0.ai/v1/memories/search/ \\\n  --header 'Authorization: Token <api-key>' \\\n  --header 'Content-Type: application/json' \\\n  --data '{\n  \"query\": \"<string>\",\n  \"agent_id\": \"<string>\",\n  \"user_id\": \"<string>\",\n  \"app_id\": \"<string>\",\n  \"run_id\": \"<string>\",\n  \"metadata\": {},\n  \"top_k\": 123,\n  \"fields\": [\n    \"<string>\"\n  ],\n  \"rerank\": true,\n  \"org_id\": \"<string>\",\n  \"project_id\": \"<string>\"\n}'"
      - lang: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v1/memories/\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
      - lang: PHP
        source: "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n  CURLOPT_URL => \"https://api.mem0.ai/v1/memories/\",\n  CURLOPT_RETURNTRANSFER => true,\n  CURLOPT_ENCODING => \"\",\n  CURLOPT_MAXREDIRS => 10,\n  CURLOPT_TIMEOUT => 30,\n  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n  CURLOPT_CUSTOMREQUEST => \"GET\",\n  CURLOPT_HTTPHEADER => [\n    \"Authorization: Token <api-key>\"\n  ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n  echo \"cURL Error #:\" . $err;\n} else {\n  echo $response;\n}"
      - lang: Java
        source: "HttpResponse<String> response = Unirest.get(\"https://api.mem0.ai/v1/memories/\")\n  .header(\"Authorization\", \"Token <api-key>\")\n  .asString();"
      x-codegen-request-body-name: data
  /v2/memories/search/:
    post:
      tags:
      - memories
      description: Search memories based on a query and filters.
      operationId: memories_search_v2
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemorySearchInputV2'
        required: true
      responses:
        '200':
          description: Successfully retrieved search results.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                      format: uuid
                      description: Unique identifier for the memory.
                    memory:
                      type: string
                      description: The content of the memory
                    user_id:
                      type: string
                      description: The identifier of the user associated with this memory
                    metadata:
                      type: object
                      nullable: true
                      description: Additional metadata associated with the memory
                    categories:
                      type: array
                      items:
                        type: string
                      description: Categories associated with the memory
                    immutable:
                      type: boolean
                      description: Whether the memory is immutable.
                      title: Immutable
                      default: false
                    expiration_date:
                      type: string
                      format: date
                      description: 'The date when the memory will expire. Format: YYYY-MM-DD.'
                      title: Expiration date
                      nullable: true
                      default: null
                    created_at:
                      type: string
                      format: date-time
                      description: The timestamp when the memory was created.
                    updated_at:
                      type: string
                      format: date-time
                      description: The timestamp when the memory was last updated.
                  required:
                  - id
                  - memory
                  - user_id
                  - created_at
                  - updated_at
      x-code-samples:
      - lang: 

# --- truncated at 32 KB (89 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/mem0/refs/heads/main/openapi/mem0-memories-api-openapi.yml