Quick Help

    Campaigns API Documentation

    v1.0

    Getting Started

    The Campaigns API lets you create, manage, and monitor CTR campaigns programmatically. It supports all 9 campaign types with full feature parity to the UI wizard.

    Authentication

    Bearer token via API key generated in Settings → API Keys

    Base URL

    https://llkfxghqtntmhvpesqut.supabase.co/functions/v1/campaigns-api

    Rate Limit

    100 requests per 60-second window per user

    Authentication

    All requests require a valid API key passed as a Bearer token in the Authorization header.

    Authorization: Bearer your-api-key-here

    API keys are hashed with SHA-256 before storage. The raw key is shown only once at creation time. Generate keys in Settings → API Keys.

    Endpoints

    Campaign Types

    AI Overview is Coming Soon and cannot be created, copied, or selected through the API or AI assistant. Other campaign types are listed below:

    Type ValueDescriptionRequired Config
    websiteWebsite CTR traffic — drives organic clicks to your sitekeywords, geographic_targeting
    gmbGoogle My Business clicks — boosts local listing engagementgmb_config, keywords
    youtubeYouTube views & engagement — drives video interactionsyoutube_config, keywords
    brand_searchBrand search queries — increases branded search volumebrand_search_config
    drive_emulationGPS drive simulation — simulates directions to businessgmb_config (with startPointMode)
    pogo_stickPogo-stick search behavior — click competitor then yourskeywords, geographic_targeting
    directionsGoogle Maps directions — generates direction requestsgmb_config
    referrer_trafficCustom referrer traffic — drives visits from specific sourcesreferrer_pages

    Fields Reference

    Fields available when creating or updating campaigns via POST /campaigns.

    Universal Fields

    FieldTypeRequiredDescriptionExample
    namestring
    Required
    Campaign name. Max 255 characters, must be unique per user (case-insensitive)."My Campaign"
    typestring
    Required
    One of the 9 campaign types listed above."website"
    target_urlstring
    Yes*
    Target URL. Must be a valid URL. *Auto-generated for drive_emulation from gmb_config."https://example.com"
    daily_click_targetnumber
    Conditional
    Number of clicks/actions per day. Must be >= 1. Required for most types.50
    budgetnumber
    Optional
    Maximum spend. Range: 0–10,000. Set 0 for unlimited. Defaults to 0.500
    keywordsstring[]
    Conditional
    Search keywords. Required for website, gmb, youtube, pogo_stick types.["seo tool", "best seo"]
    geographic_targetingobject
    Conditional
    Geographic targeting. The "country" sub-field is required for all types except drive_emulation.{ "country": "United States" }
    click_target_timeframeobject
    Optional
    Controls click distribution over time.{ "mode": "daily", "days": 7 }
    active_weekdaysstring[]
    Optional
    Which days the campaign runs. Subset of monday–sunday. Defaults to all 7 days.["monday", "tuesday", "wednesday"]
    timezone_configobject
    Optional
    Timezone and active hours configuration.{ "timezone": "America/New_York", "distributionMode": "even", "activeHoursStart": 8, "activeHoursEnd": 22 }
    demographic_targetingobject
    Optional
    Device type targeting.{ "deviceType": "mobile" }

    Module-Specific Fields

    FieldTypeRequiredDescriptionExample
    businessNamestring
    Required
    Name of the business on Google Maps."My Local Business"
    businessAddressstring
    Optional
    Full street address of the business."123 Main St, City, State"
    cidstring
    Conditional
    Google CID number. Either target_url or cid is required for GMB."12345678901234567"
    placeIdstring
    Optional
    Google Place ID."ChIJ..."
    latitudenumber
    Optional
    Business latitude coordinate.40.7128
    longitudenumber
    Optional
    Business longitude coordinate.-74.0060
    countrystring
    Optional
    Country of the business."United States"
    searchAreaModestring
    Optional
    How to define the search area."country" | "exact_location" | "radius"
    searchAreaLatnumber
    Optional
    Latitude for search area center (when using radius mode).40.7128
    searchAreaLngnumber
    Optional
    Longitude for search area center.-74.0060
    searchAreaRadiusnumber
    Optional
    Radius in miles for the search area.25
    is_sabboolean
    Optional
    Whether the business is a Service Area Business.false
    startPointModestring
    For drive_emulation
    Where drives start from."random" | "specific_address" | "multiple_addresses"
    startAddressstring
    Optional
    Start address when using specific_address mode."456 Start Ave"
    multipleStartLocationsarray
    Optional
    Multiple start points for drive emulation.[{ "address": "...", "lat": 0, "lng": 0 }]

    Validation Rules

    The API enforces the same validation as the UI wizard. Key rules per type:

    All Types

    name required (max 255, unique per user), type must be valid, target_url must be valid URL, budget 0–10,000

    website

    keywords required unless referrer_pages.csvData has valid rows

    gmb

    gmb_config.businessName required, either target_url or gmb_config.cid required, keywords required

    youtube

    youtube_config.videoUrl required (valid YouTube URL), keywords required

    ai_overview

    Unavailable: creation, copies, imports and conversion to this type are rejected

    drive_emulation

    daily_click_target >= 1, gmb_config.businessName or businessAddress required, country required, startPointMode required

    referrer_traffic

    At least 1 valid source (CSV or manual), daily_click_target >= 1

    brand_search

    brand_search_config.brandName required

    Server Defaults

    Campaigns created via API automatically receive these defaults:

    FieldDefault Value
    statusactive
    is_traffic_activetrue
    server_managedtrue
    real_browser_enabledtrue
    real_browser_quality_threshold90
    real_browser_budget_allocation0.30
    real_browser_max_sessions5

    Error Responses

    All errors follow a consistent structure:

    {
      "success": false,
      "error": {
        "code": "VALIDATION_ERROR",
        "message": "Validation failed: ...",
        "details": {
          "validationErrors": [
            { "field": "name", "message": "Campaign name is required" }
          ]
        }
      },
      "meta": { "timestamp": "...", "version": "1.0", "request_id": "..." }
    }
    CodeHTTP StatusDescription
    UNAUTHORIZED401Invalid or missing API key
    RATE_LIMIT_EXCEEDED429Too many requests (100/min limit)
    VALIDATION_ERROR400Payload validation failed
    CONFLICT409Duplicate campaign name
    INSUFFICIENT_CREDITS402No available credits
    NOT_FOUND404Campaign or endpoint not found
    INTERNAL_ERROR500Unexpected server error

    Quick Start

    1. Sign up and go to Settings → API Keys to generate a key
    2. Include the key as Authorization: Bearer YOUR_KEY
    3. Set Content-Type: application/json for POST/PUT
    4. Send requests to the base URL + endpoint path