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

# Memory

> Store and retrieve structured facts per vault

Vault memory lets you attach structured knowledge to a vault — facts, party details, deadlines, preferences, and more. Agents and workflows can read and search this memory to stay context-aware without re-processing documents.

Use vault memory when you want to:

* persist key facts extracted from documents (parties, dates, issues)
* give agents per-case context that survives across sessions
* build a correction layer so agents learn from feedback

## Entry types

Every memory entry has a `type` that describes the kind of knowledge it holds:

| Type         | Use case                                               |
| ------------ | ------------------------------------------------------ |
| `fact`       | General statements ("Client prefers email over phone") |
| `party`      | People and organizations involved                      |
| `issue`      | Legal or business issues identified                    |
| `deadline`   | Important dates and filing deadlines                   |
| `discovery`  | Discovery-related findings                             |
| `correction` | Corrections to previous agent outputs                  |
| `preference` | User or client preferences                             |

## Create an entry

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
POST /vault/{id}/memory
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl -X POST "https://api.case.dev/vault/$VAULT_ID/memory" \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "type": "fact",
      "content": "The client prefers email communication over phone calls.",
      "source": "intake-form",
      "tags": ["communication", "preference"]
    }'
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import Casedev from 'casedev';

  const client = new Casedev({ apiKey: 'sk_case_YOUR_API_KEY' });

  const { entry } = await client.vault.memory.create('VAULT_ID', {
    type: 'fact',
    content: 'The client prefers email communication over phone calls.',
    source: 'intake-form',
    tags: ['communication', 'preference'],
  });

  console.log(entry.id); // mem_abc123
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import casedev

  client = casedev.Casedev(api_key='sk_case_YOUR_API_KEY')

  result = client.vault.memory.create(
      'VAULT_ID',
      type='fact',
      content='The client prefers email communication over phone calls.',
      source='intake-form',
      tags=['communication', 'preference'],
  )

  print(result.entry.id)  # mem_abc123
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  entry, _ := client.Vault.Memory.New(ctx, "VAULT_ID", casedev.VaultMemoryNewParams{
  	Type:    casedev.F("fact"),
  	Content: casedev.F("The client prefers email communication over phone calls."),
  	Source:  casedev.F("intake-form"),
  	Tags:    casedev.F([]string{"communication", "preference"}),
  })
  fmt.Println(entry.Entry.ID)
  ```
</CodeGroup>

<Info>
  The `casedev` CLI does not yet expose vault memory commands. Use cURL or one of the supported SDKs above.
</Info>

### Request body

| Field     | Type      | Required | Description                                                                           |
| --------- | --------- | -------- | ------------------------------------------------------------------------------------- |
| `type`    | string    | Yes      | One of: `fact`, `party`, `issue`, `deadline`, `discovery`, `correction`, `preference` |
| `content` | string    | Yes      | The memory content                                                                    |
| `source`  | string    | No       | Where this fact came from (e.g. `intake-form`, `agent-extraction`)                    |
| `tags`    | string\[] | No       | Tags for filtering                                                                    |

### Response

```json theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
{
  "entry": {
    "id": "mem_abc123",
    "type": "fact",
    "content": "The client prefers email communication over phone calls.",
    "source": "intake-form",
    "tags": ["communication", "preference"],
    "created_by": "key_xxx",
    "created_at": "2026-04-02T12:00:00.000Z",
    "updated_at": "2026-04-02T12:00:00.000Z"
  }
}
```

## Search memory

Search entries by meaning — not just keywords.

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
POST /vault/{id}/memory/search
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl -X POST "https://api.case.dev/vault/$VAULT_ID/memory/search" \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"query": "how does the client prefer to be contacted?", "limit": 5}'
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const { results } = await client.vault.memory.search('VAULT_ID', {
    query: 'how does the client prefer to be contacted?',
    limit: 5,
  });

  for (const entry of results) {
    console.log(`[${entry.type}] ${entry.content}`);
  }
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result = client.vault.memory.search(
      'VAULT_ID',
      query='how does the client prefer to be contacted?',
      limit=5,
  )

  for entry in result.results:
      print(f'[{entry.type}] {entry.content}')
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  resp, _ := client.Vault.Memory.Search(ctx, "VAULT_ID", casedev.VaultMemorySearchParams{
  	Query: casedev.F("how does the client prefer to be contacted?"),
  	Limit: casedev.F(int64(5)),
  })
  fmt.Println(resp.Results)
  ```
</CodeGroup>

### Parameters

| Field   | Type      | Required | Description                     |
| ------- | --------- | -------- | ------------------------------- |
| `query` | string    | Yes      | Natural-language search query   |
| `types` | string\[] | No       | Filter by entry type            |
| `tags`  | string\[] | No       | Filter by tag                   |
| `limit` | number    | No       | Max results (1–100, default 10) |

## List entries

Retrieve all memory entries for a vault.

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
GET /vault/{id}/memory
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl "https://api.case.dev/vault/$VAULT_ID/memory" \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY"
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  const { entries } = await client.vault.memory.list('VAULT_ID');

  for (const entry of entries) {
    console.log(`[${entry.type}] ${entry.content}`);
  }
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result = client.vault.memory.list('VAULT_ID')

  for entry in result.entries:
      print(f'[{entry.type}] {entry.content}')
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  resp, _ := client.Vault.Memory.List(ctx, "VAULT_ID")
  fmt.Println(resp.Entries)
  ```
</CodeGroup>

## Update an entry

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
PATCH /vault/{id}/memory/{entryId}
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl -X PATCH "https://api.case.dev/vault/$VAULT_ID/memory/$ENTRY_ID" \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "content": "Updated: client now prefers phone calls.",
      "tags": ["communication", "preference", "updated"]
    }'
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  await client.vault.memory.update('VAULT_ID', 'ENTRY_ID', {
    content: 'Updated: client now prefers phone calls.',
    tags: ['communication', 'preference', 'updated'],
  });
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  client.vault.memory.update(
      'VAULT_ID',
      'ENTRY_ID',
      content='Updated: client now prefers phone calls.',
      tags=['communication', 'preference', 'updated'],
  )
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  client.Vault.Memory.Update(ctx, "VAULT_ID", "ENTRY_ID", casedev.VaultMemoryUpdateParams{
  	Content: casedev.F("Updated: client now prefers phone calls."),
  	Tags:    casedev.F([]string{"communication", "preference", "updated"}),
  })
  ```
</CodeGroup>

### Parameters

| Field     | Type           | Required | Description                          |
| --------- | -------------- | -------- | ------------------------------------ |
| `content` | string         | No       | Updated content                      |
| `source`  | string \| null | No       | Updated source (set `null` to clear) |
| `tags`    | string\[]      | No       | Replacement tag list                 |

At least one field must be provided.

## Delete an entry

```bash title="Endpoint" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
DELETE /vault/{id}/memory/{entryId}
```

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  curl -X DELETE "https://api.case.dev/vault/$VAULT_ID/memory/$ENTRY_ID" \
    -H "Authorization: Bearer sk_case_YOUR_API_KEY"
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  await client.vault.memory.delete('VAULT_ID', 'ENTRY_ID');
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  client.vault.memory.delete('VAULT_ID', 'ENTRY_ID')
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  client.Vault.Memory.Delete(ctx, "VAULT_ID", "ENTRY_ID")
  ```
</CodeGroup>

Returns `{ "deleted": true }` on success.
