CAPTCHA basics
How CAPTCHAs work behind the scenes
Almost every modern CAPTCHA has three parts: a widget in the browser, a token it produces, and a verification call the site's server makes with that token. Understanding the hand-offs explains most rejected answers.
Three parties, one round trip
A CAPTCHA involves three parties: the visitor's browser, the website's server and the CAPTCHA vendor. The website never grades the test itself. It embeds the vendor's widget, receives a token from the browser along with the form, and asks the vendor whether that token is genuine. The vendor answers, and the website decides what to do.
- The page loads the vendor's script with a public site key.
- The widget runs in the browser, collects signals and, if needed, shows a challenge.
- The vendor issues a token and the widget places it in the form or hands it to a callback.
- The browser submits the form with the token.
- The website's server sends the token and a secret key to the vendor's verification endpoint.
- The vendor replies with success or failure, plus details such as a score, hostname or action.
The client widget
The widget is a JavaScript bundle loaded from the vendor's domain, usually rendering inside an iframe so the site cannot tamper with it. It is configured by the site key, which identifies the site's account with the vendor and is public by design; anyone can read it from the page source.
Once loaded, the widget gathers information about the environment. Exact details are proprietary and change often, but the categories are well known: browser features and their consistency, rendering behavior, timing, interaction with the page, cookies from earlier visits to the vendor's widgets, and the network the request comes from. This collection is what lets modern widgets pass most visitors without asking anything.
Visible challenges
When the signals are inconclusive, the widget escalates to a visible task: a checkbox, an image grid, a slider. The task adds evidence; the decision still combines it with everything collected before. That is why two people solving the same grid correctly can see different outcomes.
Invisible modes
Score-based widgets such as reCAPTCHA v3 never show a task. The site calls an execute function at a moment of its choosing, usually when the visitor clicks a button, with an action name such as login. The widget returns a token immediately, and the decision is deferred to the server side, where the score becomes visible.
The token
The token is a long opaque string. To the browser and the website it means nothing; only the vendor can decode it. It encodes, in some signed form, the result of the check, when it happened, which site key and hostname it belongs to, and for score-based systems the score and action.
Tokens have two properties that matter more than any other:
- They expire quickly. A reCAPTCHA token is accepted for about two minutes; a Turnstile token for a few minutes. After that, verification fails.
- They work once. Verification consumes the token. A second verification of the same token fails, which stops a single solve from being replayed many times.
The token travels with the form in a hidden field, g-recaptcha-response for reCAPTCHA and cf-turnstile-response for Turnstile, or is passed to a JavaScript callback that adds it to an API request.
Server-side verification
When the form arrives, the website's back end calls the vendor's verification endpoint with its secret key and the token. For reCAPTCHA the call looks like this:
curl -s https://www.google.com/recaptcha/api/siteverify \
--data-urlencode "secret=SERVER_SIDE_SECRET" \
--data-urlencode "response=TOKEN_FROM_THE_FORM"
The reply is a small JSON document. For the v2 checkbox it includes success, a challenge_ts timestamp and the hostname where the widget ran. For v3 it adds score and action. Turnstile has an equivalent endpoint on Cloudflare's side that returns success, hostname, action and optional custom data. Field names here reflect the vendors' documentation at the time of writing.
The site then applies its own policy. A careful back end checks more than success: it confirms the hostname is its own, the action matches the form being submitted, and for scores, that the value is above its threshold. Those checks are why a token produced for the wrong page or the wrong action gets rejected even though the vendor says it is valid.
The secret key
The secret key never leaves the website's server. It proves to the vendor that the verification request comes from the site that owns the site key. That split, a public key in the page and a secret key on the server, is what makes the scheme work without the site needing to understand the test.
Full-page checks work differently
Bot management systems that sit in front of a whole site, such as Cloudflare's challenge page, AWS WAF and DataDome, follow a variation of the same pattern. Instead of a token submitted with a form, the successful check sets a cookie: cf_clearance, aws-waf-token or datadome. The edge network checks that cookie on every later request, often together with the IP address and user agent it was issued to. There is no separate verification call by the site; the protection layer is the verifier.
Where things go wrong
Seen from the inside, the common failures make sense:
- Expired token: it was generated too long before the form was submitted.
- Reused token: the form was resubmitted with the same string after a first attempt.
- Wrong site key or page: the token was produced for a different hostname than the one the server expects.
- Wrong action: a score-based token carried
homepagewhen the server expectedlogin. - Low score: the vendor returned success, but the site's threshold was higher.
- Cookie used from another IP: a clearance cookie traveled to a different address or user agent.
The why is my token rejected answer maps each of these to a fix.
What a solving API replaces
A solving API replaces only the browser half of this flow. You send the site key and page URL (and, depending on the type, an action, extra payload or proxy), and the service returns a token or cookie as the widget would have produced it. Everything after that is unchanged: your program places the token in the form field or callback, submits, and the website verifies it with the vendor exactly as it would for any visitor. That is why the task fields mirror the widget's own parameters, and why matching them precisely matters. The how CAPTCHA solving services work article covers the service side of the exchange.
Common questions
Is the site key secret?
No. It is published in the page so the widget can load. The secret key, used for verification, stays on the website's server.
Who decides whether a CAPTCHA passed?
The vendor validates the token, and the website applies its own policy on top, such as checking hostname, action and score threshold.
Why does a valid token sometimes get rejected?
It may have expired, been used already, been made for another page or action, or carried a score below the site's threshold.
Do full-page checks use tokens too?
They usually issue a clearance cookie instead, which the protection layer checks on every later request together with IP and user agent.
Can the website see what the widget collected?
Generally no. The website receives only the vendor's verdict and a few fields such as score, hostname and action.
Keep reading
- CAPTCHA tokenThe signed string a widget returns after a pass, how long it lives, and how site servers check it.
- Site keyThe public value a widget loads with, where it hides in HTML or scripts, and why token tasks require it.
- What is a CAPTCHA?From warped letters to invisible risk scores: what a CAPTCHA is for, the main families, and how they changed.
- Why does the site reject my solved token?Rejected tokens usually trace back to a wrong site key, stale timing, a missing action or a mismatched browser session.