MemorySync
API Reference

Query Memory

Run semantic recall over the caller's memories. The handler embeds the query string, runs nearest-neighbor search in the vector index scoped to tenant + project, joins metadata back from the primary datastore, and optionally reranks.
POST/memory/query

Authentication

Accepts a JWT bearer token (Authorization: Bearer eyJ…) or an API key (X-API-Key: ms_live_…). API-key callers should send X-Project-ID unless the key is project-locked. Cross-tenant operators must send X-Tenant-ID.

Request body

FieldTypeRequiredDescription
querystringrequiredNatural-language recall string.
limitintegeroptionalDefault 10, max 100.
filtersobjectoptionalEquality / range filters over metadata, tags, memory_type.
min_scorenumberoptionalDrop hits below this similarity threshold.
rerankbooleanoptionalRun the reranker pass (slower, more accurate).
request.json
{
"query": "how does this user like their UI?",
"limit": 5,
"filters": {
"tags": [
"preferences"
]
}
}

Response

Returns 200 OK with the following body.

FieldTypeRequiredDescription
memoriesarrayoptionalRanked hits ordered by descending score.
totalintegeroptionalTotal candidates considered before limit.
request_idstringoptionalTrace id. Quote in support tickets.
200.json
{
"memories": [
{
"id": 184213,
"text": "User prefers dark mode and concise responses.",
"score": 0.834,
"metadata": {
"source": "chat",
"user_id": "u_42"
},
"created_at": "2026-05-04T12:30:11Z"
}
],
"total": 1,
"request_id": "req_01HX..."
}

Errors

StatusCodeDescription
400validation_errorBody or query failed schema validation. The error includes the offending field name.
401unauthenticatedMissing or invalid bearer token / API key.
403forbiddenAuthenticated principal lacks the required scope, role, or project access.
404not_foundTarget resource does not exist or is not visible to the calling tenant.
429rate_limitedPer-IP or per-route limit exceeded. Respect the Retry-After header.
500internal_errorUnhandled server error. Quote the request_id when contacting support.

Examples

cURL
curl -X POST https://api.memorysync.io/memory/query \
-H "Authorization: Bearer $MEMORYSYNC_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "how does this user like their UI?",
"limit": 5,
"filters": {
"tags": [
"preferences"
]
}
}'
javascript
import { MemorySync } from 'memorysync'
const client = new MemorySync({ apiKey: process.env.MEMORYSYNC_KEY })
const result = await client.request({
method: 'POST',
path: '/memory/query',
body: {
"query": "how does this user like their UI?",
"limit": 5,
"filters": {
"tags": [
"preferences"
]
}
},
})
console.log(result)
python
from memorysync import Client
client = Client(api_key=os.environ["MEMORYSYNC_KEY"])
result = client.request(
method="POST",
path="/memory/query",
json={
"query": "how does this user like their UI?",
"limit": 5,
"filters": {
"tags": [
"preferences"
]
}
},
)
print(result)

Behavior & notes

Read-only and safe to retry. Vector search is scoped to the caller's tenant and project; cross-tenant results are never returned.

When your organisation is over its monthly query quota, the route silently returns 200 with {"memories":[]}. No error is surfaced to the caller. Watch the usage dashboard or configure quota alerts to detect this state.