Hebbrix
Collections

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

Where does new data go?

Every create / upload endpoint (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: true when the server fell back to the default.
  • Send header X-Hebbrix-Require-Collection: true to forbid silent defaulting — omitted collection_id returns HTTP 422.

Code Examples

Python
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",
        )

        # 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())

Assistant

Ask me anything about Hebbrix