Skip to main content
Are you experiencing issues obtaining the token?
Contact support

reCAPTCHA v2 Enterprise

Attention!

CapMonster Cloud uses built-in proxies by default — their cost is already included in the service. You only need to specify your own proxies in cases where the website does not accept the token or access to the built-in services is restricted.

If you are using a proxy with IP authorization, make sure to whitelist the address 65.21.190.34.

The object contains data for Google reCAPTCHA Enterprise solving task. To provide solid universality for solving this type of task we have reproduce every piece of environment used for an automation task you plan to complete. Including, proxy access, browser's user-agent, cookies (optionally).

This type of captcha has no visual differences from ReCaptcha v2. You can see the difference by examining the captcha code, for example, in the developer tools under the Network tab in the requests:

Request URL (anchor): https://www.google.com/recaptcha/enterprise/anchor?ar=1&k=6Lf26sUnAAAAAIKLuWNYgRsFUfmI-3Lex3xT5N-s&co=aHR0cHM6Ly8yY2FwdGNoYS5jb206NDQz&hl=en&v=1kRDYC3bfA-o6-tsWzIBvp7k&size=normal&cb=43r1q2d3mx66

This type of captcha might be solved a bit longer than usual image captcha, but this issue is compensated by the fact that g-recaptcha-response value we send to you is valid for the next 60 seconds after we solves your ReCaptcha2.

More on the topic in our blog

Request parameters

type<string>required

RecaptchaV2EnterpriseTask


websiteURL<string>required

Address of a webpage with Google ReCaptcha Enterprise.


websiteKey<string>required

Recaptcha website key.
<div class="g-recaptcha" data-sitekey="THIS_ONE"></div>
or <iframe title="reCAPTCHA" src="...;k=6LdIFr0ZAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH&amp;... , where 6LdIFr0ZAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH - websiteKey


pageAction<string>optional

The value of the action parameter sent by the ReCaptcha widget to Google, which is later visible to the site owner during verification. Specify this parameter if its value differs from the default: verify

Example in HTML:
grecaptcha.execute('site_key', {action:'login_test'}).


enterprisePayload<string>optional

Some implementations of the reCAPTCHA Enterprise widget may contain additional parameters that are passed to the “grecaptcha.enterprise.render” method along with the sitekey. For example: <pre lang="js" ><code>grecaptcha.enterprise.render("some-div-id", { sitekey: "6Lc_aCMTAAAAABx7u2N0D1XnVbI_v6ZdbM6rYf16" theme: "dark" s: "2JvUXHNTnZl1Jb6WEvbDyB...ugQA" });</code></pre>


apiDomain<string>optional

Domain address from which to load reCAPTCHA Enterprise. For example:
- www.google.com
- www.recaptcha.net

Don't use a parameter if you don't know why it's needed.


userAgent<string>optional

Browser's User-Agent which is used in emulation. It is required that you use a signature of a modern browser, otherwise Google will ask you to "update your browser".


cookies<string>optional

Additional cookies which we must use during interaction with target page or Google.
Format: cookiename1=cookievalue1; cookiename2=cookievalue2


proxyType<string>optional

http - regular http/https proxy;
https - try this option only if "http" doesn't work (required for some custom proxies);
socks4 - socks4 proxy;
socks5 - socks5 proxy.


proxyAddress<string>optional

