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

# Scopes and Projects

> Separate memory by customer, workspace, and project.

MemContext gives you two simple fields for organizing memory: `scope` and
`project`.

Use `scope` when your API key serves more than one user, tenant, organization, or
workspace. Use `project` when you want to group related memories inside that
scope.

For Context Vault, there are two additional fields: `workspaceId` and optional
`vaultId`. The workspace is the hard company/team/account boundary. A vault is
the shared knowledge container inside that workspace. `scope` is a hard lane
inside the selected workspace or vault. `project` is a soft grouping inside the
selected scope.

## Scope

`scope` is the isolation key. A search with one scope only returns memories saved
with that same scope.

```json theme={null}
{
  "content": "User prefers concise release notes",
  "category": "preference",
  "scope": "user_123"
}
```

Good scope values are stable IDs from your own app, such as:

* `user_123`
* `org_acme`
* `workspace_42`
* `tenant_kakiyo`

If you omit `scope`, the memory belongs to the default area for that API key.
Named scopes are not included unless you pass that scope again during search,
update, delete, feedback, or history calls.

## Project

`project` is a filter inside the selected scope. It is useful for product areas,
repositories, support queues, or customer workspaces.

```json theme={null}
{
  "content": "This project uses PNPM",
  "category": "fact",
  "scope": "user_123",
  "project": "memcontext"
}
```

Projects are not meant for tenant isolation. If two customers must never see each
other's memories, put them in different scopes.

## Context Vault Semantics

For company knowledge bases:

| Field         | Meaning                                               | Example                        |
| ------------- | ----------------------------------------------------- | ------------------------------ |
| `workspaceId` | Hard company, team, customer, or tenant boundary      | `acme_workspace_id`            |
| `vaultId`     | Optional Context Vault container inside the workspace | `engineering_vault_id`         |
| `scope`       | Hard lane inside the workspace                        | `hr`, `engineering`, `billing` |
| `project`     | Soft grouping inside the scope                        | `onboarding`, `api-platform`   |

Use `scope` when retrieving the wrong lane would be risky. Use `project` when
you only need a helpful filter or collection label.

Context Vault search also supports multi-scope retrieval with `scopes`.

```bash theme={null}
GET /api/context-vault/search?workspaceId=...&vaultId=...&query=trial&scopes=dev,billing
```

When `scopes` is provided, MemContext searches those named lanes inside the
selected workspace vault. It does not search other workspaces or vaults.

## Which Field Should I Use?

| Need                                | Use       | Example                   |
| ----------------------------------- | --------- | ------------------------- |
| Separate end users                  | `scope`   | `user_123`                |
| Separate customer tenants           | `scope`   | `tenant_acme`             |
| Separate internal workspaces        | `scope`   | `workspace_support`       |
| Group a codebase, app, or workflow  | `project` | `dashboard`, `api`, `crm` |
| Search all default memories for key | omit both | no `scope`, no `project`  |

## Common Patterns

For a SaaS product:

```typescript theme={null}
await client.save({
  content: "Kakiyo uses Intercom-style support workflows",
  category: "fact",
  scope: "customer_kakiyo",
  project: "support",
});
```

For a coding assistant:

```typescript theme={null}
await client.save({
  content: "The dashboard package uses Next.js",
  category: "fact",
  project: "memcontext",
});
```

For a multi-tenant AI app, always pass the same `scope` on save and search:

```typescript theme={null}
const customerMemory = client.withScope("customer_kakiyo");

await customerMemory.save({
  content: "Kakiyo's support widget should answer in a concise tone",
  category: "preference",
});

const results = await customerMemory.search({
  query: "How should the support widget answer customers?",
});
```

See the [TypeScript SDK](/sdk/typescript) for full usage.
