Protect your content from AI crawlers and implement the HTTP 402 protocol. Cloudflare Worker ready to deploy in 5 minutes.
For years, OpenAI, Anthropic, Google and Meta have been sending bots to scrape the entire Internet to train their AI models. For free. Without asking permission.
Cloudflare revived HTTP 402 (Payment Required) β a status code that had been sitting unused in the standard for 30 years β to create Pay Per Crawl: a protocol that lets content owners charge those bots for every visit.
This repository matters for three reasons:
1. The protocol needs critical mass. For HTTP 402 to work as an ecosystem, thousands of sites need to implement it. Every deploy of this Worker is a vote in favor of the protocol.
2. Today you block. Tomorrow you charge. Real payments don't exist yet because AI companies haven't implemented the paying side. When they do, sites that already speak the protocol will start earning on day one. Those that don't will be left out.
3. It's a stance, not just a tool. Deploying this Worker sends a message: my content has value and it's not free. Even if no money arrives today, it establishes a technical and legal precedent. It's the difference between silently giving away your content or putting on record that you didn't.
A bet on an Internet where content creators have agency over how their work is used.
Every time an AI crawler hits your site:
- No payment header β receives
402with the price - Sends
crawler-max-priceand accepts the price β passes through, charge is recorded - On your blocklist β
403 - On your allowlist β passes through for free
- Human visitor β always passes through for free
git clone https://github.com/Josusanz/pay-per-crawl-worker.git
cd pay-per-crawl-worker
npm install
cp .dev.vars.example .dev.vars
npx wrangler dev# Crawler without payment β 402
curl -i -H "User-Agent: GPTBot/1.0" http://localhost:8787/
# Crawler willing to pay β 200
curl -i -H "User-Agent: GPTBot/1.0" -H "crawler-max-price: USD 0.05" http://localhost:8787/
# Human visitor β 200 free
curl -i http://localhost:8787/npx wrangler deployCreate a crawler-rules.json file based on the crawler-rules.example.json template:
{
"default": "charge",
"defaultPrice": 0.01,
"crawlers": [
{ "name": "Google-Extended", "action": "allow" },
{ "name": "Bytespider", "action": "block" },
{ "name": "GPTBot", "action": "charge", "price": 0.01 },
{ "name": "ClaudeBot", "action": "charge", "price": 0.05 }
]
}Available actions:
| Action | Effect |
|---|---|
charge |
Requires a payment header. Without it, responds 402 with the price |
allow |
Always lets through, no charge |
block |
Always blocks with 403 |
Development β add the JSON as a string to .dev.vars:
echo "CRAWLER_RULES=$(cat crawler-rules.json | tr -d '\n')" >> .dev.varsProduction β use a Wrangler secret:
wrangler secret put CRAWLER_RULES <<< "$(cat crawler-rules.json | tr -d '\n')"| Crawler | Company | Default action |
|---|---|---|
| GPTBot | OpenAI | charge |
| ChatGPT-User | OpenAI | charge |
| OAI-SearchBot | OpenAI | charge |
| ClaudeBot | Anthropic | charge |
| Google-Extended | charge |
|
| GoogleOther | charge |
|
| FacebookBot | Meta | charge |
| Applebot-Extended | Apple | charge |
| Amazonbot | Amazon | charge |
| PerplexityBot | Perplexity AI | charge |
| YouBot | You.com | charge |
| cohere-ai | Cohere | charge |
| Bytespider | ByteDance/TikTok | charge |
| AI2Bot | Allen Institute | charge |
| Diffbot | Diffbot | charge |
Traditional search crawlers (Googlebot, Bingbot) are not on this list and always pass through for free so your SEO is not affected.
There are two ways to implement Pay Per Crawl: this Worker (open source, deployable today) and Cloudflare's official service (still in private beta). They are not competitors β they are complementary.
| This Worker | Cloudflare Pay Per Crawl | |
|---|---|---|
| Availability | β Right now | π Private beta |
| Real money collection | β Protocol only, no payments | β Payments managed by Cloudflare |
| Customization | β Full control | |
| Cost | β Free (Workers free tier) | β³ To be announced |
Recommendation: use this Worker now for immediate protection + sign up for the official beta for when real payments are available.
Yes, almost entirely. When Cloudflare launches its payment system, the flow will be:
Your Worker (HTTP 402)
β
Cloudflare as financial intermediary
β
OpenAI / Anthropic / Google pay Cloudflare
β
Cloudflare transfers the money to you
Cloudflare acts as the bank in the middle: it negotiates with AI companies, handles the payments, and pays you. You don't manage payments directly.
Three pieces need to be ready at the same time:
| Piece | Current status |
|---|---|
| This Worker | β Ready β already speaks the protocol correctly |
| Cloudflare Pay Per Crawl | π Private beta β pending public launch |
| OpenAI/Anthropic/etc. paying | β Crawlers don't send real payment headers yet |
The HTTP 402 protocol is fully implemented:
- Responds
402withcrawler-pricewhen the crawler doesn't pay - Accepts
crawler-max-price(proactive flow) andcrawler-exact-price(reactive flow) - Adds
crawler-chargedto the response when a payment is accepted
What Cloudflare will add is a financial verification layer: when a crawler sends payment headers, Cloudflare will verify the payment is real before the request reaches your Worker. The Worker logic doesn't change.
- Enable Pay Per Crawl in the Cloudflare dashboard (one click)
- Connect your payment account
- The Worker already works β no code changes needed
Cloudflare may adjust protocol details (header names, price format) before the final launch. The spec is not yet definitive. If that happens, the change in this repo will be minimal and contained in src/pricing.ts.
pay-per-crawl-worker/
βββ src/
β βββ index.ts # Main Worker logic
β βββ crawlers.ts # Known AI crawlers database
β βββ pricing.ts # Price parsing and validation
β βββ logger.ts # Structured logging system
β βββ types.ts # TypeScript types
βββ crawler-rules.example.json # Example crawler rules config
βββ .dev.vars.example # Local development environment variables
βββ wrangler.toml # Cloudflare Workers configuration
βββ package.json
βββ tsconfig.json
crawlerreceipt.com β find out how much AI crawlers owe your site in unpaid scraping fees. Generates a shareable receipt using real Common Crawl index data.
PRs welcome. If you find a new AI crawler not on the list, open an issue or PR editing src/crawlers.ts.
MIT β creado con β€οΈ desde el Valle Sagrado del Cusco, PerΓΊ. por Josu Sanz