How to add multiple captcha apikeys

Hey, Developers i want to ask that i have multiple 2captcha keys with different different balance how can i use that in single job run.

problem is i get this result {"errorId":10,"errorCode":"ERROR_ZERO_BALANCE","errorDescription":"Your balance is zero or negative. Please top up your balance."} when balance goes 0, i have to do something like if zero balance is showing then try another apikey of 2captcha

im using 2captcha api token based solutions

my config:

BLOCK:ConstantString
  value = "c8e876ec943ba3c6503bd315a53817df"
  => VAR @Api_Key
ENDBLOCK

BLOCK:HttpRequest
  url = "https://api.2captcha.com/createTask"
  method = POST
  httpLibrary = SystemNet
  TYPE:STANDARD
  $"{\"clientKey\":\"<Api_Key>\",\"task\":{\"type\":\"TurnstileTaskProxyless\",\"websiteURL\":\"https://dashboard.capsolver.com/passport/login\",\"websiteKey\":\"0x4AAAAAAAFstVbzplF7A4pv\"}}"
  "application/json"
ENDBLOCK

BLOCK:Parse
LABEL:parse
  input = @data.SOURCE
  leftDelim = "\"taskId\":"
  rightDelim = "}"
  MODE:LR
  => VAR @TaskId
ENDBLOCK

BLOCK:Parse
  input = @data.SOURCE
  leftDelim = "errorDescription\":\""
  rightDelim = "\""
  jToken = "token"
  MODE:LR
  => CAP @Status
ENDBLOCK

BLOCK:Keycheck
  KEYCHAIN RETRY OR
    STRINGKEY @data.SOURCE Contains "ERROR_ZERO_BALANCE"
ENDBLOCK
#GET
BLOCK:HttpRequest
  url = "https://api.2captcha.com/getTaskResult"
  method = POST
  TYPE:STANDARD
  $"{\"clientKey\":\"<Api_Key>\",\"taskId\":<TaskId>}"
  "application/json"
ENDBLOCK
IF STRINGKEY @data.SOURCE Contains "processing"
BLOCK:Delay
  milliseconds = 3000
ENDBLOCK

thank you

You can create a list of strings and get a random string from it, or use if and jump statements to loop through it.

Put your API keys in a global list variable in the startup script (not the normal script), then use another variable to hold the index of current API key (by default, the first one in the list, so index 0).

BLOCK:ConstantList
  value = ["apikey1", "apikey2"]
  => VAR @globals.keys
ENDBLOCK

BLOCK:ConstantInteger
  value = 0
  => VAR @globals.index
ENDBLOCK

Then, in the normal config script, do something like

string apiKey = globals.keys[globals.index];

// Use @apiKey normally

IF STRINGKEY @data.SOURCE Contains "ERROR_ZERO_BALANCE"
globals.index++;
data.STATUS = "RETRY";
return;
END

This way, when you get ERROR_ZERO_BALANCE, the index will be increased and bots will take the next api key. Obviously, if the list runs out, you’ll get index out of bounds errors, so you may want to handle those.