SurSolver

BlogCaptchaFox solver API: solve CaptchaFoxToken end to end

CaptchaFox solver API: solve CaptchaFoxToken end to end

· Updated · 8 min read

This guide walks you through one CaptchaFox solve from start to finish. You will find the sk_ sitekey, create a CaptchaFoxToken that carries your proxy, poll for the token and submit it in cf-captcha-response from the same IP, with the browser run going through that same proxy. Everything below, from the task to the form submission, is organised around keeping one proxy session constant, because a CaptchaFox token is checked against the IP that solved it.

What you get back

CaptchaFox is a privacy-first, behavioural captcha built and hosted in Europe. It scores cursor movement, click timing and scroll patterns together with technical signals and network context, and shows a visible challenge only to suspicious sessions: a slide puzzle, a one-click confirmation or an audio fallback.

A page that uses it loads cdn.captchafox.com/api.js and has a container such as <div class="captchafox" data-sitekey="...">. On success the widget adds a hidden input with the response token, submitted as the POST field cf-captcha-response. The site then verifies the token server-side, optionally together with the IP it came from.

A solved task returns a token string with no userAgent result key. Send userAgent as a required task input and keep it for replay. The token is single-use and short-lived. The CaptchaFox solver guide covers how to recognise the widget.

The script host is not a task parameter

Some sites load the widget from a different script host. United Internet properties such as mail.com, gmx.com and web.de use a dedicated host under s.uicdn.com, and their tokens carry a MAM_ prefix. Some other solvers expose an apiServer field to select that host. The SurSolver task has no such parameter; it takes the website URL, the sitekey and a proxy.

So view the page source before you spend a task: if the widget's <script src> points at cdn.captchafox.com, the task targets your site. If it points elsewhere, a standard token may be rejected, and SurSolver has no setting to change that.

Parameters

Field Required What it is
type yes CaptchaFoxToken — there is no proxyless name
websiteURL yes The exact page that shows the widget
websiteKey yes The sitekey, which starts with sk_
proxy yes Your proxy, as a string or as split fields

CaptchaFoxTokenProxyLess answers ERROR_TYPE_NOT_SUPPORTED, and a task without proxy details is rejected with ERROR_INVALID_REQUEST. Send userAgent in the task and submit with the same value.

The proxy goes in task.proxy, for example http://user:password@203.0.113.10:8000. A string with four colon-separated parts is always read as user:password:host:port. Split fields (proxyType, proxyAddress, proxyPort, proxyLogin, proxyPassword) are the explicit alternative; the proxies guide lists every format.

Find the sitekey

CaptchaFox sitekeys start with sk_. Try these in order:

  • Page source. Press Ctrl+U and search for captchafox, sk_, data-key or CaptchaFox.init. Look for a container with data-sitekey or data-key, or a CaptchaFox.init({ key: "sk_..." }) call.
  • Network tab. This is the most reliable method. Open DevTools, reload, filter requests by captchafox or challenge, and read the key from the query parameters or the response.
  • Console. Try document.querySelector('[data-key]')?.dataset.key.

The captchafox container with its data-sitekey attribute holding the documented CaptchaFox test sitekey, selected in the DevTools Elements panel on a local demo signup form

On some sites the key changes per session or page load. If a setup that worked starts failing, read the key again from a fresh page load before you suspect anything else. Identify any captcha and extract its parameters covers the general method.

Create the task and poll

snippet.powershell
$body = @{
  clientKey = 'sur_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  task = @{
    type = 'CaptchaFoxToken'
    websiteURL = 'https://www.example.com/signup'
    websiteKey = 'sk_YOUR_SITEKEY'
    proxy = 'http://user:password@203.0.113.10:8000'
  }
} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method Post -Uri 'https://api.sursolver.com/createTask' -ContentType 'application/json' -Body $body

An accepted task answers:

snippet.json
{"errorId":0,"taskId":"tsk_9c1f4e2a7b0d5e3f81a62c47","status":"idle"}

Poll getTaskResult every 3 seconds. {"errorId":0,"status":"processing"} means keep waiting. When the task is done:

