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

# Overview

> Architecture for the Get Prompts endpoint

## Purpose

Returns prompts with their visibility status across AI platforms for the dashboard "Tracked Queries" table.

## Architecture

```mermaid theme={null}
flowchart TD
    Request["GET /api/prompts/{org_slug}"]
    
    subgraph logic [Logic]
        DetermineEntities["Determine target entities"]
        QueryPrompts["Query entity_prompts_tracker"]
        BuildPlatforms["Build platforms object"]
    end
    
    subgraph db [Database]
        Entities["entities table"]
        Prompts["entity_prompts_tracker"]
    end
    
    Request --> DetermineEntities
    DetermineEntities --> Entities
    DetermineEntities --> QueryPrompts
    QueryPrompts --> Prompts
    Prompts --> BuildPlatforms
    BuildPlatforms --> Response
```

## Query Parameters

| Parameter    | Type     | Description                                   |
| ------------ | -------- | --------------------------------------------- |
| `product_id` | `string` | "business" for business only, or product slug |
| `entity_ids` | `string` | Comma-separated entity IDs for multi-select   |
| `limit`      | `int`    | Maximum prompts (default 100)                 |
| `offset`     | `int`    | Pagination offset                             |

## Filtering Options

| Filter                | Behavior                                  |
| --------------------- | ----------------------------------------- |
| No filter             | Returns all prompts (business + products) |
| `product_id=business` | Returns only business prompts             |
| `product_id=<slug>`   | Returns only that product's prompts       |
| `entity_ids=id1,id2`  | Returns prompts for specific entities     |

## Response Format

```json theme={null}
{
  "org_slug": "org-slug-123",
  "product_id": null,
  "prompts": [
    {
      "id": 123,
      "entity_id": "uuid-...",
      "query": "best payment gateway for startups",
      "platforms": {
        "chatgpt": true,
        "claude": false,
        "gemini": true,
        "perplexity": null,
        ...
      },
      "last_tested_at": "2024-01-15T10:30:00Z"
    }
  ],
  "total": 50,
  "limit": 100,
  "offset": 0
}
```

## Platform Values

| Value   | Meaning             | UI Display      |
| ------- | ------------------- | --------------- |
| `true`  | Visible on platform | Green checkmark |
| `false` | Not visible         | Red X           |
| `null`  | Not tested yet      | Gray dash "-"   |

## Sorting

Prompts are sorted by `last_tested_at` descending (tested prompts first, then untested).

## Code Location

```
src/app/apis/current_setup/prompts/routes.py
```
