API reference
Documentation · updated 9 November 2026
In short: your backend signs each request with your partner credential. Each of your customers is its own tenant, which you create, name in every memory request, and delete. Send documents or facts in; ask what is true now or on any past date. What we keep and who can read it is in the data contract.
Access
Start building (sign up or sign in, then Build with the Memory API): you get an account in test, a project and a test key, and your people see the keys, customers and usage in Team → API, where they make, roll and revoke keys and ask to go live. The quickstart pairs your terminal for a key and makes your first memory; the SDKs sign requests for you. Requests go to https://api.localmem.org, from your backend only: a secret must never reach a browser or an app.
A key is a test key (its secret starts lm_test_) or a live one (lm_live_). A test key reaches only the customers made with a test key, a live key only live ones, so the same external_ref can exist once in each and test never touches your live customers.
Signing a request
Every request carries these headers:
| Header | Value |
|---|---|
x-partner-id | Your project id |
x-localmem-key | The id of the key that signs, key_…. Required |
x-localmem-timestamp | Now, in Unix seconds. Refused if more than 5 minutes from our clock |
x-localmem-signature | Hex HMAC-SHA256, keyed with that key's secret, of timestamp.METHOD.path.body |
x-tenant-id | The customer acted on, on /v1/memory/ routes |
The path is without the query string, and the body is the exact bytes you send (empty for a GET). Because the method and path are signed, a captured request cannot be replayed onto another route.
ts=$(date +%s)
body='{"external_ref":"cust-42"}'
sig=$(printf '%s.%s.%s.%s' "$ts" POST /v1/partner/tenants "$body" \
| openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')
curl https://api.localmem.org/v1/partner/tenants \
-H "x-partner-id: $PROJECT_ID" -H "x-localmem-key: $KEY_ID" -H "x-localmem-timestamp: $ts" \
-H "x-localmem-signature: $sig" -H "content-type: application/json" \
-d "$body"
When your admins roll a key, its previous secret keeps working for 24 hours, so you can switch without downtime. A revoked key stops at once.
Your customers
| Request | Answer |
|---|---|
POST /v1/partner/tenants{ external_ref, phi? } | 201 with { tenant, external_ref, phi, status, created_at }. The same external_ref again answers 200 with the same customer, so a retry is safe; with a different phi, 409 external_ref_taken |
GET /v1/partner/tenants | { tenants: [ … ] }, each as above |
GET /v1/partner/tenants/{tenant} | The customer; once deletion has started, also deletion: { step, done, data_removed_at, kms_key, key_retired_at, irreversible_after, unreadable_everywhere_after } |
DELETE /v1/partner/tenants/{tenant} | 202 with { tenant, deleting, follow, deletion }. Access stops at once; see the data contract for what follows |
external_ref is your own id for the customer, at most 128 characters; never put a name or other content in it. Set phi: true if the customer's documents may hold protected health information. A customer you did not create answers 404 no_tenant, exactly as one that does not exist.
Documents
POST /v1/memory/documents reads a document with the customer's model provider and writes the facts it finds, with the document kept as their source. Each project follows localmem's default (Claude in Amazon Bedrock first, with a backup) unless an admin chooses a provider and a backup for it in Team → API, under AI model (Amazon Bedrock, OpenAI or Anthropic; see the data contract).
| Field | Meaning |
|---|---|
text | Required. At most 200 KB; split a longer document (413 document_too_large) |
title | Optional |
as_of | When the document was true, RFC 3339. Default: now |
tags | Optional string pairs, to filter by later |
external_ref | Your own id for the document, returned with it. A later document with the same external_ref is its revision (revises names the earlier one); the same text sent again under it is not read again (duplicate: true, nothing counted) |
content_type | text/plain (default) or text/markdown; anything else answers 415 unsupported_content_type. Send other files as their text for now |
Up to 20 KB, the answer comes when the facts are written, within 90 seconds (else 504 extraction_timeout, nothing written). Above 20 KB it is read in the background: the answer is 202 { document_id, status, job, follow }, and GET on follow (/v1/memory/documents/{document_id}) gives its state, then the written answer.
A long document is read in sections of about 1,500 words, so its last pages count as much as its first. Each section is read beside what the customer's memory already holds about it, so the same thing keeps the same name across documents. Every fact must quote the words of the document that state it; a fact whose words are not in the document is not written. Each new fact is then compared with what memory holds about its subject: a value is replaced only when the document says it changed, in any words, and a value said again becomes one more source of it.
The written answer: { document_id, episode_id, facts_written, superseded, provider, model, prompt, input_tokens, output_tokens, ms, sections, dropped_unquoted, content_type, bytes, sha256, revises, quotes, external_ref, at, status: "written" }. superseded lists each value a new fact replaced: { subject, predicate, was, now, valid_from, reason?, was_predicate? }, now null when the value was withdrawn, reason why it changed, and was_predicate the replaced value's own predicate when it differs. dropped_unquoted counts facts not written because their words were not in the document. Input and output tokens include the comparison.
facts (below) is different: a fact you write yourself replaces the live value of the same subject and predicate, because you chose the names.
Your documents. GET /v1/memory/documents lists the customer's documents, newest first, at most 100 a page: { documents: [{ document_id, status, title, external_ref, as_of, content_type, bytes, facts_written, revises, at }], next_cursor }. Filter with ?external_ref= and ?status= (written, pending, running, failed, deleted); pass next_cursor as ?cursor= for the next page. It reads the records only, never the text. GET /v1/memory/documents/{document_id}?facts=true adds the facts it wrote: { subject, predicate, object, quote, offset, valid_from, current, replaced_by }, quote the document's words and offset where they start. A document read before quotes existed answers quotes: false.
Deleting a document. DELETE /v1/memory/documents/{document_id} answers 202 { document_id, status: "deleting", job, follow }. Its keys are destroyed, then everything memory derived from it goes; a value it replaced is current again, and a revision of it stays. GET then answers status: "deleted" with deleted_at. A document still being read answers 409 document_in_progress.
Send an Idempotency-Key header (1 to 255 printable characters) to make a retry safe for 24 hours: the same key and body answer what the first request did, without a second reading. The same key with another body is refused (422 idempotency_key_reused).
Memory
Each is POST /v1/memory/{route} with a JSON body, naming the customer in x-tenant-id. Times are RFC 3339.
| Route | Body | Answer |
|---|---|---|
facts | facts: [{ subject, predicate, object, kind?, confidence?, retract?, as_of?, ref? }] (at most 200), episode? (the text they came from), as_of? (the default for facts without their own), source?, tags?, idempotency_key? | { episode_id, facts_written, superseded, bounded?, duplicate }. For facts you extracted yourself; nothing goes to a model. Search finds each fact by its subject, predicate and object, even with no episode |
write | content, tags?, as_of?, source?, idempotency_key? | { event_id, action, facts_extracted } |
search | query, k? (default 10, at most 100), at_time?, tags? | { results: [{ fact, score, sources, valid_from?, valid_to?, current, replaced_by?, facts? }], context, tokens }. valid_from is the time of the memory a result came from; it is left out only when that time is unknown, so do not drop results that lack it. current is false once newer values replaced everything the memory said, as of at_time or now, and such a result ranks below what replaced it; valid_to is when, and replaced_by lists the memories that replaced it (sources, at). A memory only partly replaced stays current, and replaced_by names what replaced that part. facts holds up to 5 of its facts that hold then and answer the query, nearest the query first (subject, attribute, value, valid_from, ref?); the values one facts call wrote come back as one result, so read its facts for the value asked about. context is the same results as one text block for a model, oldest first, each with its date and whether it still holds, and tokens counts it |
recall | entity, at_time?, tags?, limit? (1 to 1000), after?, ref? | { facts: [{ id, predicate, object, confidence, valid_from, valid_to?, retired_at?, retraction?, sources, ref? }], next? }. With limit, pass next as after for the following page. With ref, only the facts carrying that id |
get | event_id | { event_id, found, content?, valid_from? } |
profile | scope? (one subject), tags? | { profile_md, generated_at, fact_count } |
forget | target_id | { forgotten_event_ids }. Hides it from answers from now on; it does not destroy it |
purge | {} | Clears search data left from content whose key was destroyed |
at_time answers with the facts as they stood at that moment, so a value that has since changed is answered as it was then. recall without it returns the subject's whole history: a value since replaced carries retired_at, and a withdrawn one retraction: true. To show only what holds now, pass the current time. Without limit a recall returns the whole history at once; use pages for long histories.
A history in one call. Each fact may carry its own as_of, so one call can write many periods: twelve months of a figure, each at its month's end, in any order. A fact without one takes the call's as_of, else now. An idempotency_key covers the whole call, whatever its facts' times. A search hit shows one period's facts; whether it is current covers every fact the call wrote.
Any order. Values of one subject and predicate can arrive in any order: a value written between two others holds exactly from its own as_of to the next one's, so a recall at a time inside its period answers it alone.
Correcting a past value. A fact with the same subject, predicate and as_of as an earlier one replaces it, even when a newer value has followed since. Recompute September after October was written, send it with September's as_of, and a recall inside September answers only the new value.
Times are kept to the microsecond and answered as sent: a time with only milliseconds comes back as 2026-02-01T00:00:00.000Z, one with microseconds keeps all six digits. Finer digits are dropped.
Late values. A fact whose as_of is older than a value memory already holds for the same subject and predicate is kept, but it holds only until that newer value starts, so it is not what memory answers as current. The answer lists each such fact in bounded: { subject, predicate, value, ref?, valid_from, until, newer }, newer null when the newer value withdrew it. If the value was meant to be current, send it again with a later as_of. Values sent in the same call do not count against each other, and bounded is left out when there are none.
Your own ids. A fact may carry ref, your id for the value (1 to 200 bytes, no surrounding spaces). It is kept with the fact and answered by recall and with search hits, but it is not part of what search reads, so it never decides what a search finds. To check whether memory holds a value you wrote, recall its subject with ref: the answer is that value, replaced or not, or nothing. Keep ids in ref rather than as facts of their own, which search would read. A retraction takes no ref.
Retries. facts and write take an idempotency_key (1 to 255 printable characters): a repeat answers the first call's answer, with duplicate: true, and stores nothing again. One facts call is not all or nothing: its facts are stored one by one, in order. If a call fails part way, send it again with the same key: it is stored again in full, and a fact equal to one already stored replaces it, so no value is held twice.
Usage
GET /v1/partner/usage?from=YYYY-MM-DD&to=YYYY-MM-DD returns { from, to, usage: [ … ] }, one entry per customer and day: { tenant, day, documents, facts, fact_calls, writes, reads, input_tokens, output_tokens }. writes counts write calls and fact_calls counts facts calls (facts is how many facts they stored); a plan's writes allowance counts both. Both dates are included; to defaults to today and from to 29 days before it; at most 366 days (400 bad_range). Only requests that succeeded count. A deleted customer's usage stays.
Limits
- Requests are limited per project, by the key's mode and your plan: test keys 30 a minute (10 at once), live keys 300 a minute (100 at once) on Starter, 600 (200) on Growth and 1,200 (400) on Scale. Every
429states the rate that applied. Each project has its own allowance for test and its own for live, so testing never slows your live requests. - Each customer also allows 1,200 a minute (400 at once) over all callers.
- Past either, the answer is
429 rate_limitedwithRetry-After, and its body says which:{ error, message, limit, per_minute, burst, retry_after, mode }, wherelimitisproject_rateorcustomer_rate. The SDKs wait and retry for you. To send less, write many facts in onefactscall. - Documents: 60 a minute per customer, and at most 100 waiting to be read per customer (
429 documents_backlog). - A request still running after 100 seconds is cut. Send long documents and let them run in the background.
Your month
Your account has a monthly allowance of documents read, writes (write and facts calls) and searches (search, recall, get, profile), all its projects together, test and live counted apart. It resets on the 1st at 00:00 UTC. Team → API shows it.
- Every Memory API answer says what is left of the allowance it counts against, as headers:
x-localmem-allowance-name(documents,writesorreads),x-localmem-allowance-limitandx-localmem-allowance-remaining(packs included),x-localmem-allowance-resets, andx-localmem-allowance-used-up, every allowance used up this month (nonewhen none). - When documents or writes are used up, more are refused with
429 monthly_limit:{ error, message, limit, used, allowed, resets_at, mode, top_up_url }, withRetry-Afteruntil the reset. The message names the fix: go live (in test), or add a pack (live). Nothing is deleted. A repeat of a write with the sameidempotency_keyis counted once. - Searches are never refused for the month: reading your customers' memory keeps working. Past twice the allowance they are slowed to 60 a minute per project, answered
429 rate_limitedwithlimit: over_allowance_rateandRetry-Afterpast that. - A pack, live only, adds to the allowance after the month's own is used, and never expires.
Errors and request ids
An error answers { error, message }: error is a code you can act on, and the message is for people. A 429 also carries Retry-After.
| Status | Codes |
|---|---|
| 400 | bad_body (including an unknown field or a wrong type), no_tenant (none named), empty_text, empty_query, empty_entity, empty_content, invalid_as_of, invalid_at_time, invalid_idempotency_key, invalid_ref, retract_with_ref, bad_range |
| 401 | key_required (no x-localmem-key); bad_signature: wrong secret, a revoked or unknown key, a stale timestamp, or a body or path that differs from what was signed |
| 403 | partner_routes_only (a key reaches only /v1/partner/ and /v1/memory/); account_suspended |
| 404 | no_tenant (including a customer of the other mode), no_document, no_such_route |
| 409 | external_ref_taken; idempotency_key_in_use (the first request with that key is still being read); no_model (no model provider set for the customer: write to us); no_baa_provider (a phi customer's document, while no provider is under a BAA) |
| 413, 422 | document_too_large; idempotency_key_reused |
| 429 | rate_limited, documents_backlog; monthly_limit (documents or writes used up for the month: do not retry until resets_at) |
| 502, 504 | extraction_failed, extraction_timeout: nothing was written; retry with the same Idempotency-Key |
| 503 | server_busy, documents_unavailable, usage_unavailable: retry shortly |
Every answer carries x-request-id: yours, if you sent one of up to 64 letters, digits, -, _ or .; else one of ours. Quote it when you write to support@localmem.org.