> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# customer.context.fetch

> Retrieve customer-scoped context: shared organizational knowledge, policies, and team-wide memories visible to every user within a customer.

```python theme={null}
await sdk.customer.context.fetch(
    customer_id,
    conversation_id=None,
    search_query=None,
    max_results=10,
    types=None,
    mode="fast",
)
```

Retrieve context scoped to a specific customer organization. Customer-scoped memories are visible to all users within that customer. This is useful for fetching shared organizational knowledge, company policies, and team-wide context.

### Parameters

<ParamField path="customer_id" type="string" required>
  The customer identifier to fetch context for. Required on B2B; auto-resolved on B2C. See [B2C vs B2B](/concepts/memory-scopes#b2c-vs-b2b-which-scopes-apply-to-you).
</ParamField>

<ParamField path="conversation_id" type="string">
  Optional conversation identifier. When provided, results are biased toward memories relevant to the active conversation. When supplied, it must be a valid UUID [registered via `record_message`](/concepts/context-end-to-end#short-term-context).
</ParamField>

<ParamField path="search_query" type="string | string[]">
  One or more search queries to find relevant customer memories. If omitted, returns the most recent and highest-confidence customer-scoped memories.
</ParamField>

<ParamField path="max_results" type="integer">
  Maximum number of memory items to return. Defaults to `10`. Maximum `50`.
</ParamField>

<ParamField path="types" type="string[]">
  Filter results to specific memory types. If omitted, all types are included.

  | Value            | Description                                              |
  | ---------------- | -------------------------------------------------------- |
  | `fact`           | Factual information about the customer organization      |
  | `preference`     | Customer organizational preferences                      |
  | `episode`        | Significant events within the customer organization      |
  | `emotion`        | Sentiment and emotional context within the organization  |
  | `temporal_event` | Time-bound events (project deadlines, fiscal year, etc.) |
</ParamField>

<ParamField path="mode" type="string">
  Retrieval mode that controls the speed-quality tradeoff: the retrieval axis (`fast` vs `accurate`) of [Retrieval Modes](/concepts/retrieval-modes).

  | Value      | Description                                                       |
  | ---------- | ----------------------------------------------------------------- |
  | `fast`     | Vector search only. Lower latency. **Default.**                   |
  | `accurate` | Full vector + graph + re-ranking. Higher quality, higher latency. |

  For real per-mode latency on your instance, see **Dashboard → Usage**.
</ParamField>

### Returns

A `ContextResponse` with the following fields:

<ResponseField name="facts" type="array">
  Array of fact memories relevant to the query.
</ResponseField>

<ResponseField name="preferences" type="array">
  Array of preference memories.
</ResponseField>

<ResponseField name="episodes" type="array">
  Array of episode memories.
</ResponseField>

<ResponseField name="emotions" type="array">
  Array of emotion memories.
</ResponseField>

<ResponseField name="metadata" type="object">
  Response metadata including `total_results`, `query_time_ms`, `tokens_used`, `scope`, and `mode`.
</ResponseField>

### Example

```python theme={null}
from maximem_synap import MaximemSynapSDK

sdk = MaximemSynapSDK(api_key="synap_your_key_here")
await sdk.initialize()

context = await sdk.customer.context.fetch(
    customer_id="cust_acme_corp",
    search_query=["project management tools", "engineering stack"],
    max_results=5,
    types=["fact", "preference"],
    mode="accurate",
)

for fact in context.facts:
    print(f"[{fact.confidence:.2f}] {fact.content}")
```

```json Response theme={null}
{
  "facts": [
    {
      "id": "mem_cust_f1a2b3c4",
      "content": "Acme Corp uses Jira for project management and Slack for communication",
      "confidence": 0.94,
      "entities": [
        { "canonical_name": "Acme Corp", "type": "organization", "entity_id": "ent_acme001" }
      ],
      "source": {
        "ingestion_id": "ing_cust_7a8b9c0d",
        "document_type": "ai-chat-conversation",
        "document_created_at": "2025-01-12T14:30:00Z"
      },
      "relevance_score": 0.92,
      "scope": "customer"
    },
    {
      "id": "mem_cust_d5e6f7a8",
      "content": "Engineering team uses Python 3.11 and PostgreSQL for all services",
      "confidence": 0.91,
      "entities": [
        { "canonical_name": "Acme Corp Engineering", "type": "team", "entity_id": "ent_acme_eng" }
      ],
      "source": {
        "ingestion_id": "ing_cust_0a9b8c7d",
        "document_type": "document",
        "document_created_at": "2025-01-08T09:00:00Z"
      },
      "relevance_score": 0.88,
      "scope": "customer"
    }
  ],
  "preferences": [
    {
      "id": "mem_cust_b9c0d1e2",
      "content": "Team prefers detailed code reviews over quick approvals",
      "confidence": 0.87,
      "entities": [],
      "source": {
        "ingestion_id": "ing_cust_7a8b9c0d",
        "document_type": "ai-chat-conversation",
        "document_created_at": "2025-01-12T14:30:00Z"
      },
      "relevance_score": 0.79,
      "scope": "customer"
    }
  ],
  "episodes": [],
  "emotions": [],
  "metadata": {
    "total_results": 3,
    "query_time_ms": 187,
    "tokens_used": 456,
    "scope": {
      "customer_id": "cust_acme_corp",
      "client_id": "cli_a1b2c3d4e5f67890"
    },
    "mode": "accurate"
  }
}
```

<Tip>
  Customer-scoped memories take priority over client-scoped memories when they cover the same topic, following the [scope chain](/concepts/memory-scopes) priority rules. To merge customer and client context in a single call, use [`sdk.context.fetch`](/sdk-reference/context/fetch).
</Tip>

### Raises

* `InvalidInputError`: when `mode` is not `"fast"` or `"accurate"`.
* `SDKNotInitializedError`: when called before `await sdk.initialize()`.
* `AuthenticationError`: when the API key is invalid or revoked.
* `ContextNotFoundError`: when `customer_id` does not exist for this instance.

### See also

* [`sdk.user.context.fetch`](/sdk-reference/context/user-fetch): user-scoped context
* [`sdk.client.context.fetch`](/sdk-reference/context/client-fetch): organizational (client) context
* [`sdk.context.fetch`](/sdk-reference/context/fetch): unified scope-chain fetch
