Skip to main content
If organizational context is your product’s knowledge base, customer context is each customer’s internal wiki. Every user in the organization can access it, but outsiders cannot.

When to use customer context

Customer context is the right scope for knowledge that is specific to one organization but shared across its users:

Company policies

Internal guidelines, approval workflows, escalation procedures, and compliance requirements specific to the customer.

Team and structure

Organizational hierarchy, team compositions, role definitions, and reporting lines.

Shared projects

Active projects, roadmaps, milestones, and cross-team initiatives that multiple users need context about.

Terminology and conventions

Internal jargon, product names, acronyms, and naming conventions specific to the customer’s domain.

How to ingest customer context

Customer context is created by ingesting documents with a customer_id but without a user_id. This causes Synap to store the resulting memories at the Customer scope, making them visible to all users within that customer organization.
from synap import Synap

sdk = Synap(api_key="your_api_key")

# Ingest company documentation for Acme Corp
await sdk.memories.create(
    document="""
    Acme Corp Engineering Handbook

    ## Development Standards
    - All services must use Python 3.11 or later
    - PostgreSQL is the primary database for all services
    - Every PR requires two code review approvals
    - CI must pass before merge (linting, tests, type checking)

    ## Deployment Process
    - Deployments to staging: any time
    - Deployments to production: Tuesdays and Thursdays, 10am-2pm PT
    - Hotfix deployments: requires VP Engineering approval
    - Rollback policy: automatic rollback if error rate exceeds 1%

    ## Team Structure
    - Platform Team (8 engineers): infrastructure, CI/CD, observability
    - Product Team (12 engineers): core product features, API
    - Data Team (5 engineers): analytics, ML pipelines, data warehouse
    """,
    document_type="document",
    customer_id="acme_corp"
    # No user_id -- shared across all users at Acme Corp
)
Be careful not to accidentally include a user_id when ingesting customer-wide documents. If you include a user_id, the memories will be stored at the User scope and will only be visible to that one user, defeating the purpose of shared organizational knowledge.

How to retrieve customer context

Customer context can be retrieved directly (for customer-scoped queries) or as part of the full scope chain during user conversations.

Direct retrieval (customer scope and below)

Use sdk.customer.context.fetch() to retrieve memories scoped to a specific customer, plus any applicable Client and World scope memories:
# Retrieve customer context for Acme Corp
context = await sdk.customer.context.fetch(
    customer_id="acme_corp",
    search_query=["deployment process", "production releases"]
)

# Results include CUSTOMER + CLIENT + WORLD scopes (no USER scope)
# context.facts might include:
# - "Production deployments: Tuesdays and Thursdays, 10am-2pm PT" (CUSTOMER)
# - "Hotfix requires VP Engineering approval" (CUSTOMER)
# - "Platform supports blue-green deployment strategy" (CLIENT)

As part of user conversations

When retrieving context for a specific user, customer context is automatically included in the scope chain:
# Alice asks about deployment rules
context = await sdk.user.context.fetch(
    user_id="user_alice",
    customer_id="acme_corp",
    search_query=["when can I deploy to production"]
)

# Scope chain results:
# USER:     "Alice deployed the billing service last Tuesday" (highest priority)
# CUSTOMER: "Production deployments: Tues/Thurs 10am-2pm PT" (high priority)
# CLIENT:   "Blue-green deployment support available" (medium priority)

Multi-user scenarios

The power of customer context is that it provides shared knowledge to every user in the organization. Consider a scenario with three users at Acme Corp:
# Alice (engineering lead) ingests team planning notes
await sdk.memories.create(
    document="Sprint planning: migrating auth service to OAuth 2.1 by end of Q2.",
    document_type="document",
    customer_id="acme_corp"  # Shared with all Acme users
)

# Bob queries about current projects
context = await sdk.user.context.fetch(
    user_id="user_bob",
    customer_id="acme_corp",
    search_query=["current engineering projects"]
)
# Bob sees: "Migrating auth service to OAuth 2.1 by end of Q2"

# Carol queries about team priorities
context = await sdk.user.context.fetch(
    user_id="user_carol",
    customer_id="acme_corp",
    search_query=["team priorities this quarter"]
)
# Carol also sees: "Migrating auth service to OAuth 2.1 by end of Q2"
All three users benefit from the same customer-scoped knowledge, while each also has access to their own user-scoped memories. The result is an agent that understands both the shared organizational context and each individual’s personal situation.

What each user sees

MemorySource scopeAlice seesBob seesCarol sees
”Auth migration to OAuth 2.1 by Q2”CUSTOMERYesYesYes
”Alice prefers Slack for notifications”USER (Alice)YesNoNo
”Bob is on the Platform team”USER (Bob)NoYesNo
”Carol handles on-call for Data team”USER (Carol)NoNoYes
”Product supports OAuth 2.0 and 2.1”CLIENTYesYesYes

How customer context differs from organizational context

Both customer context and organizational context provide shared knowledge, but they differ in scope and audience:
AspectOrganizational contextCustomer context
Scope levelCLIENTCUSTOMER
VisibilityAll customers, all usersAll users in one customer
Who provides itYou (the application developer)You or the customer’s data
What it containsProduct docs, announcements, domain knowledgeCompany policies, team info, shared projects
Caching30-minute TTLNo special caching
Changes how oftenInfrequently (product releases)Moderately (as org evolves)
Example”Our API supports pagination via cursor""Acme Corp uses Jira for project tracking”
When both organizational and customer context are relevant to a query, customer context takes priority in ranking because it is the narrower scope. However, both are returned if token budget allows, giving the agent a complete picture.

Code example: full customer context workflow

Here is a complete example showing how to ingest customer-specific documentation and then use it in user conversations:
from synap import Synap

sdk = Synap(api_key="your_api_key")

# Step 1: Ingest customer-specific documents
async def onboard_customer(customer_id: str, company_docs: list[str]):
    """Load company documents during customer onboarding."""
    for doc in company_docs:
        await sdk.memories.create(
            document=doc,
            document_type="document",
            customer_id=customer_id
        )
    print(f"Onboarded {len(company_docs)} documents for {customer_id}")

# Step 2: Use customer context in conversations
async def handle_message(user_id: str, customer_id: str, message: str):
    """Handle a user message with full context chain."""
    # Fetch context across all applicable scopes
    context = await sdk.user.context.fetch(
        user_id=user_id,
        customer_id=customer_id,
        search_query=[message]
    )

    # Build a rich prompt with scoped context
    prompt = f"""You are an AI assistant with knowledge about the user
and their organization.

Organizational knowledge (product-wide):
{context.facts}

User preferences:
{context.preferences}

User message: {message}

Respond using all available context. Prioritize user-specific and
organization-specific information over general product knowledge.
"""
    # Pass to your LLM...

# Usage
await onboard_customer("acme_corp", [
    "Acme Corp uses Slack for internal communication...",
    "Acme Corp's fiscal year runs April to March...",
    "Engineering team OKRs for Q2: migrate to microservices...",
])

await handle_message(
    user_id="user_alice",
    customer_id="acme_corp",
    message="When does our fiscal year end?"
)
# Agent responds: "Acme Corp's fiscal year ends in March."

Next steps

Organizational Context

Learn about application-wide knowledge at the Client scope.

Memory Scopes

Understand the full scope chain and how scopes interact during retrieval.

Multi-User Scoping Guide

Step-by-step guide to implementing multi-user, multi-tenant memory.

Customers & Users

Understand the entity model for customers and users.