Skip to main content
GET
https://searchcompany-main.up.railway.app
/
api
/
cron
/
ai-articles-quota
curl "https://searchcompany-main.up.railway.app/api/cron/ai-articles-quota?org_slug=nike" \
  -H "X-API-Key: search-company"
{
  "org_slug": "nike",
  "week_start": "2026-01-06",
  "week_end": "2026-01-12",
  "weekly_target": 1000,
  "articles_this_week": 0,
  "articles_remaining": 1000,
  "total_products": 50,
  "products": [
    {
      "id": "uuid-1",
      "name": "Air Max",
      "daily_quota": 20,
      "total_articles": 0
    },
    {
      "id": "uuid-2",
      "name": "Air Force 1",
      "daily_quota": 20,
      "total_articles": 0
    }
  ],
  "total_daily_quota": 1000,
  "message": "First run - creating full weekly burst",
  "architecture": "one-time-burst"
}
Calculates how many AI articles the cron job should create. Uses a one-time burst architecture that creates all 1,000 articles on the first cron run after signup. Authentication: Requires internal API key (X-API-Key header).

How It Works

The system uses a one-time burst model:
  1. First cron run after signup: Creates all 1,000 articles in one batch
  2. Subsequent runs: Returns 0 quota (already completed for the week)
Cron (Job 4: Create AI Articles)
    β”‚
    └── For each business:
        β”‚
        β”œβ”€β”€ GET /ai-articles-quota?org_slug={business_id}
        β”‚   └── Returns: 1000 articles (first run) or 0 (already done)
        β”‚
        └── Create articles for each product (round-robin distribution)
Products only - AI articles are created for products, not the business entity itself. All articles are deployed to the business’s AI site.

One-Time Burst Architecture

Unlike a daily distribution model, this architecture front-loads all content creation:
ScenarioQuota Returned
First run of the week (no articles yet)1,000 articles
Any subsequent run (articles exist)0 articles
This ensures new customers get their full content library immediately after signup.

Product Distribution (Round-Robin)

The 1,000 articles are distributed across products using round-robin:
  1. Products are ordered by article_count (ascending)
  2. Products with fewest articles get priority
  3. Articles are distributed evenly across all products
Example with 50 products:
  • Each product gets 20 articles (1000 Γ· 50)
  • Products with fewer existing articles are prioritized
Example with 200 products:
  • Each product gets 5 articles (1000 Γ· 200)
  • All products get coverage in a single burst

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
weekly_target
integer
Total weekly target (1000)
articles_this_week
integer
Articles already created this week
total_products
integer
Total number of products for this organization
products
array
Array of product quotas
total_daily_quota
integer
Total articles to create (1000 or 0)
architecture
string
Always β€œone-time-burst”
message
string
Human-readable status message
curl "https://searchcompany-main.up.railway.app/api/cron/ai-articles-quota?org_slug=nike" \
  -H "X-API-Key: search-company"
{
  "org_slug": "nike",
  "week_start": "2026-01-06",
  "week_end": "2026-01-12",
  "weekly_target": 1000,
  "articles_this_week": 0,
  "articles_remaining": 1000,
  "total_products": 50,
  "products": [
    {
      "id": "uuid-1",
      "name": "Air Max",
      "daily_quota": 20,
      "total_articles": 0
    },
    {
      "id": "uuid-2",
      "name": "Air Force 1",
      "daily_quota": 20,
      "total_articles": 0
    }
  ],
  "total_daily_quota": 1000,
  "message": "First run - creating full weekly burst",
  "architecture": "one-time-burst"
}

Integration with Cron

The cron job uses this quota API to determine article creation:
  1. Calls this API to get the quota
  2. If total_daily_quota > 0: Creates articles for each product in parallel
  3. All articles are deployed to the business’s AI site
  4. Subsequent cron runs return 0 quota until next week
This one-time burst approach means:
  • New customers: Get all 1,000 articles immediately
  • Existing customers: No redundant work on subsequent runs
  • Weekly reset: Quota resets each Monday for ongoing content freshness