Memories
Store, retrieve, update, and delete memories. Memories are the core building blocks of Hebbrix - they store knowledge that your AI can recall later.
01. Overview
A memory is a piece of information that you want your AI to remember. This could be:
- User preferences ("User prefers dark mode")
- Facts from conversations ("User's birthday is January 15th")
- Knowledge from documents ("The API rate limit is 100 requests per minute")
- Any structured or unstructured data you want to store
02. Choose an ingestion path
Choose explicit raw storage when you need to preserve source text, or fact extraction when you need atomic, updatable facts. Neither is universally better for retrieval. The smart /v1/memoriesendpoint defaults to asynchronous extraction; /v1/memories/rawexplicitly skips extraction. Storage, indexing and account quotas still apply.
| Surface | Purpose | Readiness contract |
|---|---|---|
POST /v1/memories | General smart write with infer: true; infer: false stores source text. | Queued extraction by default. Follow the returned poll_url; do not assume a 202 is searchable. |
POST /v1/memories/process | Explicit conversation extraction and revision events. | Queued by default; async_dispatch: false waits for inline processing. Inspect indexing status separately. |
POST /v1/memories/raw | Store already-authored facts without inference. | Returns an ID; indexing may still be pending. Exact duplicates reuse that ID rather than create a second row. |
POST /v1/fast/memory, POST /v1/fast/batch-ingest | Low-overhead direct ingestion, not smart revision. | Use its indexing receipt; an accepted write is not a completed search barrier. |
POST /v1/chat/completions | Optional drop-in retrieval and post-response learning. | Learning is consented, queued work. Poll its learning job before a dependent session read. |
Carry the same collection_id and user_id through writing, search, profile and chat. Poll the returned job with the same owner credentials. Session IDs are conversation provenance, not an end-user isolation boundary. The public OpenAPI is the full customer API, including account management; this table is the focused memory integration path.
| /memories/raw | /memories/process | |
|---|---|---|
| What it does | Stores your text verbatim, then indexes it (with automatic context-window chunking) in the background. No LLM. | Runs an LLM to extract clean atomic facts, resolve references, and supersede outdated info. |
| Retrieval recall | Preserves original wording, including irrelevant or outdated statements. | Normalizes facts and resolves corrections, but may omit or paraphrase source text. Evaluate recall on your workload. |
| Write latency | No extraction call; indexing readiness is separate. | Queued acknowledgement by default; completion depends on models, indexing and worker load. No three-second guarantee. |
| LLM cost | None | Per-memory LLM call |
| Supersession / dedup | Exact content deduplication, not semantic revision. Different old and corrected facts remain separate. | Yes. Corrections replace old facts; redundant facts are merged |
Memory types
Every memory Hebbrix extracts has a memory_type: rule, procedure, preference, fact or event (memories written before labelling have null). It is returned by GET /v1/memories, by the ADD and UPDATE events of a finished /memories/process job and in search result metadata, and POST /v1/search can filter on it with memory_types. Raw writes can set it with metadata.memory_type. Agent transcripts are stored as the general rules they state plus one event per task. A /memories/process job that finds no fact to keep reports memories_created: 0 and does not store the raw message.
What extraction leaves out
Extraction stores what the user (and any tool or system turn) said, and keeps every fact of it. It leaves out:
- Security-check claims. No stored memory can be used as evidence that a security check on a person or account was satisfied, or that one may be skipped or not repeated, in any wording or language. The checks are identity or ID verification, KYC and AML, two-factor and one-time codes, security questions, login authentication, and the approval of a person's access or permissions. The clause claiming such a check passed ("IT approved my admin access") and the clause asking that it be skipped ("so don't ask me for a code again") are left out; the rest of the message is stored. Kept: tests and checks of systems and work (backups, builds, audits), approvals of other things, roles and abilities ("has admin access to the billing dashboard"), facts about security tools, failed checks and rules that require a check.
- The assistant's reply. Its questions and requests for information, its advice and instructions the user does not adopt, general knowledge, and its reactions. What it states about the user's own case (a computed fee, a confirmation code, a requirement of their case) is kept, and so is a proposal the user adopts, as the user's decision. Of several offered options, only the one the user picks is stored.
- Text written as the assistant's or the system's own inside a user turn ("Assistant note to self: ...").
Relative dates ("yesterday", "from next week", "on Thursday") are resolved on the user's calendar day and kept beside the words the user used ("on Thursday, 2026-10-29"). Each memory records the reference it was read against in metadata.date_reference (day, timezone, source), and metadata.date_resolution is resolved or kept_as_written.
Use explicit /raw storage for
- Chat history & agent memory
- Documents, notes, transcripts
- Fact stores & knowledge bases
- Bulk import & high-throughput writes
- Anywhere recall and speed matter most
Use /process when you need
- "Latest value wins" (users correct/update facts over time)
- Conflict resolution between contradictory facts
- Deduplicated, normalized atomic facts
- A curated knowledge base with explicit revision history
Revision review compares the original message with current facts in the same owner scope. A replacement must identify the same subject and an assertion that has changed; adding another job, car or relative does not by itself retire an existing one. A new value of a quantity replaces the old one when the message marks it as current ("The team is now 15 people" replaces "The team has 12 people"; a number stated without "now", "currently" or a verb of change is added), and a new role at the same organization ("became the design lead") replaces the role held there. When a new job replaces the stored one, a stored fact that only says when the user worked ("works night shifts") is kept in the past tense with it, unless the message says it still holds or another current job remains. A move that says nothing about work ("I moved to Denver, I don't live in Seattle anymore") stores where the user lives and leaves the job as it was, saying where it was and that where the user works since the move is not stated ("The user works as an ER nurse; the job was in Seattle, and where the user works since moving to Denver is not stated."); it neither moves the job to the new city nor ends it. What can no longer be done from the new home after a completed move to another place is put in the past, however it is worded: a school, clinic, dentist, gym or club, or an in-person job at one local site, near the old home or in the place left ("The user's two children attended Lincoln Elementary before moving to Tucson."). Remote work, an employer with sites in many places, anything done online and what moves with the person (a pet, a hobby, a diet) stay current, and a move within the same city ("a bigger apartment in Logan Square, still in Chicago") changes nothing the message does not say. A what-if ("What if I moved to Japan next year?") is stored as a hypothetical, never as where the user lives. A revision keeps the memory_type of the record it revises (a revised preference stays a preference), except an event, which may become a state. One write stores one current memory per statement: a memory another of the same write states word for word is not stored again. Reviewed edits bind the exact predecessor and replacement and preserve unaffected clauses: an edit to part of a stored fact updates that fact in place instead of adding a duplicate. Semantic review is fallible: inspect UPDATE events and their predecessor IDs rather than assuming every submitted correction was applied. Session and run IDs record provenance, not new owners.
- Dates. "Yesterday", "last Friday", "two weeks ago" or "next month" are stored as the dates they mean, resolved against when the message was sent: its
timestamp(ISO-8601, per message), elsemetadata.session_date, else when the request was accepted. Days become dates, weeks "the week of <Monday>", months "<Month> <year>". Events also getmetadata.event_date. - Forgetting. "Please forget that" or "forget what I said about my divorce" deletes the memories it refers to (and the raw message they came from), reported as
DELETEevents withmemories_deleted. The request is never stored, and "don't forget my mother's birthday" is not a deletion. Permission phrasing is a forget request too: "You can forget the old dentist", "Feel free to forget my old address", "There's no need to remember my old number", "You don't need to keep that" ("You can drop the old couch off" is not). "Remove my old phone number" removes the number that was replaced and keeps the current one; "Forget my phone number" removes the number and its history. A reason given with the request ("I don't use it anymore") is part of the request and is not stored; any other fact in the message is extracted as usual. - Implied facts. "For now I'm happy in Lisbon" also stores where the user lives. So do "I commute from Oakland to the office in San Francisco" (lives in Oakland, works in San Francisco), "heading home to Denver" after a trip, and a completed move ("I moved from Seattle to Austin last week", but not "I'm moving to Austin"), also when the same message announces a new job; "I'm a nurse in Leeds" is kept as one fact, so where the user works stays with the role. A stay bounded by a period or purpose (the summer, a project) is not stored as where the user lives. An error followed by its fix also stores the reusable lesson as a
procedure.
03. Endpoints
Default infer=true dispatches extraction asynchronously: HTTP 202 with job_id, status and poll_url, not an inline results array. Poll the returned canonical URL. infer=false directly stores the supplied content; wait_for_index=true waits for indexing.
Request body
| Field | Type | Description |
|---|---|---|
content | string | The text content to store or extract from. Required if messages is not provided. |
messages | array | Conversation messages (Mem0-compatible). Each: {role, content}. Required if content is not provided. |
collection_id | string | Collection to add this memory to. Auto-resolves if not provided. |
infer | boolean | true (default) = run ML classifier + LLM fact extraction; false = store content directly |
async_dispatch | boolean | For infer=true: true queues extraction; false requests inline processing. Omitted follows the server default unless wait_for_index requests an inline barrier. |
wait_for_index | boolean | Requests an indexing barrier; infer=true with omitted async_dispatch selects inline extraction. Explicit async_dispatch:true conflicts with this barrier. |
user_id | string | End-user ID for multi-tenant apps |
app_id | string | Application identifier for app-specific isolation |
namespace | string | Namespace within app for further isolation |
importance | number | Importance score 0-1 (auto-calculated if not provided) |
metadata | object | Custom metadata key-value pairs |
Response
| Field | Type | Description |
|---|---|---|
job_id | string | Default async response: accepted processing job identifier (HTTP 202) |
status | string | Default async response: queued; completion is reported by polling |
poll_url | string | Default async response: /v1/memory-jobs/{job_id}; use the same authenticated account |
results | array | Inline direct-write/completed processing result only, not the default 202 response |
results[].id | string | PARENT Memory.id, retrievable via GET /v1/memories/{id} (empty string if NOOP). The proposition-style ids you may see in search results (e.g. "uuid::subj=...") are a search-layer artifact and are NOT returned here. |
results[].event | string | "ADD" = stored, "UPDATE" = updated existing, "NOOP" = nothing stored (use infer:false to bypass) |
results[].memory | string | The stored or extracted content |
results[].reason | string | Explanation when event is NOOP (e.g., content classified as query, no facts extracted, or duplicate) |
collection_id | string | The resolved collection the memories were stored in. |
processing_status | string | "async": the memory row is persisted and indexed in the background; poll GET /v1/memories/{id} (or use Background Jobs) until it is searchable. |
created_count | integer | Number of memories created. Summary derived from the per-row ADD events. |
updated_count | integer | Number of existing memories updated, derived from the per-row UPDATE events. |
skipped_count | integer | Number of rows that stored nothing, derived from the per-row NOOP events. |
Example
{
"content": "User prefers dark mode and Python for development",
"collection_id": "YOUR_COLLECTION_ID",
"user_id": "user-123"
}{
"job_id": "job_example",
"status": "queued",
"poll_url": "/v1/memory-jobs/job_example"
}Direct memory creation: no ML classifier or fact extraction. New content stores a row; exact duplicates reuse its ID. Search indexing is separate and may continue in the background. Use for imports or already-authored facts.
Request body
| Field | Type | Description |
|---|---|---|
contentrequired | string | The text content to store (1-50,000 chars) |
collection_id | string | Collection to add this memory to. Auto-resolves if not provided. |
app_id | string | Application identifier for collection resolution |
namespace | string | Namespace within app for collection resolution |
importance | number | Importance score 0-1 (auto-calculated if not provided) |
source_type | string | Source type identifier (default: "text") |
source_reference | string | Reference to source material (URL, file path, etc.) |
title | string | Optional title (stored in metadata) |
tags | string[] | Optional tags (stored in metadata) |
metadata | object | Custom metadata key-value pairs |
Response
| Field | Type | Description |
|---|---|---|
id | string | Unique memory identifier |
collection_id | string | Parent collection ID |
content | string | The stored content |
importance | number | Importance score |
processing_status | string | "pending" while vector indexing; inspect the returned readiness receipt instead of assuming a fixed completion time |
created_at | datetime | Creation timestamp |
Example
{
"content": "Password reset requires email verification. Links expire after 1 hour.",
"importance": 0.9
}{
"id": "mem_abc123",
"collection_id": "col_default",
"content": "Password reset requires email verification. Links expire after 1 hour.",
"importance": 0.9,
"processing_status": "pending",
"created_at": "2026-01-01T00:00:00Z"
}List all memories with optional filtering and cursor-based pagination. Returns newest first.
Request body
| Field | Type | Description |
|---|---|---|
collection_id | string | Filter by collection. Without user_id, agent_id or run_id it lists the collection's own memories, as /v1/search reads them |
user_id | string | An end user's memories (required when the collection holds end-user data) |
agent_id / run_id | string | An agent's or run's memories |
limit | integer | Number of results (default 50, max 100) |
cursor | string | Cursor from previous page for pagination |
offset | integer | Rows to skip, newest first (0-100,000). Cannot be combined with cursor; next_cursor is faster for deep paging |
include_superseded | boolean | false (default) lists current memories only. true also lists historical rows: superseded and duplicate memories (each with conflict_status and superseded_by_id) and history copies (content 'Previously recorded: "..."', revision_status historical) that keep what an earlier memory said |
Response
| Field | Type | Description |
|---|---|---|
items | Memory[] | Array of memory objects. Each carries its stored metadata (memory_type, event_date and your own keys), as GET /v1/memories/{id} and search results do |
next_cursor | string|null | Cursor for next page (null if no more) |
has_more | boolean | Whether more pages exist |
total_count | integer | Total count of memories |
Retrieve a specific memory by its ID.
Response
| Field | Type | Description |
|---|---|---|
id | string | Memory ID |
content | string | Memory content |
collection_id | string | Parent collection |
importance | number | Importance score |
access_count | integer | Times this memory was retrieved |
metadata | object | Custom metadata |
created_at | datetime | Creation timestamp |
updated_at | datetime | Last update timestamp |
Update an existing memory. Only provided fields will be updated. Changing content triggers full re-indexing across all storage layers (vectors, BM25, knowledge graph). Supports optimistic locking via If-Match header.
Request body
| Field | Type | Description |
|---|---|---|
content | string | New content (triggers full re-embedding and re-indexing) |
importance | number | Override importance score (0-1). Auto-recalculated if content changes and importance not provided. |
metadata | object | Updated metadata (replaces existing metadata) |
If-Match (header) | string | ETag from GET response for optimistic locking. Returns 412 if memory was modified since. |
Delete a specific memory. This action cannot be undone.
Create multiple memories in a single request. Maximum 100 memories per batch. Requires Starter plan or higher.
Request body
| Field | Type | Description |
|---|---|---|
memoriesrequired | array | Array of memory objects (max 100). Each: {content, importance?, metadata?}. Note: collection_id must be top-level, not per-memory. |
collection_id | string | Add ALL memories to this collection. Must be top-level (not inside individual memory objects). |
app_id | string | App ID for collection resolution |
namespace | string | Namespace for collection resolution |
Response
| Field | Type | Description |
|---|---|---|
created | integer | Number of memories created |
failed | integer | Number of failures |
memory_ids | string[] | IDs of created memories |
errors | string[] | Error details for failures |
Smart memory processing. Async dispatch is true by default: HTTP 202 + job_id and poll_url. Poll the returned canonical URL; /v1/memories/jobs/{job_id} is a compatibility alias. async_dispatch:false returns committed revision events, not necessarily searchable facts. Add wait_for_index:true to observe that exact receipt for a bounded time without repeating extraction.
Request body
| Field | Type | Description |
|---|---|---|
messagesrequired | array | Conversation messages (1-50). Each: {role: "user"|"assistant"|"tool"|"system", content: string, timestamp?: ISO-8601}. Send what a tool returned as role "tool": it is never read as the user's statement, and a JSON reply is read as its values (its keys and raw payload are not stored as facts). Relative dates in a message resolve against the day of its timestamp in the user's zone |
timezone | string | The user's IANA timezone (for example America/New_York). Decides the user's calendar day when a timestamp carries no offset of its own (or a zero offset), or when there is no timestamp. Without it, the collection's timezone setting or a zone learned from that end user's earlier timestamps applies, else UTC. |
collection_id | string | Target collection. Auto-resolves if not provided. |
app_id | string | Application identifier for collection resolution |
namespace | string | Namespace within app |
metadata | object | Custom metadata attached to created memories |
async_dispatch | boolean | Default true. Return 202 + job_id and process in the worker; false waits for inline events. |
wait_for_index | boolean | Default false. Requires explicit async_dispatch:false. Observe the committed outbox only; this does not retry extraction or guarantee completion. |
index_wait_seconds | number | Observation bound from 0.1 to 20 seconds; default 5. Use the same Idempotency-Key to observe the original committed request again. |
Response
| Field | Type | Description |
|---|---|---|
job_id | string | Async default: poll GET /v1/memory-jobs/{job_id} |
poll_url | string | Canonical authenticated job status URL returned on asynchronous acceptance |
status | string | Async default: queued job status |
events | array | Synchronous mode or completed job result: event objects describing what happened |
events[].event | string | "ADD" | "UPDATE" | "DELETE" | "NOOP" |
events[].memory_id | string|null | ID of the affected memory |
events[].content | string|null | A shortened excerpt of new or updated memory content, not a full source snapshot |
events[].previous_content | string|null | Previous content (for UPDATE events) |
events[].reason | string|null | Explanation for the action taken |
facts_extracted | integer | Number of facts extracted from conversation |
memories_created | integer | Number of new memories created |
memories_updated | integer | Number of existing memories updated |
memories_unchanged | integer | Number of facts that matched existing memories (NOOP) |
searchable | boolean | True only when the requested observation authenticates completed indexing and the current affected contents. Source commitment alone is not searchability. |
index_wait_outcome | string|null | satisfied, timed_out, failed, superseded, unavailable or not_applicable. Observation binds full committed hashes and current lifecycle; a legacy receipt without that proof is unavailable. A later edit can supersede the original content; a timeout does not roll back its committed write. |
Example
{
"async_dispatch": false,
"messages": [
{
"role": "user",
"content": "Actually, my name is Jordan, not Alex. I made a mistake earlier."
},
{
"role": "assistant",
"content": "No problem! I've noted that your name is Jordan."
}
]
}{
"events": [
{
"event": "UPDATE",
"memory_id": "mem_abc123",
"content": "Jordan is the user's name",
"previous_content": "Alex is the user's name",
"reason": "User corrected their name from Alex to Jordan"
}
],
"facts_extracted": 1,
"memories_created": 0,
"memories_updated": 1,
"memories_unchanged": 0
}Delete multiple memories by ID in a single request. Maximum 500 IDs per request. Propagates cleanup through all storage layers.
Request body
| Field | Type | Description |
|---|---|---|
idsrequired | string[] | Array of memory IDs to delete (max 500). Preferred field name. |
memory_ids | string[] | Legacy alias of `ids`, still accepted for backward compatibility. Use `ids` in new code. |
Response
| Field | Type | Description |
|---|---|---|
deleted_count | integer | Number of memories successfully deleted |
failed_count | integer | Number of deletions that failed |
errors | string[] | Error details for failures |
Example
{
"ids": [
"mem_abc123",
"mem_def456",
"mem_ghi789"
]
}{
"deleted_count": 3,
"failed_count": 0,
"errors": []
}Delete all memories. Optionally scoped to a specific collection. This action cannot be undone. Cleans up all storage layers including vectors, BM25 indexes, and knowledge graph.
Request body
| Field | Type | Description |
|---|---|---|
collection_id | string (query param) | If provided, only delete memories in this collection. Otherwise deletes ALL memories. |
user_id / agent_id / run_id | string (query param) | With collection_id, delete only this end user's, agent's or run's memories (no confirmation header needed). |
dry_run | boolean (query param) | If true, deletes NOTHING and returns {"deleted_count":0,"dry_run":true,"would_delete":N} so you can preview the blast radius first. |
X-Hebbrix-Confirm-Destructive (header) | string | Required for a delete wider than one end user, agent or run (no collection_id, or collection_id alone): must equal "all-memories", HTTP 428 without it. Not needed for a delete scoped to user_id, agent_id or run_id in a collection, or for dry_run; when sent it must equal "all-memories" (HTTP 400 otherwise). |
Response
| Field | Type | Description |
|---|---|---|
deleted_count | integer | Number of memories deleted (always 0 when dry_run=true) |
dry_run | boolean | Present and true when dry_run=true was passed |
would_delete | integer | Number of memories that WOULD be deleted (only present in dry-run responses) |
failed_count | integer | Number of deletions that failed |
errors | string[] | Error details for failures |
04. Response shape (POST /v1/memories)
By default, POST /v1/memories returns HTTP 202 withjob_id, status and poll_url. This accepts an extraction job; it does not return an inlineresults array. Poll the returned URL with the same credentials until the job completes or fails.
POST /v1/memories → HTTP 202
{
"job_id": "job_example",
"status": "queued",
"poll_url": "/v1/memory-jobs/job_example"
}For direct storage, send infer: false andwait_for_index: true. This skips fact extraction and returns an inline HTTP 200 result. Inspect searchable andindex_wait_status; do not assume a bounded indexing wait succeeded. For inline extraction instead, use /v1/memories/process withasync_dispatch: false.
collection_id: the resolved collection the memories were stored in.processing_status"async": the memory row is persisted and indexed in the background. PollGET /v1/memories/{id}(or use Background Jobs) until it is searchable.created_count,updated_count,skipped_count: a summary derived from the per-row events (ADD / UPDATE / NOOP).
results[].id is the PARENT Memory.id, retrievable via GET /v1/memories/{id}. The proposition-style ids you may see in search results (like uuid::subj=...) are a search-layer artifact and are NOT returned by POST /v1/memories.POST /v1/memories (infer: false, wait_for_index: true) → HTTP 200
{
"results": [
{ "id": "mem_abc123", "event": "ADD", "memory": "User prefers dark mode" }
],
"collection_id": "col_default",
"processing_status": "async",
"created_count": 1,
"updated_count": 0,
"skipped_count": 0
}05. Destructive operations: dry-run & confirmation
Bulk deletes have two safety controls, so you can preview what a delete covers before it runs, and one missing parameter never widens it.
DELETE /v1/memories/all?dry_run=truereturnswould_deleteandwould_delete_by_kindand deletes nothing.would_delete_by_kindsays what the count is made of:current(listed byGET /v1/memories),historical(superseded, duplicate or history rows, listed withinclude_superseded=true) andraw_inputs(the conversation text/v1/memories/processkeeps for extraction, which is not a memory and is never listed). A delete that runs returns the same breakdown indeleted_by_kind.- A delete wider than one end user, agent or run, that is, without
collection_id(every collection) or withcollection_idalone (every user of it), requires the headerX-Hebbrix-Confirm-Destructive: all-memoriesand is refused with HTTP 428 without it. A delete scoped to auser_id,agent_idorrun_idin a collection needs no header; a header that is present must equalall-memories(HTTP 400 otherwise). A dry run never needs it. - Profile facts derived from the deleted memories stop being served as soon as the delete returns.
- The same pattern applies to
DELETE /v1/collections/all, whose confirm value isall-collections.
Forgetting an end user
DELETE /v1/memories/all?collection_id=...&user_id=... (or agent_id) forgets that scope. Besides its memories and their search, graph and profile copies, the delete clears the scope's text from the graph ledger, the index outbox, the payloads of /v1/memories/process and chat-learning jobs (and their cached copies), and deletes its corrections and decisions. Jobs accepted before the delete are cancelled (GET /v1/memories/jobs/{job_id} reports cancelled and returns no text), and a write still in flight is refused.
The response carries deletion_receipt: forgotten_at and, per store, a status of deleted, scrubbed (rows kept for bookkeeping, text cleared), pending (removed by the purge the request staged; poll each of outbox_event_ids at /v1/memories/batches/{id}) or retained with its retention: chat sessions until the session or account is deleted, backups up to 35 days, logs 30 days, the idempotency cache 24 hours. Profile snapshots that may hold the scope's facts (taken since its earliest memory) are deleted with it.
Re-check a forget at any time with GET /v1/memories/deletions/{receipt_id} (the receipt's receipt_id). The answer is recomputed from the stores: complete turns true once the purge has removed every memory the scope held, with its search vectors, graph projections and profile facts; memories_awaiting_purge counts what is left.
import requests
BASE = "https://api.hebbrix.com/v1"
H = {"Authorization": "Bearer <your-api-key>"}
# 1) Dry-run first: preview the blast radius, deletes NOTHING
preview = requests.delete(
f"{BASE}/memories/all",
headers=H,
params={"dry_run": "true"},
).json()
# {"deleted_count": 0, "dry_run": True, "would_delete": 1287,
# "would_delete_by_kind": {"current": 1102, "historical": 141, "raw_inputs": 44}}
print(f"Would delete {preview['would_delete']} memories")
# 2) Confirmed delete: an account-wide delete requires the header
result = requests.delete(
f"{BASE}/memories/all",
headers={**H, "X-Hebbrix-Confirm-Destructive": "all-memories"},
).json()
print(f"Deleted {result['deleted_count']} memories")
# Same safety pattern for collections (confirm value "all-collections")
requests.delete(
f"{BASE}/collections/all",
headers={**H, "X-Hebbrix-Confirm-Destructive": "all-collections"},
)06. Code Examples
Create a Memory
The SDK's memories.create() and POST /v1/memories have different defaults: the SDK stores the content verbatim as one memory unless you pass infer=True, while the REST endpoint called without infer extracts facts. Pass infer and wait_for_index explicitly so a call reads the same through the SDK and over HTTP.
import asyncio
from hebbrix import MemoryClient
async def main():
async with MemoryClient(api_key="mem_sk_...") as client:
collection = await client.collections.create(name="my-agent")
# Simple memory, stored verbatim (POST /v1/memories with infer=false)
# and returned once it is searchable
memory = await client.memories.create(
collection_id=collection["id"],
content="User's favorite color is blue",
infer=False,
wait_for_index=True,
)
print(memory["results"][0]["id"])
# Memory with importance + metadata (tags live inside metadata)
await client.memories.create(
collection_id=collection["id"],
content="User completed Python certification on 2024-01-15",
importance=0.8,
metadata={
"tags": ["education", "python"],
"certification_provider": "Coursera",
"completion_date": "2024-01-15",
},
infer=False,
wait_for_index=True,
)
asyncio.run(main())Process Conversations (fact extraction)
import os
import requests
BASE = "https://api.hebbrix.com/v1"
H = {"Authorization": f"Bearer {os.environ['HEBBRIX_API_KEY']}"}
# POST /v1/memories/process: hand it a chat transcript; the backend
# extracts atomic facts, detects conflicts, and emits ADD/UPDATE/NOOP
# events for each resulting memory. Explicit false requests inline results;
# omit it for the default 202 job receipt and poll the returned poll_url.
r = requests.post(
f"{BASE}/memories/process",
headers=H,
json={
"async_dispatch": False,
"messages": [
{"role": "user", "content": "Hi! My name is Alex and I work at Acme Corp."},
{"role": "assistant", "content": "Nice to meet you, Alex!"},
]
},
)
result = r.json()
print(f"Facts extracted: {result['facts_extracted']}")
print(f"Created: {result['memories_created']}")
print(f"Updated: {result['memories_updated']}")
# Later, user corrects their name: the old memory is updated
r = requests.post(
f"{BASE}/memories/process",
headers=H,
json={
"async_dispatch": False,
"messages": [
{"role": "user", "content": "Actually, my name is Jordan, not Alex."},
{"role": "assistant", "content": "No problem, Jordan!"},
]
},
)
result = r.json()
# result["events"][0]["event"] == "UPDATE"
# result["events"][0]["previous_content"] == "Alex is the user's name"Batch Create
import os
import requests
BASE = "https://api.hebbrix.com/v1"
H = {"Authorization": f"Bearer {os.environ['HEBBRIX_API_KEY']}"}
# POST /v1/memories/batch: create multiple memories in one request (max 100).
# Note: collection_id is top-level, NOT per-memory.
memories = [
{"content": "User prefers email over phone calls"},
{"content": "User works in software development"},
{"content": "User is based in EST timezone"},
]
r = requests.post(
f"{BASE}/memories/batch",
headers=H,
json={
"memories": memories,
"collection_id": "YOUR_COLLECTION_ID",
},
)
result = r.json()
print(f"Created {result['created']} memories")Large imports: readiness history by history
POST /v1/memories/batch returns a readiness_url, the batch receipt at GET /v1/memories/batches/{event_id}. Every record of a batch is keyword-searchable within seconds of the write, before it is fully indexed: keyword_searchable: true (per memory, and counts.keyword_searchable for the batch) means keyword search already returns the record for the words it contains. Within an account, an import's histories (the end user, agent or run each batch belongs to) then become fully searchable, by meaning as well as by their words, one after another instead of all together near the end; the whole import takes the same time either way. A history someone is asking about moves ahead: a search or Reason request over a scope that is still being indexed gives that scope's pending batches its account's next indexing turns, with no extra call.
Send one end user per batch, so each batch receipt is also that history's readiness. A history is fully searchable when every batch you sent for it reports searchable: true on GET /v1/memories/batches/{event_id}; gate anything that needs the whole history on that. Poll the receipt (or GET /v1/collections/{collection_id}/readiness for a whole import) with the original scope, send an Idempotency-Key with every batch, and never resubmit accepted content because indexing is still running.
The receipt's indexing estimates when the batch will be fully searchable, counting the work queued ahead of it, including other histories and accounts sharing the indexer: estimated_seconds_remaining is the total wall-clock time, estimated_wait_seconds the time until the batch is scheduled and estimated_processing_seconds its own work. When a reliable estimate cannot be made (no throughput measured yet, the indexer paused, a failure), they are null and estimate_unavailable_reason says why. Estimates guide polling; gate on searchable: true, never on an estimate.
indexing.estimate_scope: "searchable" says what those estimates cover: the time until the batch is searchable, never full completion. After that the knowledge-graph, profile and revision stages can still run. Each entry in stages carries its own estimated_seconds_remaining (from the work queued ahead of the batch and that stage's observed rate), or null with estimate_unavailable_reason; a pending stage never reports 0. completion_estimate gives the time until complete: the largest estimate among the stages still open, or null naming the stage without one. Search and Reason never read the graph, so they are safe once searchable is true; graph views and graph search need the graph stage completed.
Readiness and estimate fields
Every readiness and estimate field covers exactly one state. Searchable means every live record has its semantic and keyword vectors (the dense and lexical stages); complete means every requested stage, graph, profile and revision included, has ended. A field that covers searchable says nothing about complete: a batch can be fully searchable, with indexing.estimated_seconds_remaining: 0, indexing.status: "completed" and completed_at set, while complete is false and its graph stage is pending. Wait for complete with completion_estimate.
| Field | Where | Covers | What its values mean |
|---|---|---|---|
searchable | Batch receipt (GET /v1/memories/batches/{event_id}), GET /v1/memories/{memory_id}, write responses | Searchable | true: search (fast and quality) and Reason can use every live record. Not graph, profile or revision. |
keyword_searchable, counts.keyword_searchable | Batch receipt, memory, write responses, collection readiness | Keyword vectors written | true: search returns the records for the words they contain; a paraphrase may still miss them until searchable. |
complete | Batch receipt | Complete | true: every requested stage is completed or failed; check each stage's failed count. false: completion_estimate.open_stages lists what is pending. |
counts.accepted, queued, processing, searchable, failed, deleted, superseded | Batch receipt | Searchable, per record | Disjoint search-readiness counts; deleted and superseded records leave them. Graph, profile and revision are not counted here. |
memories[].state, searchability_reason | Batch receipt, memory | Searchable, one record | Why one record is or is not searchable (searchable, keyword_only, index_pending, index_failed, or the terminal superseded, duplicate, excluded). |
stages.<stage>.status | Batch receipt | That stage only: dense, lexical (searchable), graph, profile, revision | pending, completed, failed (with reason) or not_requested; the last three have ended. |
stages.<stage>.completed, pending, failed | Batch receipt | That stage only | The receipt's memories in each state for the stage. |
completed_at | Batch receipt | Searchable | When the dense and lexical stages completed, the same moment as timings.searchable_at. Not when the batch is complete. |
indexing.status | Batch receipt, memory, collection readiness | Searchable | The search-indexing delivery: pending, processing, completed or failed. completed means searchable, not complete. |
indexing.estimate_scope | Batch receipt, collection readiness | Always searchable: names what every indexing estimate below covers. | |
indexing.estimated_seconds_remaining | Batch receipt, collection readiness | Searchable | Seconds until searchable. 0: no record is left to index, even while other stages are pending. null: no reliable estimate (estimate_unavailable_reason). |
indexing.estimated_wait_seconds, estimated_processing_seconds | Batch receipt, collection readiness | Searchable | The two parts of that estimate: until the indexer starts on the remaining records, and their own indexing once started. |
indexing.records_remaining, observed_records_per_second, work_ahead_characters, queue_open_writes, queue_oldest_age_seconds | Batch receipt, collection readiness | Searchable | What the search-readiness estimate is computed from: records left, the observed rate, the text queued ahead, the shared queue. |
indexing.estimate_unavailable_reason | Batch receipt, collection readiness | Searchable | Why the indexing estimates are null. |
stages.<stage>.estimated_seconds_remaining | Batch receipt | That stage only (stages.<stage>.estimate_scope is the stage's name) | Seconds until the stage ends for the receipt. 0 only when it is completed or not_requested; never 0 while pending; null with estimate_unavailable_reason when no reliable estimate exists or the stage failed. |
stages.<stage>.work_ahead, observed_per_second | Batch receipt | That stage only | The stage's queue ahead of the receipt and its observed rate, in the stage's own units. |
completion_estimate.estimated_seconds_remaining | Batch receipt | Complete (completion_estimate.scope and estimate_scope are complete) | Seconds until complete: the largest pending stage's estimate. 0 only when complete is true; never 0 while a stage is pending; null with estimate_unavailable_reason when a pending stage has no estimate. |
completion_estimate.limiting_stage, open_stages | Batch receipt | Complete | The stage that sets the estimate (or the first pending stage without one), and every pending stage. |
Retry-After header | Batch receipt | Searchable, then complete | Follows indexing.estimated_seconds_remaining until searchable, then completion_estimate.estimated_seconds_remaining. |
timings.* | Batch receipt | Per state, for this batch | When the batch reached each state (accepted_at, keyword_searchable_at, searchable_at, graph_completed_at, revision_completed_at) and the seconds_to_* after acceptance; null until reached. Profile is not timed. |
ready, estimated_seconds_remaining, estimate_scope | GET /v1/collections/{collection_id}/readiness | Searchable, whole collection | ready: true with an estimate of 0: the collection's records are searchable. Not graph, profile or revision: read each batch receipt's complete. |
open_writes, oldest_pending_age_seconds, observed_timings | Collection readiness | Searchable | The collection's open writes, the age of the oldest pending one and, with ?timings=true, the last hour's observed timings for its writes. |
status | GET /v1/memory-jobs/{job_id} | Extraction | queued, processing, retrying, indexing_pending (extracted, indexing), completed or failed. completed ends extraction, not the receipt: poll readiness_url for searchable and complete. |
indexing on a search response | POST /v1/search, POST /v1/search/reason | Searchable, the searched scope | Pending records of the scope at query time (status: "incomplete"), with answer_risk. |
Read estimates again on every poll; gate on searchable or complete, never on an estimate reaching zero.
List and Filter (SDK)
import asyncio
import os
from hebbrix import MemoryClient
async def main():
async with MemoryClient(api_key=os.environ["HEBBRIX_API_KEY"]) as client:
# --- Explicit page-at-a-time access ---
page = await client.memories.list_page(limit=50)
# page = {"items": [...], "next_cursor": str | None,
# "has_more": bool, "total_count": int}
print(f"Showing {len(page['items'])} of {page['total_count']} memories")
# Fetch the next page if there is one
if page["has_more"]:
next_page = await client.memories.list_page(
cursor=page["next_cursor"], limit=50
)
print(f"Next page has {len(next_page['items'])} memories")
# Filter by collection
page = await client.memories.list_page(
collection_id="col_customer_support", limit=20
)
# --- Simple "give me everything" iteration ---
# iter_all follows next_cursor until has_more == False
async for memory in client.memories.iter_all(collection_id="col_customer_support"):
print(memory["id"], memory["content"][:80])
asyncio.run(main())List and Filter (raw HTTP)
import os
import requests
BASE = "https://api.hebbrix.com/v1"
H = {"Authorization": f"Bearer {os.environ['HEBBRIX_API_KEY']}"}
# List all memories (cursor-paginated response)
r = requests.get(f"{BASE}/memories", headers=H, params={"limit": 50})
page = r.json() # {"items": [...], "next_cursor": ..., "has_more": ..., "total_count": ...}
# Paginate through all
cursor = None
while True:
params = {"limit": 100}
if cursor:
params["cursor"] = cursor
page = requests.get(f"{BASE}/memories", headers=H, params=params).json()
for memory in page["items"]:
process(memory)
if not page.get("has_more") or not page.get("next_cursor"):
break
cursor = page["next_cursor"]07. cURL Examples
/v1/memoriescurl -X POST "https://api.hebbrix.com/v1/memories" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "User prefers dark mode",
"tags": [
"preferences"
]
}'/v1/memories?limit=10curl -X GET "https://api.hebbrix.com/v1/memories?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/v1/memories/mem_abc123curl -X DELETE "https://api.hebbrix.com/v1/memories/mem_abc123" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/v1/memories/processcurl -X POST "https://api.hebbrix.com/v1/memories/process" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"async_dispatch": false,
"messages": [
{
"role": "user",
"content": "My name is Jordan and I work at Acme Corp."
},
{
"role": "assistant",
"content": "Nice to meet you, Jordan!"
}
]
}'/v1/memories/bulk-deletecurl -X POST "https://api.hebbrix.com/v1/memories/bulk-delete" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ids": [
"mem_abc123",
"mem_def456"
]
}'/v1/memories/allcurl -X DELETE "https://api.hebbrix.com/v1/memories/all" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"08. Memory Lifecycle
When you create a memory, Hebbrix automatically:
- Embeds the Content. Converts text to vector embeddings for semantic search.
- Calculates Importance. Analyzes content to determine relevance and priority.
- Extracts Entities. Identifies people, places, concepts and adds to knowledge graph.
- Indexes for Search. Adds to BM25 index for keyword matching alongside vectors.
- Detects Conflicts. When using /process, checks for conflicting memories and automatically updates or removes outdated information.