> ## 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.

# Generate Product Prompts

Generate visibility tracking prompts for products.

<Warning>
  **Standalone endpoint for manual use only.** The cron job does NOT call this endpoint directly.
  Instead, `discover-products` calls `generate_prompts_for_product` internally for new products.
</Warning>

Use this endpoint for:

* Manual prompt regeneration for specific products
* Debugging and testing prompt generation
* Backfilling prompts for products that were created without them

## How It Works

```mermaid theme={null}
flowchart TD
    A[POST /api/cron/generate-product-prompts] --> B[For each product]
    B --> C[Call Gemini to generate prompts]
    C --> D[Save to entity_prompts_tracker]
    D --> E[Return count]
```

## Request Body

| Field         | Type   | Required | Description                              |
| ------------- | ------ | -------- | ---------------------------------------- |
| `business_id` | string | Yes      | Clerk org ID                             |
| `products`    | array  | Yes      | Products from `discover-products` output |

### products Array

| Field       | Type   | Description         |
| ----------- | ------ | ------------------- |
| `name`      | string | Product name        |
| `entity_id` | string | Product entity UUID |
| `url`       | string | Product URL         |

## Response

```json theme={null}
{
  "status": "success",
  "products_processed": 3,
  "prompts_generated": 30
}
```

## Prompt Generation

For each product, Gemini generates 10 search queries that users might use to find this product:

```
Product: AI Teddy Bear
URL: https://example.com/products/teddy

Generated prompts:
1. "best talking teddy bear for kids"
2. "AI stuffed animals with voice recognition"
3. "interactive plush toys that respond"
...
```

## Configuration

| Constant              | Value | Description                   |
| --------------------- | ----- | ----------------------------- |
| `PROMPTS_PER_PRODUCT` | 10    | Prompts generated per product |

## Database Updates

| Table                    | Action                        |
| ------------------------ | ----------------------------- |
| `entity_prompts_tracker` | Insert 10 prompts per product |

## Code Location

```
src/app/apis/cron/generate_product_prompts/routes.py
```
