Pay per crawl

Handle 402 Payment Required from a site that prices access, with crawler-price headers compatible with Cloudflare pay per crawl.

A site can put a price on some actions for some agents. The headers follow Cloudflare's pay-per-crawl convention, so an agent that already handles it works unchanged.

Note

AgentGate signals prices only. It processes no payment: the site operator settles out of band from the decision log. Built-in settlement is planned.

The price

A priced request without an acceptable offer is answered:

HTTP
HTTP/1.1 402 Payment Required
crawler-price: USD 0.01
crawler-error: MissingCrawlerPrice

Accepting the price

Retry with one of these headers:

HeaderMeaning
crawler-exact-price: USD 0.01must equal the price (value and currency)
crawler-max-price: USD 0.05the most you will pay; you are charged the listed price, not your maximum

Your Web Bot Auth signature must cover the header you send, for example by adding "crawler-exact-price" to the covered components. Unverified agents cannot pay. On success the response carries the amount charged:

HTTP
HTTP/1.1 200 OK
crawler-charged: USD 0.01
AgentGate-Receipt: eyJhbGciOiJFZERTQSIs…

The decision is recorded with the label agentgate:agent:payment:accepted, which the operator uses for settlement; the signed receipt is your proof of what was charged.

Errors

crawler-errorStatusMeaning
MissingCrawlerPrice402no offer sent
InvalidCrawlerExactPrice402the exact offer differs from the price (value or currency)
InvalidCrawlerMaxPrice402the maximum is below the price
InvalidCrawlerPriceValue400not CUR 0.00
ConflictingPriceHeaders400both offer headers sent
StrongAuthRequired400 or 402the offer is not covered by a signature, or you are not verified

Behind the nginx gateway, the price travels in the same headers and the status is 402 (the check answers 403 with reason payment_required and the example configuration turns it into 402).

View as Markdown