Skip to main content
GET
https://searchcompany-main.up.railway.app
/
api
/
cron
/
sample-prompts
Sample Prompts
curl --request GET \
  --url https://searchcompany-main.up.railway.app/api/cron/sample-prompts
{
  "status": "<string>",
  "org_slug": "<string>",
  "total_prompts": 123,
  "untested_count": 123,
  "sample_size": 123,
  "prompts": [
    {}
  ]
}

Overview

This endpoint samples prompts from the total prompt pool (business + products) for an organization. It’s used by the cron job to check a subset of prompts each day instead of all prompts (cost optimization). Sampling Algorithm:
  1. First, select prompts that have never been tested (last_tested_at IS NULL)
  2. If we need more to reach sample_size, randomly select from already-tested prompts
This ensures all prompts eventually get tested while prioritizing new ones.
This is an internal API used by the Cron service. Requires API key authentication.

Query Parameters

org_slug
string
required
Organization slug (clerk_org_id)
sample_size
integer
default:"10"
Number of prompts to sample

Response

status
string
"success" or "error"
org_slug
string
The organization slug
total_prompts
integer
Total number of prompts available for this organization
untested_count
integer
Number of prompts that have never been tested
sample_size
integer
Actual number of prompts sampled (may be less than requested if fewer prompts exist)
prompts
array
Array of sampled prompts with metadata:
  • id: Prompt ID (integer)
  • prompt: The prompt text (string)
  • entity_id: Entity UUID (string)
  • entity_name: Entity name (string)
  • entity_type: "business" or "product" (string)

Example Response

{
  "status": "success",
  "org_slug": "acme-corp",
  "total_prompts": 150,
  "untested_count": 45,
  "sample_size": 10,
  "prompts": [
    {
      "id": 42,
      "prompt": "best project management software for small teams",
      "entity_id": "550e8400-e29b-41d4-a716-446655440000",
      "entity_name": "Acme Corp",
      "entity_type": "business"
    },
    {
      "id": 87,
      "prompt": "acme widget pro vs competitor",
      "entity_id": "550e8400-e29b-41d4-a716-446655440001",
      "entity_name": "Widget Pro",
      "entity_type": "product"
    }
  ]
}

Use Case

The visibility cron job calls this endpoint once per customer per day:
  1. Sample 10 prompts (prioritizing untested ones)
  2. Analyze each prompt across 8 AI platforms (pass/fail)
  3. Update entity_prompts_tracker with results and last_tested_at
  4. Store daily report in visibility_reports table
This approach:
  • Reduces API costs by ~50% compared to checking all prompts daily
  • Ensures all prompts eventually get tested
  • Prioritizes new prompts so users see results quickly after onboarding