POST
/
v4
/
search
Search memory entries
const url = 'https://api.supermemory.ai/v4/search';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"q":"machine learning concepts"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
{
  "results": [
    {
      "id": "mem_abc123",
      "memory": "John prefers machine learning over traditional programming",
      "metadata": {
        "source": "conversation",
        "confidence": 0.9
      },
      "updatedAt": "2023-11-07T05:31:56Z",
      "similarity": 0.89,
      "version": 3,
      "context": {
        "parents": [
          {
            "relation": "updates",
            "version": -1,
            "memory": "Earlier version: Dhravya is working on a patent at Cloudflare.",
            "metadata": {},
            "updatedAt": "2023-11-07T05:31:56Z"
          }
        ],
        "children": [
          {
            "relation": "extends",
            "version": 1,
            "memory": "Later version: Dhravya has filed the patent successfully.",
            "metadata": {},
            "updatedAt": "2023-11-07T05:31:56Z"
          }
        ]
      },
      "documents": [
        {
          "id": "doc_xyz789",
          "title": "Introduction to Machine Learning",
          "type": "web",
          "metadata": {
            "category": "technology",
            "isPublic": true,
            "readingTime": 5,
            "source": "web",
            "tag_1": "ai",
            "tag_2": "machine-learning"
          },
          "summary": "A comprehensive guide to understanding the basics of machine learning and its applications.",
          "createdAt": "2023-11-07T05:31:56Z",
          "updatedAt": "2023-11-07T05:31:56Z"
        }
      ]
    }
  ],
  "timing": 245,
  "total": 5
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
q
string
required

Search query string

Minimum length: 1
Example:

"machine learning concepts"

containerTag
string

Optional tag this search should be containerized by. This can be an ID for your user, a project ID, or any other identifier you wish to use to filter memories.

Example:

"user_123"

threshold
number
default:0.6

Threshold / sensitivity for memories selection. 0 is least sensitive (returns most memories, more results), 1 is most sensitive (returns lesser memories, accurate results)

Required range: 0 <= x <= 1
Example:

0.5

filters
object

Optional filters to apply to the search

Example:
{
"AND": [
{
"key": "group",
"negate": false,
"value": "jira_users"
},
{
"filterType": "numeric",
"key": "timestamp",
"negate": false,
"numericOperator": ">",
"value": "1742745777"
}
]
}
include
object
limit
integer
default:10

Maximum number of results to return

Required range: 1 <= x <= 100
Example:

10

rerank
boolean
default:false

If true, rerank the results based on the query. This is helpful if you want to ensure the most relevant results are returned.

Example:

false

rewriteQuery
boolean
default:false

If true, rewrites the query to make it easier to find documents. This increases the latency by about 400ms

Example:

false

Response

Memory search results

results
object[]
required

Array of matching memory entries with similarity scores

timing
number
required

Search execution time in milliseconds

Example:

245

total
number
required

Total number of results returned

Example:

5