snippet.json
{
  "errorId": 0,
  "status": "ready",
  "solution": {
    "token": "7828075fb55ecbd9146745ee6f2bec475b88076d36e23050f1fb28359ffca15d"
  }
}

API errors are HTTP 200 with errorId: 1; stop polling at the first one. An unexpected server fault is an HTTP 500 without errorId. The API sets no polling ceiling, so add a deadline in your own loop. Tokens live only a few minutes, so a short deadline is fine. The task is charged when createTask accepts it, and a task that finishes as failed automatically returns its original charge once; a retry is a new task. The fields are in the public catalog (GET /v1/task-types) and the API reference.

Submit cf-captcha-response

On a standard integration the token goes into the POST field cf-captcha-response, and the site verifies it with CaptchaFox. Custom integrations rename it. Complete the captcha once by hand and read the request in the Network tab: observed variants include cf_token, captcha_response, captchafox_token, a header such as X-Captcha-Token, or a field inside a JSON body. Use whatever the site's own request uses. How to submit a captcha token goes through the patterns.

Three conditions have to hold at submission:

  1. Same IP. Send the request through the proxy you gave the task. The site can bind the token to the IP that solved it, and a submit from a different address can then be refused.
  2. Same user agent. Send your browser's userAgent in the task and submit with exactly that same value. Confirm the first submission is accepted before scaling up.
  3. Straight away. The token is single-use and expires within minutes. A replay or a late submit comes back refused as expired or already used.

A Playwright run through the same proxy

The generated script has constants at the top for CLIENT_KEY, TARGET_URL, PROXY_URL, SUBMIT_SELECTOR and SUCCESS_SELECTOR; SITE_KEY is an optional override.

captchafox-playwright.js
// captchafox-playwright.js - solve CaptchaFox on the live page and submit the form with the
// token.
// Install: npm install playwright && npx playwright install chromium
// Run: node captchafox-playwright.js

const { chromium } = require('playwright');
const { setTimeout: sleep } = require('node:timers/promises');

// Your SurSolver API key.
const CLIENT_KEY = 'sur_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// The page that renders the widget, with its path and query string.
const TARGET_URL = 'https://example.com/page';
// The proxy for the solve and the replay: http://user:pass@host:port or socks5://host:port.
const PROXY_URL = 'http://username:password@proxy.example.com:8080';
// Optional, read from the page when empty: data-sitekey or data-key on the CaptchaFox container
// (it starts with sk_).
const SITE_KEY = '';
// The User-Agent the solve runs with; send the result with this same user agent.
const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36';
// The control that submits the form.
const SUBMIT_SELECTOR = '.PASTE_SUBMIT_SELECTOR';
// A selector that matches only after the site accepted the result.
const SUCCESS_SELECTOR = '.PASTE_ACCEPTED_SELECTOR';

const API = 'https://api.sursolver.com';
const POLL_ATTEMPTS = 60;