IPv4/IPv6 proxy IP address. Not allowed:

  • using transparent proxies (where you can see the client's IP);
  • using proxies on local machines.


proxyPort<integer>optional

Proxy port.


proxyLogin<string>optional

Proxy-server login.


proxyPassword<string>optional

Proxy-server password.


For enterprisePayload - before calling it, you need to replace the grecaptcha.enterprise.render function with your own and take the value from its parameters. The function exists after loading the script, and the captcha is usually rendered immediately or based on a page event. If the captcha is rendered with the current field s on the client, then the token will most likely not be accepted. The original function can be called without the s field.

apiDomain is the domain that hosts the API interface for interacting with reCAPTCHA, it is used to verify that the user passes the captcha.

Script
var __test_grc = undefined;

var __test_enterprise = undefined;

var __test_render = undefined;

var __test_render_widget = undefined;

var __test_render_args = undefined; // here will be the object with which render is called.

var __test_handler = {
get: function(target, name, receiver) {
if (name == 'enterprise') {
return __test_enterprise ? __test_enterprise : (__test_enterprise = new Proxy(target[name], __test_handler));
} else if (name == 'render') {
__test_render = target[name];
return (function(a, b) {
__test_render_args = b;
__test_render_widget = a;
return __test_render(a, {sitekey: b.sitekey}); });
} else {
return target[name];
}
}
};

Object.defineProperty(window, 'grecaptcha', {
enumerable: true,
configurable: false,
get: function() {
return __test_grc;
},
set: function(value) {
__test_grc = new Proxy(value, __test_handler);
}
});

Create task method

POST
https://api.capmonster.cloud/createTask

Request

{
"clientKey":"API_KEY",
"task": {
"type":"RecaptchaV2EnterpriseTask",
"websiteURL":"https://mydomain.com/page-with-recaptcha-enterprise",
"websiteKey":"6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
"enterprisePayload": {
"s": "SOME_ADDITIONAL_TOKEN"
}
}
}

Response

{
"errorId":0,
"taskId":407533072
}

Get task result method

Use the getTaskResult method to request answer for ReCaptcha2. You will get response within 10 - 80 sec period depending on service workload.

POST
https://api.capmonster.cloud/getTaskResult

Request

{
"clientKey":"API_KEY",
"taskId": 407533072
}

Response

{
"errorId":0,
"status":"ready",
"solution": {
"gRecaptchaResponse":"3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3"
}
}

PropertyTypeDescription
gRecaptchaResponseStringHash which should be inserted into Recaptcha2 submit form in <textarea id="g-recaptcha-response" ..></textarea>. It has a length of 500 to 2190 bytes.

How to find all required parameters for task creation

Manually

  1. Open your website where the captcha appears in the browser.
  2. Right-click on the captcha element and select Inspect.

websiteKey

Public site key (sitekey). You can find the websiteKey in the Elements:

sitekeyEntpr

Or in Network requests:

sitekeyEntpr1

Automatically

To automate parameter extraction, you can retrieve them via a browser (regular or headless, e.g., using Playwright) or directly from HTTP requests. Since dynamic parameter values are short-lived, it is recommended to use them immediately after retrieval.

Important!

The provided code snippets are basic examples for learning how to extract the required parameters. The exact implementation will depend on your captcha page, its structure, and the HTML elements and selectors used.

Show code (in browser)
(() => {
const payload = {};
let sitekey = null;

document.querySelectorAll('.g-recaptcha').forEach(div => {
if (div.dataset.sitekey) sitekey = div.dataset.sitekey;

for (const [key, value] of Object.entries(div.dataset)) {
if (key !== 'sitekey') {
payload[key] = value;
}
}
});

const scriptTags = Array.from(document.querySelectorAll("script:not([src])"));
const regex = /grecaptcha\.enterprise\.render\([^,]+,\s*\{(.*?)\}/s;

scriptTags.forEach(tag => {
const match = regex.exec(tag.textContent);
if (match) {
const obj = match[1];
const paramRegex = /(\w+)\s*:\s*['"]([^'"]+)['"]/g;
let p;
while ((p = paramRegex.exec(obj)) !== null) {
const key = p[1];
const val = p[2];
if (key === "sitekey") sitekey = val;
else payload[key] = val;
}
}
});

console.log("sitekey:", sitekey);
console.log("enterprisePayload:", payload);
})();
Show code (Node.js)
import { chromium } from 'playwright';

(async () => {
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
const page = await context.newPage();

let sitekey = null;
const enterprisePayload = {};

const targetUrl = 'https://example.com';
await page.goto(targetUrl, { timeout: 60000 });
await page.waitForTimeout(3000);

const recaptchaDivs = await page.$$('.g-recaptcha');
for (const div of recaptchaDivs) {
const attrs = ['data-sitekey', 'data-s', 'data-cdata', 'data-type', 'data-context'];
for (const attr of attrs) {
const val = await div.getAttribute(attr);
if (val) {
const key = attr.replace('data-', '');
if (key === 'sitekey') {
sitekey = val;
} else {
enterprisePayload[key] = val;
}
}
}
}

const inlineScripts = await page.$$eval("script:not([src])", (scripts) =>
scripts.map((s) => s.textContent)
);

const pattern = /grecaptcha\.enterprise\.render\([^,]+,\s*\{(.*?)\}/s;

for (const script of inlineScripts) {
const match = script.match(pattern);
if (match) {
const obj = match[1];
const keyValuePattern = /(\w+)\s*:\s*['"]([^'"]+)['"]/g;
let keyValueMatch;
while ((keyValueMatch = keyValuePattern.exec(obj)) !== null) {
const key = keyValueMatch[1];
const val = keyValueMatch[2];
if (key === 'sitekey') {
sitekey = val;
} else {
enterprisePayload[key] = val;
}
}
break;
}
}

console.log(`sitekey: ${sitekey}`);
console.log("enterprisePayload:");
for (const [key, value] of Object.entries(enterprisePayload)) {
console.log(` ${key}: ${value}`);
}

await browser.close();
})();

Use the SDK library

Show code (for browser)
// https://github.com/ZennoLab/capmonstercloud-client-js

import {
CapMonsterCloudClientFactory,
ClientOptions,
RecaptchaV2EnterpriseRequest
} from '@zennolab_com/capmonstercloud-client';

document.addEventListener('DOMContentLoaded', async () => {

const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key

const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);

// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest({
websiteURL: "https://mydomain.com/page-with-recaptcha-enterprise", // URL of the page with captcha
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd", // Replace with correct value
enterprisePayload: {
s: "SOME_ADDITIONAL_TOKEN", // Optional enterprise parameter
}
});

// Example of using your own proxy
// Uncomment this block if you want to use your own proxy

/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password"
};

recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest({
websiteURL: "https://mydomain.com/page-with-recaptcha-enterprise",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
enterprisePayload: { s: "SOME_ADDITIONAL_TOKEN" },
proxy,
userAgent: "userAgentPlaceholder"
});
*/

// Optionally, you can check the balance
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(recaptchaV2EnterpriseRequest);
console.log("Solution:", result);
});
Show code (Node.js)
// https://github.com/ZennoLab/capmonstercloud-client-js

import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2EnterpriseRequest } from '@zennolab_com/capmonstercloud-client';

const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key

async function solveRecaptchaV2Enterprise() {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);

// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest({
websiteURL: "https://mydomain.com/page-with-recaptcha-enterprise", // URL of the page with captcha
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd", // Replace with correct value
enterprisePayload: {
s: "SOME_ADDITIONAL_TOKEN", // Optional enterprise parameter
}
});

// Example of using your own proxy
// Uncomment this block if you want to use your own proxy

/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password"
};

recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest({
websiteURL: "https://mydomain.com/page-with-recaptcha-enterprise",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
enterprisePayload: { s: "SOME_ADDITIONAL_TOKEN" },
proxy,
userAgent: "userAgentPlaceholder"
});
*/

// Optionally, you can check the balance
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(recaptchaV2EnterpriseRequest);
console.log("Solution:", result);
}

solveRecaptchaV2Enterprise().catch(console.error);
More on the topic in our blog