Skip to main content
GET
https://searchcompany-main.up.railway.app
/
api
/
cron
/
boosted-pages-quota
curl "https://searchcompany-main.up.railway.app/api/cron/boosted-pages-quota?org_slug=nike" \
  -H "X-API-Key: search-company"
{
  "org_slug": "nike",
  "week_start": "2025-12-22",
  "week_end": "2025-12-28",
  "week_number": 52,
  "days_remaining": 5,
  "weekly_target": 100,
  "total_products": 3,
  "products_selected_this_week": 3,
  "business": {
    "daily_quota": 8,
    "this_week": 12,
    "target": 50,
    "remaining": 38
  },
  "products": [
    {
      "name": "Air Max",
      "daily_quota": 3,
      "this_week": 5,
      "target": 17,
      "remaining": 12
    },
    {
      "name": "Air Force 1",
      "daily_quota": 3,
      "this_week": 4,
      "target": 17,
      "remaining": 13
    },
    {
      "name": "Jordan",
      "daily_quota": 3,
      "this_week": 6,
      "target": 16,
      "remaining": 10
    }
  ],
  "total_daily_quota": 17
}
Calculates how many boosted pages the cron job should create today to hit the weekly target of 100 pages per customer. Authentication: Requires internal API key (X-API-Key header).

How It Works

The cron job calls this endpoint before creating boosted pages to determine exactly how many pages to create for each entity:
Cron (Job 4: Create Boosted Pages)
    β”‚
    └── For each business:
        β”‚
        β”œβ”€β”€ GET /boosted-pages-quota?org_slug={business_id}
        β”‚   └── Returns: business.daily_quota=7, products[0].daily_quota=3, etc.
        β”‚
        β”œβ”€β”€ Create {business.daily_quota} boosted pages for the business
        β”‚
        └── For each selected product:
            └── Create {product.daily_quota} boosted pages for that product
This ensures we hit exactly 100 boosted pages per week per customer, with a 50/50 split between business and products.
Products use the business’s AI site - Products don’t have their own AI websites. All boosted pages (business and product) are deployed to the same business AI site.

Algorithm

The endpoint calculates the daily quota based on:
  1. Weekly target: 100 pages total
  2. Business share: 50% (50 pages/week) - or 100% if no products
  3. Products share: 50% (50 pages/week, distributed across products)
  4. Days remaining: Days left in the current week (Monday-Sunday)
  5. Already created: Pages created so far this week
Formula: daily_quota = ceil((target - created_this_week) / days_remaining)

Product Distribution

The 50 weekly product pages are distributed based on the number of products:
ProductsDistribution
0 productsBusiness gets all 100 pages
1-50 productsAll products included, pages split evenly
51+ productsRound-robin rotation: 50 products selected per week

Round-Robin Algorithm

When there are more than 50 products, the system uses a rotating selection to ensure all products eventually get coverage:
  1. Products are ordered by creation date
  2. Each week, a different subset of 50 products is selected
  3. Selection offset = (week_number Γ— 50) % total_products
  4. This ensures every product gets boosted pages over time
Example with 200 products:
  • Week 1: Products 1-50 selected (1 page each)
  • Week 2: Products 51-100 selected
  • Week 3: Products 101-150 selected
  • Week 4: Products 151-200 selected
  • Week 5: Products 1-50 again (rotation completes)
Each product gets boosted pages approximately every 4 weeks.

Example Calculation

If it’s Wednesday (5 days remaining) and we’ve created 10 business pages this week:
  • Business target: 50
  • Already created: 10
  • Remaining: 40
  • Daily quota: ceil(40 / 5) = 8 pages today

Query Parameters

org_slug
string
required
The organization slug (business_id)

Response

org_slug
string
The organization slug
week_start
string
Start of current week (Monday) in YYYY-MM-DD format
week_end
string
End of current week (Sunday) in YYYY-MM-DD format
week_number
integer
ISO week number (1-53), used for round-robin rotation
days_remaining
integer
Days remaining in the week including today (1-7)
weekly_target
integer
Total weekly target (100)
total_products
integer
Total number of products for this organization
products_selected_this_week
integer
Number of products selected for boosted pages this week (may be less than total if using round-robin)
business
object
Business quota details
products
array
Array of product quotas (only products selected for this week are included)
total_daily_quota
integer
Total pages to create today (business + all selected products)
round_robin_note
string
Present only when using round-robin (>50 products). Explains the rotation.
curl "https://searchcompany-main.up.railway.app/api/cron/boosted-pages-quota?org_slug=nike" \
  -H "X-API-Key: search-company"
{
  "org_slug": "nike",
  "week_start": "2025-12-22",
  "week_end": "2025-12-28",
  "week_number": 52,
  "days_remaining": 5,
  "weekly_target": 100,
  "total_products": 3,
  "products_selected_this_week": 3,
  "business": {
    "daily_quota": 8,
    "this_week": 12,
    "target": 50,
    "remaining": 38
  },
  "products": [
    {
      "name": "Air Max",
      "daily_quota": 3,
      "this_week": 5,
      "target": 17,
      "remaining": 12
    },
    {
      "name": "Air Force 1",
      "daily_quota": 3,
      "this_week": 4,
      "target": 17,
      "remaining": 13
    },
    {
      "name": "Jordan",
      "daily_quota": 3,
      "this_week": 6,
      "target": 16,
      "remaining": 10
    }
  ],
  "total_daily_quota": 17
}

Integration with Cron

The cron job uses this quota API to determine exactly how many pages to create:
  1. Calls this API to get the daily quota for business and each product
  2. Creates the specified number of boosted pages for each entity
  3. All pages are deployed to the business’s AI site
This dynamic approach means:
  • Early in the week: fewer pages per day (spread the load)
  • Late in the week: more pages per day (catch up if behind)
  • If quota is already met: 0 pages (no over-creation)
  • Many products: round-robin ensures all products get coverage over time