// API errors are HTTP 200 with errorId 1; anything else is a transport failure.
async function call(path, body) {
  const res = await fetch(`${API}${path}`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  const data = await res.json();
  if (data.errorId !== 0) throw new Error(`${data.errorCode}: ${data.errorDescription}`);
  return data;
}

async function solve(task) {
  const created = await call('/createTask', { clientKey: CLIENT_KEY, task });

  for (let attempt = 0; attempt < POLL_ATTEMPTS; attempt += 1) {
    const result = await call('/getTaskResult', {
      clientKey: CLIENT_KEY,
      taskId: created.taskId,
    });
    if (result.status === 'ready') return result.solution;
    await sleep(3000);
  }
  throw new Error(`task ${created.taskId} was not ready in ${POLL_ATTEMPTS} polls`);
}

// Optional task fields are sent only when they have a value.
function withoutEmpty(fields) {
  return Object.fromEntries(
    Object.entries(fields).filter(([, value]) => value !== undefined && value !== ''),
  );
}

// A value the page did not show must be pasted into its constant at the top.
function need(name, value) {
  if (value === undefined || value === null || value === '') {
    throw new Error(`Could not read ${name} from the page; fill in the ${name} constant.`);
  }
  return value;
}

// Chromium takes the proxy as a server plus credentials rather than one URL.
// It cannot send credentials to a SOCKS5 proxy; use an http:// proxy for browser runs.
function proxyOption(proxyUrl) {
  const url = new URL(proxyUrl);
  return {
    server: `${url.protocol}//${url.host}`,
    ...(url.username
      ? { username: decodeURIComponent(url.username), password: decodeURIComponent(url.password) }
      : {}),
  };
}

// Opens the page once and reads what the solve needs from it.
async function readPage(browser) {
  const page = await browser.newPage({ userAgent: USER_AGENT });
  try {
    await page.goto(TARGET_URL, {
      waitUntil: 'domcontentloaded',
      timeout: 45000,
    });
    // The widget is often added after the page loads; give it a moment to appear.
    await page
      .waitForFunction(
        () =>
          !!document.querySelector('[data-sitekey]')?.dataset.sitekey ??
            document.querySelector('[data-key]')?.dataset.key,
        undefined,
        { timeout: 10000 },
      )
      .catch(() => undefined);
    const dom = await page.evaluate(() => ({
      websiteKey: document.querySelector('[data-sitekey]')?.dataset.sitekey ??
        document.querySelector('[data-key]')?.dataset.key,
    }));
    return {
      pageUrl: page.url(),
      ...dom,
    };
  } finally {
    await page.close();
  }
}

async function main() {
  const browser = await chromium.launch({ proxy: proxyOption(PROXY_URL) });
  try {
    const found = await readPage(browser);
    const solution = await solve({
      type: 'CaptchaFoxToken',
      websiteURL: found.pageUrl,
      websiteKey: need('websiteKey', SITE_KEY || found.websiteKey),
      userAgent: USER_AGENT,
      proxy: PROXY_URL,
    });

    // Submit from a fresh session with the user agent the solve ran with.
    const context = await browser.newContext({ userAgent: USER_AGENT });
    const page = await context.newPage();
    await page.goto(found.pageUrl);

    const applied = await page.evaluate(
      ({ token }) => {
        let filled = false;
        for (const name of ['cf-captcha-response']) {
          for (const field of document.querySelectorAll(`[name="${name}"]`)) {
            field.value = token;
            filled = true;
          }
        }
        const callback = null;
        if (callback && typeof window[callback] === 'function') {
          window[callback](token);
          filled = true;
        }
        return filled;
      },
      { token: solution.token },
    );
    if (!applied) {
      throw new Error('The page has no token field or callback; check how it passes the token.');
    }

    await page.click(SUBMIT_SELECTOR);
    await page.locator(SUCCESS_SELECTOR).first().waitFor({ timeout: 15000 });
    console.log('The site accepted the token.');
  } finally {
    await browser.close();
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

What it does: launches Chromium through PROXY_URL, reads the sk_ key from the page's data-sitekey/data-key attribute, solves a CaptchaFoxToken task with that key and the same proxy, then submits from a fresh context that presents the task's userAgent: it fills the cf-captcha-response field, clicks your submit control and waits for the success selector. Solve and replay share the proxy exit, which is exactly the condition the token is checked against. Note for browser runs: Chromium cannot authenticate against a SOCKS5 proxy, so use an http:// proxy URL there and keep SOCKS5 for plain HTTP clients.

In a local end-to-end run against CaptchaFox's published test keys (sk_1111…/ok_1111…), the flow returned a token, and the site's siteverify check answered success: true — with the solve and the verify both going through the required proxy. Test keys return a fixed token, so treat that run as proof of the wiring, not of a production verdict; the check that matters on your own target is the protected form accepting the submission.

Node.js

The Node variant keeps the proxy on every hop, so npm install undici comes first; fill in the constants and run node captchafox-node.js. It solves CaptchaFoxToken through the proxy, then submits the form — token in cf-captcha-response — through the same proxy with the task's required userAgent.

captchafox-node.js
// captchafox-node.js - solve CaptchaFox and post the token with the form.
// Install: npm install undici
// Run: node captchafox-node.js

const { fetch: proxiedFetch, ProxyAgent } = require('undici');
const { setTimeout: sleep } = require('node:timers/promises');

// Your SurSolver API key.
const CLIENT_KEY = 'sur_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// The page that renders the widget, with its path and query string.
const TARGET_URL = 'https://example.com/page';
// The proxy for the solve and the replay: http://user:pass@host:port or socks5://host:port.
const PROXY_URL = 'http://username:password@proxy.example.com:8080';
// data-sitekey or data-key on the CaptchaFox container (it starts with sk_).
const SITE_KEY = 'YOUR_SITE_KEY';
// The User-Agent the solve runs with; send the result with this same user agent.
const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36';
// Current application session as a Cookie header value; used on form submission.
const SESSION_COOKIES = '';
// Where the page posts the form (the form action, or the request in DevTools, Network).
const FORM_URL = 'https://example.com/submit';
// The form's other fields as a JSON object, such as {"username":"demo"}.
const FORM_FIELDS = undefined;
// Text that appears only in a response the site accepted.
const SUCCESS_TEXT = 'PASTE_ACCEPTED_MARKER';

const API = 'https://api.sursolver.com';
const POLL_ATTEMPTS = 60;

// API errors are HTTP 200 with errorId 1; anything else is a transport failure.
async function call(path, body) {
  const res = await fetch(`${API}${path}`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  const data = await res.json();
  if (data.errorId !== 0) throw new Error(`${data.errorCode}: ${data.errorDescription}`);
  return data;
}

async function solve(task) {
  const created = await call('/createTask', { clientKey: CLIENT_KEY, task });

  for (let attempt = 0; attempt < POLL_ATTEMPTS; attempt += 1) {
    const result = await call('/getTaskResult', {
      clientKey: CLIENT_KEY,
      taskId: created.taskId,
    });
    if (result.status === 'ready') return result.solution;
    await sleep(3000);
  }
  throw new Error(`task ${created.taskId} was not ready in ${POLL_ATTEMPTS} polls`);
}

// Optional task fields are sent only when they have a value.
function withoutEmpty(fields) {
  return Object.fromEntries(
    Object.entries(fields).filter(([, value]) => value !== undefined && value !== ''),
  );
}

async function main() {
  // undici ProxyAgent speaks http:// proxies; use a socks5 agent package for socks5://.
  const dispatcher = new ProxyAgent(PROXY_URL);

  const solution = await solve({
    type: 'CaptchaFoxToken',
    websiteURL: TARGET_URL,
    websiteKey: SITE_KEY,
    userAgent: USER_AGENT,
    proxy: PROXY_URL,
  });

  // Send the token the way the page does; some sites name it differently or send JSON.
  // The solve ran with USER_AGENT; the submit presents the same one.
  const headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'User-Agent': USER_AGENT,
    ...(SESSION_COOKIES ? { Cookie: SESSION_COOKIES } : {}),
  };
  const body = new URLSearchParams({
    ...(FORM_FIELDS ?? {}),
    ['cf-captcha-response']: solution.token,
  });
  const response = await proxiedFetch(FORM_URL, { method: 'POST', headers, body, dispatcher });
  const text = await response.text();
  if (!response.ok || !text.includes(SUCCESS_TEXT)) {
    throw new Error(`The site did not accept the result (HTTP ${response.status}).`);
  }
  console.log('The site accepted the result.');
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Python

pip install requests and python captchafox-python.py do the same without a browser: solve through the proxy, post the form through the proxy, judge the response body by SUCCESS_TEXT.

captchafox-python.py
# captchafox-python.py - solve CaptchaFox and post the token with the form.
# Install: pip install requests
# Run: python captchafox-python.py

import time
from urllib.parse import urlsplit

import requests


# Your SurSolver API key.
CLIENT_KEY = "sur_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# The page that renders the widget, with its path and query string.
TARGET_URL = "https://example.com/page"
# The proxy for the solve and the replay: http://user:pass@host:port or socks5://host:port.
PROXY_URL = "http://username:password@proxy.example.com:8080"
# data-sitekey or data-key on the CaptchaFox container (it starts with sk_).
SITE_KEY = "YOUR_SITE_KEY"
# The User-Agent the solve runs with; send the result with this same user agent.
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36"
# Current application session as a Cookie header value; used on form submission.
SESSION_COOKIES = None
# Where the page posts the form (the form action, or the request in DevTools, Network).
FORM_URL = "https://example.com/submit"
# The form's other fields as a JSON object, such as {"username": "demo"}.
FORM_FIELDS = None
# Text that appears only in a response the site accepted.
SUCCESS_TEXT = "PASTE_ACCEPTED_MARKER"


API = "https://api.sursolver.com"
POLL_ATTEMPTS = 60


def call(path, body):
    # API errors are HTTP 200 with errorId 1; anything else is a transport failure.
    response = requests.post(f"{API}{path}", json=body, timeout=30)
    response.raise_for_status()
    data = response.json()
    if data["errorId"] != 0:
        raise RuntimeError(f'{data["errorCode"]}: {data["errorDescription"]}')
    return data


def solve(task):
    created = call("/createTask", {"clientKey": CLIENT_KEY, "task": task})
    for _ in range(POLL_ATTEMPTS):
        result = call("/getTaskResult", {"clientKey": CLIENT_KEY, "taskId": created["taskId"]})
        if result["status"] == "ready":
            return result["solution"]
        time.sleep(3)
    raise TimeoutError(f'task {created["taskId"]} was not ready in {POLL_ATTEMPTS} polls')


PROXIES = {"http": PROXY_URL, "https": PROXY_URL}


def main():
    session = requests.Session()
    if SESSION_COOKIES:
        for part in SESSION_COOKIES.split(";"):
            if "=" in part:
                name, value = part.strip().split("=", 1)
                session.cookies.set(name, value, domain=urlsplit(FORM_URL).hostname, path="/")
    solution = solve({
        "type": "CaptchaFoxToken",
        "websiteURL": TARGET_URL,
        "websiteKey": SITE_KEY,
        "userAgent": USER_AGENT,
        "proxy": PROXY_URL,
    })

    # The solve ran with USER_AGENT; the submit presents the same one.
    headers = {"User-Agent": USER_AGENT}
    # Send the token the way the page does; some sites name it differently or send JSON.
    response = session.post(
        FORM_URL,
        data={**(FORM_FIELDS or {}), "cf-captcha-response": solution["token"]},
        headers=headers,
        proxies=PROXIES,
        timeout=30,
    )
    session.close()
    if not response.ok or SUCCESS_TEXT not in response.text:
        raise SystemExit(f"The site did not accept the result (HTTP {response.status_code}).")
    print("The site accepted the result.")


if __name__ == "__main__":
    main()

Why a valid token gets rejected

Symptom Likely cause Check / fix
Token refused right after a successful solve Submit left from a different IP than the solve Route the submission through the task's proxy, browsers and HTTP clients alike
Refusals after the first hour of runs The proxy rotates exits One sticky session per solve, alive at least five minutes
Refusal with everything else matching User agent differs from the task input Submit with the task's required userAgent
Refusal on the second submit Token replayed or expired Poll, submit immediately, one token per attempt
Nothing happens on submit Wrong field name Sniff the real name from a manual solve
A setup that worked starts failing Sitekey rotated per page load Read the key again from a fresh page load
Tokens never accepted on one specific site Different script host Check whether the widget loads from cdn.captchafox.com or elsewhere, as described above

Pick a proxy in a country that suits the target. The proxies post covers sticky sessions and proxy types, and the user agent and headers post covers the header side.

First run

Check the widget's script host, grab the sk_ key and pick a sticky proxy session. Then send one CaptchaFoxToken with the parameters listed by the public catalog (GET /v1/task-types) and submit the result through the same proxy. If you also work with Procaptcha, the Prosopo guide follows the same flow without the mandatory proxy.

More articles