Skip to main content

Memory API reference

Base URL: https://api.withfoundry.ai
Auth: Authorization: Bearer key_...
All responses use this envelope:
{
  "success": true,
  "data": { ... },
  "meta": { "requestId": "req_..." }
}
Errors return success: false, data with error details, and appropriate HTTP status (4xx/5xx).

Write entries

POST /v1/memory/entries Write one or more entries into a namespace. Each entry is embedded and indexed for semantic search. Request body
FieldTypeRequiredDescription
namespacestringYesNamespace id (e.g. app or tenant).
entriesarrayYesArray of { content, metadata? }.
entries[].contentstringYesText to store and embed.
entries[].metadataobjectNoArbitrary JSON for filtering/display.
Response data
FieldTypeDescription
idsstring[]IDs of created entries (e.g. mem_...).
Example
curl -X POST https://api.withfoundry.ai/v1/memory/entries \
  -H "Authorization: Bearer key_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"namespace":"my-app","entries":[{"content":"Auth uses Bearer key_...","metadata":{"source":"docs"}}]}'

POST /v1/memory/search Semantic search over a namespace. Returns entries ranked by similarity to the query. Request body
FieldTypeRequiredDescription
namespacestringYesNamespace to search.
querystringYesNatural-language query.
limitnumberNoMax results (default from plan).
metadataFilterobjectNoKey-value filters on metadata.
Response data Array of objects:
FieldTypeDescription
idstringEntry id.
contentstringStored text.
metadataobjectStored metadata.
scorenumberSimilarity score (e.g. 0–1).
Example
curl -X POST https://api.withfoundry.ai/v1/memory/search \
  -H "Authorization: Bearer key_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"namespace":"my-app","query":"How do we authenticate?","limit":5}'

Get context

POST /v1/memory/context Run semantic search and return a single formatted context string for use in LLM prompts. Request body
FieldTypeRequiredDescription
namespacestringYesNamespace to search.
querystringYesQuery for ranking entries.
limitnumberNoMax entries to include in the string.
Response data
FieldTypeDescription
textstringConcatenated content of top entries.
entryIdsstring[]IDs of entries included.
Example
curl -X POST https://api.withfoundry.ai/v1/memory/context \
  -H "Authorization: Bearer key_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"namespace":"my-app","query":"user preferences and auth","limit":3}'