How to stop bots from buying your products

Intermediate4 min readUpdated

GET /learn/scalping/how-to-stop-bots-from-buying-products/ Accept text/html text/markdown

Short answer

Stop bots from buying products by hiding stock levels and early product URLs, running bot detection on the product, cart and checkout endpoints including the API, and enforcing purchase limits across linked accounts, cards, addresses and devices. Use a queue or raffle with verification for big drops, watch the sale live, and review orders before they ship so linked ones can be cancelled.

Bots win a limited release in three places: they see it first, they check out faster, and they buy many times under different identities. Defending a drop means closing all three, starting a week before the release and ending after the last order ships. How sneaker bots work describes the attacking side in detail.

Before the release: hide what bots watch

  • Create or publish the product only at release time. Until then it should return the same 404 as a product that does not exist, on the page and in every JSON endpoint.
  • Use product handles and IDs that cannot be guessed from earlier releases.
  • Show "in stock" or "low stock" instead of exact quantities, and remove stock counts from public APIs.
  • Close preview and staging hosts to the public. Early links often come from them.
  • Announce a release window ("between 10:00 and 12:00") and pick the exact time at random inside it.

Decide how the stock is allocated

For a first-come sale, put a waiting room in front of the product and check every visitor at entry and again at checkout, as described in do virtual waiting rooms stop bots. For the most wanted items, a raffle removes the speed race and moves the fight to fake entries, covered in do raffles stop bots. Either way, require a logged-in account and some verification, such as a confirmed phone number or an account older than the announcement.

Put bot detection on product, cart and checkout, including the API

Checkout bots often never load your pages, so detection has to run on the requests that change state: add-to-cart, shipping, payment, signup and login. That includes the API your mobile app uses. For apps, Apple App Attest and Google Play Integrity let the server check that a request came from your real app on a real device. How to protect APIs from bots covers the server side.

On Cloudflare with Bot Management, a custom rule can challenge low-score requests on the cart and checkout paths:

txt
(http.request.method eq "POST" and http.request.uri.path in {"/cart/add" "/checkout"} and cf.bot_management.score lt 30)

Start with a Managed Challenge action and check what it catches before you switch to Block. A score of 30 is a starting point. A per-IP rate limit in nginx is a cheap floor, but it only catches crude bots, since most operators rotate proxy IP addresses:

nginx
limit_req_zone $binary_remote_addr zone=cart:10m rate=10r/m;

location = /cart/add {
    limit_req zone=cart burst=5 nodelay;
    limit_req_status 429;
    proxy_pass http://shop_backend;
}

Enforce purchase limits by linked identity

A limit of one per account means nothing to someone with many accounts. Enforce the limit on every key that points to the same person: a normalised email mailbox, phone number, normalised shipping address, payment card fingerprint and device ID. Payment processors can give you a stable card fingerprint. In Stripe it is the card.fingerprint field on the payment method. Before accepting an order, check all keys at once:

sql
SELECT count(*)
FROM orders
WHERE sku = $1
  AND status <> 'cancelled'
  AND (card_fingerprint = $2 OR address_key = $3 OR mailbox = $4 OR device_id = $5);

If the count is at or above the limit, refuse the order with a clear message. Parallel tasks can pass the count at the same moment, so for a limit of one, back the check with a partial unique index per key:

sql
CREATE UNIQUE INDEX orders_one_per_card ON orders (sku, card_fingerprint) WHERE status <> 'cancelled';

For higher limits, run the count and the insert in one transaction while holding a lock on that key. How to detect multi-accounting explains how to build the address and mailbox keys.

Watch the sale while it runs

Put these numbers on one screen, per minute, for the protected product:

  • Add-to-cart requests compared with product page views
  • Checkout attempts per successful order
  • New accounts created
  • Payment declines
  • Share of requests challenged or blocked

A sudden gap between page views and cart requests means traffic is skipping the page. Agree beforehand who can pause the sale or tighten a rule, and test that switch before launch day.

Review orders before they ship

Hold fulfilment for a short review window after the drop. One or two days is a starting point. In that window, run the linking queries across all orders for the release, cancel linked orders in one batch, refund in full and tell the customers why. Your terms of sale need to allow this, as covered in are sneaker bots illegal. Feed the confirmed bot orders back into your rules before the next release.

Tools that help

StopBots is published by Kairal, which is one of the tools listed. The list is not a ranking.

  • Kairal runs bot detection per endpoint across signup, login, cart and checkout, links related devices, accounts and IP addresses, and has a preview mode that shows the decisions it would take without blocking traffic, which is useful before a release.
  • Cloudflare Bot Management adds a bot score to every request that WAF rules can use on cart and checkout paths, and fits stores already on Cloudflare's Enterprise plan.
  • Shopify bot protection lets Shopify Plus stores schedule a protected checkout event of up to 60 minutes with a reCAPTCHA or hCaptcha checkpoint, which suits single drops on that platform.
  • Queue-it is a virtual waiting room with a randomised pre-queue for timed releases, and works best paired with bot detection on checkout.
  • FingerprintJS is a free, MIT-licensed browser identifier that a small store can use to link accounts, though its README says it is much less accurate than the company's commercial product.

Common questions

How do you prevent bots from buying products?

Protect every request that changes a cart or an order, since bots send those calls without loading pages. Then count each limit per person across accounts that share cards, addresses or devices, and cancel the linked orders that still get through before they ship.

Does a purchase limit per account stop bots?

Only against operators who use a single account. A limit works when the same count applies across every account that shares a card, a normalised address, a phone number or a device.

Should I randomise the release time of a drop?

It helps when combined with other controls. Announcing a window instead of an exact second removes the advantage of tasks scheduled to fire at that second, and it forces monitors to poll for longer, which makes them easier to find in your logs.