Siteverify
Your backend redeems each token once, with your site’s secret, and acts on the decision in the reply.
Important
success is not a verdict
success: true only means the token is genuine, unexpired and unused. It says nothing about whether to let the request through. Always act on decision.
A Turnstile-style handler that checks only success lets blocked bots through. It’s the most common mistake when switching.
Request
POST https://hc.acecaptcha.com/v1/siteverify with a JSON or application/x-www-form-urlencoded body of at most 16 KiB.
secretRequired- Your site’s secret.
responseRequired- The token from your page.
remoteipOptional- The visitor’s IP address as your server saw it. It only fills
ip_matchin the reply. actionOptional- The action you expect. A token issued for a different action fails with
action-mismatchand is not used up.
{ "secret": "ace_secret_…", "response": "<the token from execute>", "remoteip": "203.0.113.7", "action": "login"}curl https://hc.acecaptcha.com/v1/siteverify \ --max-time 5 \ -H 'content-type: application/json' \ -d '{"secret": "'"$ACE_SECRET"'", "response": "<token>", "action": "login"}'Call siteverify from your server only. The secret never goes to the browser, and each token verifies once.
Response
A verified token answers HTTP 200:
{ "success": true, "error-codes": [], "sitekey": "ace_site_…", "hostname": "shop.example.com", "challenge_ts": "2026-11-21T09:30:12.000Z", "action": "login", "decision": "allow", "mode": "enforce", "ip_match": true}success- The token is genuine, unexpired and unused. Not a verdict: see below.
error-codes- Empty on success; otherwise one of the error codes.
decisionallow,allow_limitedorblock. Act on this.modeshadoworenforce: the site’s mode, so your backend can branch.action- The action the token was issued for.
hostname- The hostname of the page that ran the check, validated by AceCaptcha.
challenge_ts- When the token was issued (ISO 8601).
sitekey- The sitekey the token was issued for.
ip_match- When you sent
remoteip:trueif it matches the address the check came from (the same IP, the same /24 for IPv4 or the same /48 for IPv6), otherwisefalse.nullwhen you didn’t send it.
success is not a verdict
success answers “is this a real, fresh, unused token?”. decision answers “what should I do with this request?”. A bot can hold a genuine token and still get block, so a handler has to read both: refuse when success is false, then act on decision.
Decisions
allow- Proceed.
allow_limited- Proceed, with tighter limits on this request. For example: stricter rate limits for the account, IP or session; email or SMS verification on signup; holding an order for review; no high-value actions without extra friction.
block- Refuse the request, with a generic error.
Keep the refusal generic (“Please try again.”), so it doesn’t tell a bot what it tripped.
Modes
Mode is a site setting, and siteverify echoes it in every reply as mode, so your backend can branch without its own switch.
shadow(the default, Invisible in the dashboard) is for rolling out safely. Nobody is asked to do anything, so a visitor the check isn’t sure about comes back asallow_limited. Logdecision, but don’t refuse anything on it yet.enforcegives visitors the check isn’t sure about a short visible check, and how it goes decides the answer. Act ondecision. Enforce mode and the visible check are plan features.
Error replies carry no mode, so the samples below keep refusing a failed verification (success: false) in shadow mode too, just as a handler for your current captcha would.
Advanced data
On plans with advanced data (Enterprise), a successful reply also carries a detail block: the score behind the decision, and ids for the visitor’s device. Other replies are unchanged, so a handler written for the plain reply keeps working.
{ "success": true, "error-codes": [], "sitekey": "ace_site_…", "hostname": "shop.example.com", "challenge_ts": "2026-11-21T09:30:12.000Z", "action": "login", "decision": "allow", "mode": "enforce", "ip_match": true, "detail": { "v": 1, "score": 0.12, "band": "pass", "device": { "id": "lUA3A1zAGYjHQPefytgPYQ", "machine": null } }}v- The version of this block,
1. New fields may be added within a version; ignore the ones you don’t know. score- From
0to1: how likely the check was automated. Higher is more likely a bot. For your logs and reviews;decisionalready applies your site’s thresholds. bandpass,grayorfail: where the score fell against your site’s thresholds.device.id- An id for the visitor’s browser, stable on your site until the visitor clears the browser storage for hc.acecaptcha.com. Use it for per-device rate limits or to link accounts that share a browser.
device.machine- An id for the visitor’s computer that survives cleared storage and a new network. Only on Windows and Linux desktops, otherwise
null: phones and Macs of one model share it, so counting it there would group strangers.
The ids belong to your site alone. The same browser gets a different id on every other site, so ids can’t be matched across sites. Keep acting on decision; detail is extra evidence, not a second verdict. Failed replies and test keys never carry it.
Error codes
Errors answer HTTP 200 with success: false and one code, except internal-error, which answers HTTP 503.
{ "success": false, "error-codes": ["timeout-or-duplicate"]}missing-input-secret- The
secretfield is empty. missing-input-response- The
responsefield is empty. invalid-input-secret- The secret is unknown, malformed, expired, revoked, or belongs to another site.
invalid-input-response- Not a token, or a token issued for another site. Also returned when the site is suspended or deleted, the page’s hostname has been removed from it, or test and real keys are mixed.
timeout-or-duplicate- The token expired (after 5 minutes) or was already used.
action-mismatch- You sent an
actionand the token was issued for a different one. The token is not used up. bad-request- The body couldn’t be parsed, or is over 16 KiB.
internal-error- Sent with HTTP 503 and
Retry-After: a temporary fault. See retries and outages.
Retries and outages
- On
internal-error(HTTP 503), wait forRetry-Afterand retry once. If the retry answerstimeout-or-duplicate, ask the visitor to try again. - Give each call a timeout (the samples use 5 seconds) so a slow answer can’t hold your request.
- Decide per action what an outage means. A newsletter signup might fail open (proceed, with limits); a payment might fail closed (refuse and ask the visitor to retry).
- Don’t retry other errors: each token verifies once, and a retry of a used token answers
timeout-or-duplicate.
Samples
Each sample sends JSON, gives up after 5 seconds, retries internal-error once, and returns a decision your handler can act on. In shadow mode it logs the decision and returns allow. Pass failOpen per action to choose what an outage means. The secret comes from the ACE_SECRET environment variable.
// verify.mjs (Node 18+)const SITEVERIFY = 'https://hc.acecaptcha.com/v1/siteverify'/** * Redeems a token. Returns 'allow', 'allow_limited' or 'block'. * failOpen: what this action does when AceCaptcha can't answer. */export async function verifyAce(token, { action, remoteip, failOpen = false } = {}) { const outage = failOpen ? 'allow_limited' : 'block' const body = JSON.stringify({ secret: process.env.ACE_SECRET, response: token, action, remoteip }) for (let attempt = 0; attempt < 2; attempt++) { let reply, data try { reply = await fetch(SITEVERIFY, { method: 'POST', headers: { 'content-type': 'application/json' }, body, signal: AbortSignal.timeout(5000), }) data = await reply.json() } catch { return outage // network failure, 5 s timeout or unreadable reply } if (data['error-codes']?.includes('internal-error')) { if (attempt === 1) return outage const wait = Math.min(Number(reply.headers.get('retry-after')) || 1, 5) await new Promise((resolve) => setTimeout(resolve, wait * 1000)) continue } if (!data.success) return 'block' // missing, invalid, expired or used token if (data.mode === 'shadow') { console.info('acecaptcha shadow', action, data.decision) return 'allow' } return data.decision // act on decision, never on success alone } return outage}// In your route (Express shown):// const decision = await verifyAce(req.body['ace-token'], { action: 'login', remoteip: req.ip })// if (decision === 'block') return res.status(403).send('Please try again.')// if (decision === 'allow_limited') { /* proceed, with tighter limits */ }<?php// verify.php (PHP 8 with the curl extension)const ACE_SITEVERIFY = 'https://hc.acecaptcha.com/v1/siteverify';/** * Redeems a token. Returns 'allow', 'allow_limited' or 'block'. * $failOpen: what this action does when AceCaptcha can't answer. */function ace_verify(string $token, string $action = '', ?string $remoteIp = null, bool $failOpen = false): string{ $outage = $failOpen ? 'allow_limited' : 'block'; $body = json_encode(array_filter([ 'secret' => getenv('ACE_SECRET'), 'response' => $token, 'action' => $action, 'remoteip' => $remoteIp, ], fn ($value) => $value !== null && $value !== '')); for ($attempt = 0; $attempt < 2; $attempt++) { $retryAfter = 1; $ch = curl_init(ACE_SITEVERIFY); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$retryAfter) { if (stripos($line, 'retry-after:') === 0) { $retryAfter = max(1, (int) trim(substr($line, 12))); } return strlen($line); }, ]); $raw = curl_exec($ch); $data = is_string($raw) ? json_decode($raw, true) : null; if (!is_array($data)) { return $outage; // network failure, 5 s timeout or unreadable reply } if (in_array('internal-error', $data['error-codes'] ?? [], true)) { if ($attempt === 1) { return $outage; } sleep(min($retryAfter, 5)); continue; } if (empty($data['success'])) { return 'block'; // missing, invalid, expired or used token } if (($data['mode'] ?? '') === 'shadow') { error_log("acecaptcha shadow {$action} {$data['decision']}"); return 'allow'; } return $data['decision']; // act on decision, never on success alone } return $outage;}// In your form handler:// $decision = ace_verify($_POST['ace-token'] ?? '', 'login', $_SERVER['REMOTE_ADDR']);// if ($decision === 'block') { http_response_code(403); exit('Please try again.'); }// if ($decision === 'allow_limited') { /* proceed, with tighter limits */ }# verify.py (Python 3.9+, pip install requests)import osimport timeimport requestsSITEVERIFY = "https://hc.acecaptcha.com/v1/siteverify"def verify_ace(token, action=None, remoteip=None, fail_open=False): """Redeems a token. Returns 'allow', 'allow_limited' or 'block'. fail_open: what this action does when AceCaptcha can't answer. """ outage = "allow_limited" if fail_open else "block" payload = {"secret": os.environ["ACE_SECRET"], "response": token} if action: payload["action"] = action if remoteip: payload["remoteip"] = remoteip for attempt in range(2): try: reply = requests.post(SITEVERIFY, json=payload, timeout=5) data = reply.json() except (requests.RequestException, ValueError): return outage # network failure, 5 s timeout or unreadable reply if "internal-error" in data.get("error-codes", []): if attempt == 1: return outage time.sleep(_retry_after(reply)) continue if not data.get("success"): return "block" # missing, invalid, expired or used token if data.get("mode") == "shadow": print("acecaptcha shadow", action, data.get("decision")) return "allow" return data["decision"] # act on decision, never on success alone return outagedef _retry_after(reply): try: return min(max(int(reply.headers.get("Retry-After", "1")), 1), 5) except ValueError: return 1# In your view (Flask shown):# decision = verify_ace(request.form.get("ace-token", ""), "login", request.remote_addr)# if decision == "block": abort(403)# if decision == "allow_limited": ... # proceed, with tighter limits// verify.go (Go 1.21+)package aceimport ( "bytes" "encoding/json" "log" "net/http" "os" "slices" "strconv" "time")const siteverifyURL = "https://hc.acecaptcha.com/v1/siteverify"var client = &http.Client{Timeout: 5 * time.Second}type verifyRequest struct { Secret string `json:"secret"` Response string `json:"response"` Action string `json:"action,omitempty"` RemoteIP string `json:"remoteip,omitempty"`}type verifyReply struct { Success bool `json:"success"` ErrorCodes []string `json:"error-codes"` Decision string `json:"decision"` Mode string `json:"mode"`}// Verify redeems a token and returns "allow", "allow_limited" or "block".// failOpen is what this action does when AceCaptcha can't answer.func Verify(token, action, remoteIP string, failOpen bool) string { outage := "block" if failOpen { outage = "allow_limited" } body, _ := json.Marshal(verifyRequest{os.Getenv("ACE_SECRET"), token, action, remoteIP}) for attempt := 0; attempt < 2; attempt++ { res, err := client.Post(siteverifyURL, "application/json", bytes.NewReader(body)) if err != nil { return outage // network failure or 5 s timeout } var reply verifyReply err = json.NewDecoder(res.Body).Decode(&reply) res.Body.Close() if err != nil { return outage // unreadable reply } if slices.Contains(reply.ErrorCodes, "internal-error") { if attempt == 1 { return outage } wait, err := strconv.Atoi(res.Header.Get("Retry-After")) if err != nil || wait < 1 { wait = 1 } time.Sleep(time.Duration(min(wait, 5)) * time.Second) continue } if !reply.Success { return "block" // missing, invalid, expired or used token } if reply.Mode == "shadow" { log.Printf("acecaptcha shadow %s %s", action, reply.Decision) return "allow" } return reply.Decision // act on decision, never on success alone } return outage}// In your handler:// ip, _, _ := net.SplitHostPort(r.RemoteAddr)// switch ace.Verify(r.FormValue("ace-token"), "login", ip, false) {// case "block":// http.Error(w, "Please try again.", http.StatusForbidden)// return// case "allow_limited":// // proceed, with tighter limits// }Turnstile compatibility
Siteverify follows Turnstile’s shape, so most handlers change in a few lines:
- the same request fields:
secret,response,remoteip; - the same reply fields:
success,error-codes,hostname,challenge_ts,action; - the same codes:
missing-input-*,invalid-input-*,timeout-or-duplicate,bad-request,internal-error.
AceCaptcha adds:
decision,mode,ip_matchandsitekeyin replies;- server-side
actionenforcement in requests, with theaction-mismatchcode.
See Migrate for side-by-side changes from Turnstile, reCAPTCHA and hCaptcha.