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

# Memory / Knowledge Base

> AI memory endpoints for storing and extracting user preferences, decisions, and context

# Memory API

The Memory API manages your AI Knowledge Base — persistent memories that help the AI personalize PRD generation across conversations. Memories are scoped per user and include preferences, decisions, project context, and feedback.

See the [Knowledge Base user guide](/user-guide/knowledge-base) for how memories work in the product.

## List Memories

```http theme={null}
GET /api/memory
```

Retrieve your stored memories, sorted by importance and recent usage.

**Query parameters:**

| Parameter  | Type    | Default | Description                                                             |
| ---------- | ------- | ------- | ----------------------------------------------------------------------- |
| `limit`    | integer | 20      | Max memories to return                                                  |
| `category` | string  | —       | Filter by category: `technical`, `business`, `process`, `style`, `team` |
| `type`     | string  | —       | Filter by type: `preference`, `decision`, `project_context`, `feedback` |
| `active`   | boolean | true    | Set to `false` to include soft-deleted memories                         |

<CodeGroup>
  ```bash curl theme={null}
  curl https://app.thig.ai/api/memory?limit=10&category=style \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/memory?limit=10&category=style', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  });
  const { memories } = await res.json();
  ```

  ```python Python theme={null}
  import requests

  res = requests.get(
      'https://app.thig.ai/api/memory',
      params={'limit': 10, 'category': 'style'},
      headers={'Authorization': 'Bearer YOUR_API_KEY'}
  )
  memories = res.json()['memories']
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "memories": [
    {
      "id": "uuid",
      "userId": "user_123",
      "memoryType": "preference",
      "category": "style",
      "content": "User prefers detailed user stories with acceptance criteria in Given/When/Then format",
      "summary": "Prefers Given/When/Then acceptance criteria",
      "importance": 8,
      "isActive": true,
      "sourceProjectId": "proj_456",
      "lastUsedAt": "2026-03-05T14:30:00Z",
      "createdAt": "2026-02-15T10:00:00Z"
    }
  ]
}
```

***

## Create Memory

```http theme={null}
POST /api/memory
```

Manually add a memory to your Knowledge Base.

**Body:**

| Field                | Type      | Required | Description                                                |
| -------------------- | --------- | -------- | ---------------------------------------------------------- |
| `memoryType`         | string    | Yes      | `preference`, `decision`, `project_context`, or `feedback` |
| `category`           | string    | Yes      | `technical`, `business`, `process`, `style`, or `team`     |
| `content`            | string    | Yes      | The memory content (clear, actionable statement)           |
| `summary`            | string    | No       | Brief 1-line summary                                       |
| `sourceProjectId`    | string    | No       | Project this memory originated from                        |
| `sourceConversation` | object\[] | No       | Conversation messages for context                          |
| `importance`         | integer   | No       | 1–10 (10 = most important for future context)              |

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://app.thig.ai/api/memory \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "memoryType": "preference",
      "category": "style",
      "content": "Always include acceptance criteria in Given/When/Then format",
      "summary": "Given/When/Then acceptance criteria",
      "importance": 8
    }'
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/memory', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      memoryType: 'preference',
      category: 'style',
      content: 'Always include acceptance criteria in Given/When/Then format',
      summary: 'Given/When/Then acceptance criteria',
      importance: 8
    })
  });
  const { memory } = await res.json();
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "memory": {
    "id": "uuid",
    "userId": "user_123",
    "memoryType": "preference",
    "category": "style",
    "content": "Always include acceptance criteria in Given/When/Then format",
    "summary": "Given/When/Then acceptance criteria",
    "importance": 8,
    "isActive": true,
    "createdAt": "2026-03-06T12:00:00Z"
  }
}
```

***

## Delete Memory

```http theme={null}
DELETE /api/memory?id=MEMORY_ID
```

Soft-deletes a memory (sets `isActive` to false). The memory can still be retrieved by passing `active=false` to the list endpoint.

**Query parameters:**

| Parameter | Type   | Required | Description         |
| --------- | ------ | -------- | ------------------- |
| `id`      | string | Yes      | Memory ID to delete |

<CodeGroup>
  ```bash curl theme={null}
  curl -X DELETE "https://app.thig.ai/api/memory?id=MEMORY_ID" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://app.thig.ai/api/memory?id=${memoryId}`, {
    method: 'DELETE',
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  });
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true
}
```

***

## Extract Memories from Conversation

```http theme={null}
POST /api/memory/extract
```

Uses AI to analyze a conversation and automatically extract reusable memories — preferences, decisions, context, and feedback. Extracted memories are saved to your Knowledge Base.

**Body:**

| Field                    | Type      | Required | Description                                                       |
| ------------------------ | --------- | -------- | ----------------------------------------------------------------- |
| `conversation`           | object\[] | Yes      | Array of message objects (max 50 messages, max 10,000 chars each) |
| `conversation[].role`    | string    | Yes      | `user` or `assistant`                                             |
| `conversation[].content` | string    | Yes      | Message content                                                   |
| `projectId`              | string    | No       | Project the conversation belongs to                               |

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://app.thig.ai/api/memory/extract \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "conversation": [
        {"role": "user", "content": "I prefer user stories with Given/When/Then acceptance criteria"},
        {"role": "assistant", "content": "Noted! I will use Given/When/Then format for all acceptance criteria going forward."},
        {"role": "user", "content": "Also, our tech stack is React + Node.js + PostgreSQL"}
      ],
      "projectId": "proj_123"
    }'
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/memory/extract', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      conversation: [
        { role: 'user', content: 'I prefer user stories with Given/When/Then acceptance criteria' },
        { role: 'assistant', content: 'Noted! I will use Given/When/Then format.' },
        { role: 'user', content: 'Our tech stack is React + Node.js + PostgreSQL' }
      ],
      projectId: 'proj_123'
    })
  });
  const { extracted, saved, memories } = await res.json();
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "extracted": 2,
  "saved": 2,
  "memories": [
    {
      "id": "uuid",
      "memoryType": "preference",
      "category": "style",
      "content": "User prefers Given/When/Then format for acceptance criteria",
      "summary": "Given/When/Then acceptance criteria",
      "importance": 8
    },
    {
      "id": "uuid",
      "memoryType": "project_context",
      "category": "technical",
      "content": "Tech stack: React, Node.js, PostgreSQL",
      "summary": "React + Node.js + PostgreSQL stack",
      "importance": 7
    }
  ]
}
```

<Note>
  Memory extraction uses your configured AI provider (respecting BYOK settings). The AI only extracts genuinely useful, reusable information — it skips trivial or project-specific details that won't apply to future projects.
</Note>

***

## Memory Types

| Type              | Description                                                        |
| ----------------- | ------------------------------------------------------------------ |
| `preference`      | User preferences about PRD style, detail level, terminology        |
| `decision`        | Key decisions made about requirements or architecture              |
| `project_context` | Company, team, or technical stack information                      |
| `feedback`        | Feedback about generated content that indicates future preferences |

## Categories

| Category    | Description                                     |
| ----------- | ----------------------------------------------- |
| `technical` | Technical architecture, stack, infrastructure   |
| `business`  | Business goals, KPIs, stakeholder preferences   |
| `process`   | Development methodology, workflow preferences   |
| `style`     | Writing style, format, detail level preferences |
| `team`      | Team structure, roles, communication patterns   |
