Skip to navigation

If your site runs behind Cloudflare, you can run Agent Detection there. One Cloudflare Worker sits in front of your site. It adds the script tag to your pages for you, and it can block agents before a request reaches your servers.

This suits teams who want edge-level blocking while the script tag rolls out across their platforms.

What the Worker does

Adds the script for you

The Worker adds the Agent Detection script to every HTML page and serves it from your own domain, under /__rad/. You don’t change any site code, and your Content Security Policy needs no new hosts.

Gives each browser a pass

Once the script has run on a page the Worker served, the browser gets a signed, HttpOnly pass cookie that carries the current verdict. A pass is tied to the browser and the network it was issued to.

Blocks at the edge

On the paths you protect, the Worker blocks visits already called agents. It also blocks requests that announce themselves as agents or aren’t browsers, unless they’re verified. Every other request without a pass gets a short check page.

Watch first

In watch mode, the Worker blocks nothing and records what it would have done. Switch to enforce when the numbers look right.

On a protected path

The requestWhat happens
Has a pass, and the visit was called an agentBlocked, with no call to Resemble
Has any other valid passAllowed, with no call to Resemble
Is a verified agent, by Web Bot Auth signature or a crawler’s published addressesAllowed
Announces an AI agent, automation tool or HTTP client, comes from a headless browser, carries an unverified signature, or isn’t a browserBlocked
Anything else without a passA page navigation gets a short check page that runs the script and continues once it has a pass. An API call gets a 403

Blocked requests get a 403 with an x-rad-edge header that names the reason. API calls get JSON:

{ "error": "automated_access_blocked", "reason": "http_client", "ray": "8f1c2a3b4d5e6f70" }

The edge sees a request’s headers and network, but not how the visitor behaves. AI browsers and computer-use agents run a real browser and pass the check page. They’re blocked on their next protected request once Agent Detection calls the visit an agent, usually within its first few seconds. Protect the actions that matter, such as sign-in, sign-up and payment, so that block lands before them.

Install

1

Get your key and secret

In the Resemble app, open your Agent Detection integration. Copy the publishable key (pk_live_...) and the identity secret (sk_ident_...) from the Identify panel. The Worker uses the secret to prove it’s yours. Keep it out of your pages and your source code.

2

Deploy the Worker

The Worker lives at resemble-ai/agent-detection-cloudflare. Click Deploy to Cloudflare there, sign in, and enter your key and secret when asked. Then add a route for your site under Workers & Pages → resemble-agent-detection → Settings → Domains & Routes.

To deploy with Wrangler instead:

git clone https://github.com/resemble-ai/agent-detection-cloudflare
cd agent-detection-cloudflare
npm install
# In wrangler.jsonc, set RAD_SITE_KEY, RAD_PROTECT and your route
npx wrangler secret put RAD_SITE_SECRET
npx wrangler deploy
3

Turn on enforce

Watch the results for a few days. Then set RAD_MODE = "enforce" and deploy again.

Settings

VariableWhat it does
RAD_SITE_KEYYour publishable key.
RAD_SITE_SECRETSecret. Your identity secret. If it or the key is missing, the Worker passes every request through untouched.
RAD_MODEwatch (default) records what the Worker would do. enforce acts on protected paths. off passes everything through, so it’s your kill switch.
RAD_PROTECTA comma-separated list of paths. /login matches that path exactly, /api/* matches everything under /api/, and * matches every path. Put a method in front, as in POST *, to limit a rule to that method. Empty protects nothing.
RAD_INJECTSet to false if you add the script tag yourself. Then set the tag’s data-resemble-endpoint to /__rad/v1/events, or browsers won’t get a pass.
RAD_DEBUGtrue adds an x-rad-edge header to every page, showing the pass and the decision.

Native mobile apps

Native apps call your APIs directly and never load a web page, so they never get a pass. Don’t protect API paths that your iOS or Android apps use.

What leaves your site

  • Sent to Resemble: a fixed list of request headers (user agent, client hints, fetch metadata, language and signature headers), the method and URL, and the visitor’s IP address. Resemble hashes the address, keeps only the URL’s path, and uses the full URL only to check a signature.
  • Never sent: cookies, authorization headers, or page content.
  • Set on your pages: __Host-rad_pass (the pass), __Host-rad_n (proof that a page came through the Worker, 10 minutes), and rad_pr (a random id that links the request to the visit, 2 minutes). Check them against your consent rules.

If something fails

The Worker never stops a page from loading. If it throws an error, your page is served as normal. If Resemble can’t be reached within 1.5 seconds, the request goes through. The added time is about 10 ms on HTML pages and about 2 ms on other files.