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

Castle

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.

Request parameters

type<string>required

CustomTask


class<string>required

Castle


websiteURL<string>required

The URL of the page where Castle is located.


websiteKey<string>required

Publishable Key, the Castle identifier. It can be found on the page/in the site scripts.
Example: pk_1Tk5Yzr1WFzxrJCh7WzMZzY1rHpaOtdK


wUrl (inside metadata)<string>required

Link to cw.js, for example: https://s.rsg.sc/auth/js/20251234bgef/build/cw.js


swUrl (inside metadata)<string>required

Link to csw.js, for example: https://s.rsg.sc/auth/js/20251234bgef/build/cw.js


count (inside metadata)<intenger>optional

Number of tokens — default is 1 (generation of 1 to 49 Castle tokens bound to the same browser session, i.e. with the same __cuid identifier).
If a value greater than 49 is specified, the maximum allowed number of tokens — 49 — will be returned, and the cost will be calculated based on this amount.


userAgent<string>optional

Browser User-Agent.
Pass only a valid UA from Windows OS. Currently it is: userAgentPlaceholder


proxyType<string>optional

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


proxyAddress<string>optional

Proxy IPv4/IPv6 IP address. Not allowed:

  • use of transparent proxies (where the client IP is visible);
  • use of proxies on local machines.


proxyPort<integer>optional

Proxy port.


proxyLogin<string>optional

Proxy server login.


proxyPassword<string>optional

Proxy server password.

Create task method

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

Request

{
"type": "CustomTask",
"Class": "Castle",
"websiteURL": "https://www.example.com/",
"websiteKey": "pk_1Tk5Yzr1WFzxrJCh7WzMZzY1rHpaOtdK",
"userAgent": "userAgentPlaceholder",
"metadata": {
"wUrl": "https://s.rsg.sc/auth/js/20251234bgef/build/cw.js",
"swUrl": "https://s.rsg.sc/auth/js/20251234bgef/build/csw.js",
"count":1
}
}

Response

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

Get task result method

Use the getTaskResult method to get the TenDI solution.

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

Request

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

Response

{
"errorId":0,
"status":"ready",
"solution": {
"data":
{
"tokens":["Q05Ap...H7nYn", "cn9xW...aFl_4", ...]
},
"domains": {
"www.example.com": {
"cookies": {
"__cuid": "6883480a9ab7442d9f97da7307d6ea9c"
}
}
}
}
}

How to get Castle parameters

pk (websiteKey)

Option 1:

  1. Open the page with Castle, launch Developer Tools, go to the Elements tab.
  2. Open search (Ctrl + F) and enter the keywords pk or publishableKey.
  3. Find the Publishable Key parameter among the page elements or in the connected scripts.

Option 2:

If the site uses the window._env object:

Copy the pk value or enter the following command in the browser console: window._env.pk

Option 3:

If pk is contained in data-config:

Copy the pk value or use the following code in the browser console:

const script = document.querySelector('script[data-config]');
const config = JSON.parse(script.dataset.config);
config.castle.publishableKey;

cw.js and csw.js

In Developer Tools, go to the Network tab, activate Castle and inspect network requests. Find requests to the cw.js and csw.js files and copy their URLs.