#!/usr/bin/env bash
# Usage: bash ping.sh   (edit HOST, KEY and URLS first)
# Purpose: tell IndexNow participants (Bing and others, NOT Google) that URLs changed. Ping only recently changed URLs.
# Checked against the IndexNow docs and FAQ: global endpoint api.indexnow.org, up to 10,000 URLs per POST, submissions are shared with participating engines.
# It proves the request was accepted, not that anything was indexed. Replace every placeholder (example.com and the key).
HOST="www.example.com"
KEY="0123456789abcdef0123456789abcdef"
curl -s -o /dev/null -w "%{http_code}\n" -X POST "https://api.indexnow.org/indexnow" \
  -H "Content-Type: application/json; charset=utf-8" \
  -d "{
    \"host\": \"$HOST\",
    \"key\": \"$KEY\",
    \"keyLocation\": \"https://$HOST/$KEY.txt\",
    \"urlList\": [\"https://$HOST/blog/generative-engine-optimization\"]
  }"
# 200 = received, 202 = received, key validation pending, 403 = key not found,
# 422 = URL not on host, 429 = slow down
