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

# Second Opinion PrePrompts

> Admin endpoints for managing Second Opinion suggestion cards and the public catalog for clients.

Second Opinion PrePrompts are the suggestion cards shown to users in the Second Opinion feature.
They are stored in a **separate collection** (`second_opinion_preprompts`) from the main chat preprompts.

Each pre-prompt stores:

* a unique `key` (used by clients),
* the `publicValue` shown in UI suggestion cards,
* the `maskedValue` sent to the LLM when user clicks the card,
* optional `description` (subtitle text) and `tags`.

### Authentication

Administrative endpoints live under `/api/v1/second-opinion/preprompts` and are protected by the
`backendSecretMiddleware`. Send either:

```
Authorization: Bearer <BACKEND_SECRET>
```

or

```
X-Backend-Secret: <BACKEND_SECRET>
```

where `BACKEND_SECRET` is configured in your environment variables.

### Surface area

| Action | Endpoint                                                                    | Description                        |
| ------ | --------------------------------------------------------------------------- | ---------------------------------- |
| Create | [`POST /api/v1/second-opinion/preprompts`](./second-opinion/create)         | Create new suggestion card (admin) |
| List   | [`GET /api/v1/second-opinion/preprompts`](./second-opinion/list)            | List all preprompts (admin)        |
| Get    | [`GET /api/v1/second-opinion/preprompts/{key}`](./second-opinion/get)       | Get specific preprompt (admin)     |
| Update | [`PUT /api/v1/second-opinion/preprompts/{key}`](./second-opinion/update)    | Update preprompt (admin)           |
| Delete | [`DELETE /api/v1/second-opinion/preprompts/{key}`](./second-opinion/delete) | Soft delete preprompt (admin)      |
| Public | [`GET /api/v1/public/second-opinion/preprompts`](./second-opinion/public)   | Get public catalog (no auth)       |

See the endpoint pages for request bodies, parameter constraints, and example
responses pulled directly from the OpenAPI schema.

### Quick start

1. **Create** suggestion cards via the admin API (requires `BACKEND_SECRET`).
2. **Surface** the public catalog (`GET /api/v1/public/second-opinion/preprompts`) to end-users.
3. **Render** the cards in the Second Opinion UI for users to tap and get instant opinions.

All records persist inside the MongoDB `second_opinion_preprompts` collection.

### Current PrePrompts

The following suggestion cards are currently configured:

| Key                  | Display Text                                                  | Description                                 |
| -------------------- | ------------------------------------------------------------- | ------------------------------------------- |
| `groww_ipo`          | Groww IPO looks good... but should I actually apply? 🤔       | Understand hidden risks before subscribing. |
| `crypto_investment`  | Friend says crypto will 10x... should I invest my savings? 💰 | Get clarity on volatility and real risks.   |
| `esop_worth`         | Boss offered ESOP... is it worth it? 🎯                       | Know what you're getting into.              |
| `term_vs_investment` | Should I buy term insurance or investment plan? 🛡️           | Understand what actually protects you.      |

### Frontend Integration

Front-ends should:

1. Fetch the public catalog on component mount
2. Render the `publicValue` as card titles and `description` as subtitles
3. When user taps a card, send `maskedValue` (or `publicValue` with emojis stripped) to the Second Opinion API

The `maskedValue` is intentionally kept separate to allow different text to be sent to the LLM
than what's displayed to users (e.g., removing emojis, adding context).
