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

> Technical overview of the Regenerate Prompts endpoint

# POST /api/cron/generate-prompts

Regenerates prompts for a business or product. This is a manual trigger/debugging endpoint.

## Purpose

This endpoint scrapes the website fresh and generates new prompts. Used for:

* Regenerating prompts after website content changes
* Debugging prompt generation
* Manual prompt refresh

## Architecture

```mermaid theme={null}
flowchart TD
    A[Request] --> B{Has product_id?}
    B -->|Yes| C[Use PROMPTS_PER_PRODUCT]
    B -->|No| D[Use MAX_BUSINESS_PROMPTS]
    C --> E[generate_prompts Service]
    D --> E
    E --> F[Scrape Website]
    F --> G[Generate with LLM]
    G --> H[Save to Database]
    H --> I[Return Counts]
```

## Request Body

| Field          | Type    | Required | Description                                      |
| -------------- | ------- | -------- | ------------------------------------------------ |
| `business_id`  | string  | Yes      | Business identifier (clerk org slug)             |
| `url`          | string  | Yes      | Website URL to scrape                            |
| `product_id`   | string  | No       | Optional product ID for product-specific prompts |
| `prompt_count` | integer | No       | Number of prompts to generate                    |

## Prompt Limits

| Entity Type | Default Count | Constant               |
| ----------- | ------------- | ---------------------- |
| Business    | 50            | `MAX_BUSINESS_PROMPTS` |
| Product     | 10            | `PROMPTS_PER_PRODUCT`  |

All products can have prompts (no limit on number of products).

## Response Fields

| Field               | Type    | Description                   |
| ------------------- | ------- | ----------------------------- |
| `status`            | string  | "success" or "error"          |
| `prompts_generated` | integer | Number of prompts generated   |
| `prompts_saved`     | integer | Number of prompts saved to DB |
| `error`             | string  | Error message if applicable   |

## Internal Services

### generate\_prompts

Core prompt generation service that scrapes and generates prompts.

**Location:** `src/app/shared/__init__.py` (exported from prompts module)

## Code Location

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