Collections
Organize memories into collections for multi-tenant applications, different projects, or separate knowledge domains.
Use Cases
- Multi-tenant Apps. One collection per customer to keep data isolated.
- Knowledge Domains. Separate collections for different topics or projects.
Endpoints
Create a new collection to organize memories. A name you already use returns that collection with 200 instead of creating another (201 for a new one), so creating by name is safe to retry; give each test or tenant its own name.
Request body
| Field | Type | Description |
|---|---|---|
namerequired | string | Collection name (min 1, max 255 characters) |
description | string | Collection description (max 2000 characters) |
metadata | object | Custom metadata |
sensitive_data | string | object | What happens to passwords, PINs, keys, card and account numbers and IDs written to this collection: "redact" (default), "reject" or "allow", or {mode, categories}. See Privacy controls |
List all collections for the authenticated user, newest first: limit (max 100), then next_cursor as cursor for the next page, or offset to skip rows (not both). name and name_prefix filter by name.
Get details for a specific collection.
Update collection name, description, or metadata.
Delete a collection. Cascades to ALL memories, documents, and media inside; nothing is left behind. This is irreversible.
Delete multiple collections in one request. Each collection's memories, documents, and media are also deleted.
Request body
| Field | Type | Description |
|---|---|---|
collection_idsrequired | string[] | Array of collection IDs to delete. |
Response
| Field | Type | Description |
|---|---|---|
deleted_count | integer | Collections successfully deleted |
failed_count | integer | Collections that could not be deleted |
errors | string[] | Error details (one per failed collection) |
Delete every collection the caller owns, and everything in them. Scoped by the X-Hebbrix-Source header (so app data and API data are deleted independently).
Fetch (or lazily create) the caller's default collection. This is the bucket that receives uploads and memories when no collection_id is supplied.
Where does new data go?
POST /v1/memories, POST /v1/memories/raw, POST /v1/memories/batch, POST /v1/documents/upload, POST /v1/media/upload) accepts an optional collection_id.- Provide
collection_id→ data lands in that collection. - Omit it → data is auto-assigned to the caller's
__default__collection (lazily created on first use). - Document / media upload responses include
collection_auto_assigned: truewhen the server fell back to the default. - Send header
X-Hebbrix-Require-Collection: trueto forbid silent defaulting: an omittedcollection_idreturns HTTP 422.
Code Examples
import asyncio
from hebbrix import MemoryClient
async def main():
async with MemoryClient(api_key="mem_sk_...") as client:
# Create a collection for a customer
collection = await client.collections.create(
name="Customer: Acme Corp",
description="Memories for Acme Corp support",
metadata={"customer_id": "acme_123", "plan": "enterprise"},
)
# Add a memory inside that collection
await client.memories.create(
collection_id=collection["id"],
content="Acme Corp uses Python for their backend",
infer=False, # store verbatim (the SDK default; REST extracts by default)
wait_for_index=True, # return once it is searchable
)
# Scope search to this collection only
results = await client.search(
query="what language do they use?",
collection_id=collection["id"],
)
for r in results:
print(r["content"])
# When the customer leaves, one call wipes memories,
# documents, and media that belonged to them.
await client.collections.delete(collection["id"])
asyncio.run(main())