{
  "status": "approved",
  "source_system": "cake",
  "environment": [
    "staging",
    "prod"
  ],
  "sharded": true,
  "shard_schema": "lucos_ro_cake",
  "id": "get_publisher_keyword_report",
  "mcp_tool": "get_publisher_keyword_report",
  "shard_view_prefix": "lucos_ro_keyword",
  "connections": {
    "admin": "cake_admin_ro",
    "shorty": "cake_shorty_ro"
  },
  "objects": [
    "lucos_ro_cake.lucos_ro_keyword_*",
    "Admin.lucos_ro_affiliate_directory",
    "Admin.lucos_ro_publisher_clicks"
  ],
  "parameters": {
    "publisher": {
      "type": "string",
      "required": true
    },
    "keyword": {
      "type": "string",
      "required": false
    },
    "sub_id": {
      "type": "string",
      "required": false
    },
    "sort_by": {
      "type": "enum",
      "required": false,
      "values": [
        "clicks",
        "avg_cpc"
      ]
    },
    "sort_dir": {
      "type": "enum",
      "required": false,
      "values": [
        "desc",
        "asc"
      ]
    },
    "date_from": {
      "type": "date",
      "required": false
    },
    "date_to": {
      "type": "date",
      "required": false
    },
    "limit": {
      "type": "int",
      "required": false,
      "default": 50
    }
  },
  "constraints": {
    "max_window_days": 31,
    "default_window_days": 7,
    "max_rows": 500,
    "timeout_ms": 60000
  },
  "allow_fields": [
    "keyword",
    "sub_id",
    "clicks",
    "conversions",
    "revenue",
    "avg_cpc"
  ],
  "deny_fields": [
    "net_cpc",
    "rev_share",
    "click_ip",
    "search_ip",
    "admedia_clickid",
    "user_agent"
  ],
  "post_processing": [
    "Answers members.admedia.com Keyword Details Report (reports/keyworddetails, stats_model.php getKeywordStats).",
    "Reads lucos_ro_cake.lucos_ro_keyword_YYYYMMDD, which pre-aggregates Shorty click_YYYYMMDD by affiliate+keyword+sub_id+campaign for valid clicks only (status = 0 AND errors = ''), so no click-level row is selectable.",
    "REVENUE IS DELIBERATELY ABSENT. The portal's revenue-per-keyword selects the first N net_cpc rows for the publisher and date with no keyword or click-id predicate and no ORDER BY, and reuses the same rows for every keyword (stats_model.php:784-796). It is not attributable, so it is not reproduced.",
    "avg_cpc is the mean bid across the keyword's valid clicks, which is a real figure.",
    "Grain follows the portal: keyword plus sub id."
  ],
  "notes": "Which keywords a publisher's valid clicks came from, ranked by clicks. Publisher is mandatory. For earnings use get_publisher_report or get_publisher_click_report."
}
