NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

CAPTCHA basics

Error handling for CAPTCHA APIs

A CAPTCHA client meets three kinds of trouble: errors from the API, tasks that end without an answer, and answers the target site rejects. Each needs a different reaction, and getting them right keeps jobs running without wasted calls.

How errors are reported

Every GateSolver response has an errorId. Zero means the call worked. One means it did not, and the body then carries an errorCode and an errorDescription. HTTP transport problems, such as timeouts or connection resets, happen before any of that and must be handled by your HTTP layer. Error responses are never charged, so the cost of an error is only time.

{ "errorId": 1, "errorCode": "ERROR_INVALID_TASK_DATA",
  "errorDescription": "websiteKey is required" }

A task that runs but cannot be solved shows up differently: getTaskResult returns status: "failed", or the API returns ERROR_CAPTCHA_UNSOLVABLE. Neither is charged either.

Sort every code into retry, fix or stop

errorCode and categoryWhat your code should do
ERROR_SERVICE_UNAVAILABLE (retry)Wait a few seconds and send the same call again, a few times at most.
ERROR_RATE_LIMIT (retry, slower)You passed 600 requests per minute on this key. Back off, then poll less often.
ERROR_CAPTCHA_UNSOLVABLE (resubmit)Create a new task, ideally with fresh page data. Once or twice, then give up on that item.
ERROR_INVALID_TASK_DATA (fix)The description names the missing field. Fix the input; retrying unchanged cannot work.
ERROR_TASK_NOT_SUPPORTED (fix)The task type name is wrong or not offered. Check the spelling against the type page.
ERROR_TASKID_INVALID (fix)The id does not exist or belongs to another key. Often a bug in passing ids around, or a key that was replaced.
ERROR_ZERO_BALANCE (stop)Top up, then resume. Pause the job instead of looping.
ERROR_KEY_DENIED_ACCESS (stop)Missing or wrong key. Creating a new key replaces the old one, so update every deployment.
ERROR_ACCOUNT_SUSPENDED (stop)The account cannot create tasks. Halt and alert a person.

"Fix" and "stop" errors should never be retried automatically. They indicate a problem a loop cannot solve, and retrying only floods your logs and spends rate limit. The FAQ pages for ERROR_ZERO_BALANCE, ERROR_INVALID_TASK_DATA and ERROR_CAPTCHA_UNSOLVABLE go into each case.

A client that follows the rules

The Go example below turns those categories into code. Transient errors are retried inside the call helper with growing pauses; everything else becomes a typed error the caller can inspect.

package gate

import (
	"bytes"
	"encoding/json"
	"net/http"
	"time"
)
type Reply struct {
	ErrFlag int             `json:"errorId"`
	ErrName string          `json:"errorCode"`
	ErrText string          `json:"errorDescription"`
	Task    string          `json:"taskId"`
	Phase   string          `json:"status"`
	Result  json.RawMessage `json:"solution"`
}
type SolverError struct{ Code, Detail string }
func (se *SolverError) Error() string { return se.Code + " / " + se.Detail }
var passing = map[string]bool{"ERROR_SERVICE_UNAVAILABLE": true, "ERROR_RATE_LIMIT": true}

func Call(key, path string, fields map[string]any) (*Reply, error) {
	fields["clientKey"] = key
	payload, _ := json.Marshal(fields)
	for try := 1; ; try++ {
		resp, err := http.Post("https://gatesolver.com"+path, "application/json", bytes.NewReader(payload))
		if err != nil {
			if try >= 3 {
				return nil, err
			}
			time.Sleep(time.Duration(try*2) * time.Second)
			continue
		}
		var out Reply
		err = json.NewDecoder(resp.Body).Decode(&out)
		resp.Body.Close()
		if err != nil || out.ErrFlag == 0 {
			return &out, err
		}
		if !passing[out.ErrName] || try >= 4 {
			return nil, &SolverError{out.ErrName, out.ErrText}
		}
		time.Sleep(time.Duration(try*5) * time.Second)
	}
}

A production client would also use an http.Client with a timeout instead of the default one, so a hung connection cannot block forever.

Resubmitting unsolvable tasks

The caller decides about resubmission, because only it can fetch fresh page data. A compact rule: on ERROR_CAPTCHA_UNSOLVABLE or status: "failed", create one new task with freshly read parameters; if that also fails, record the item as skipped and move on. Use errors.As to read the code from the typed error:

var solveErr *SolverError
if errors.As(err, &solveErr) && solveErr.Code == "ERROR_CAPTCHA_UNSOLVABLE" && attempts < 2 {
	attempts++
	return solveAgain(freshParams())
}

Timeouts on your side

Unsolved tasks are marked failed after 120 seconds. Give your polling loop a deadline slightly above that, so it never waits forever, and treat reaching the deadline like a failed task. Polling faster does not make a task finish sooner; every three seconds for token tasks and every second for image tasks is the right pace.

Avoid duplicate tasks on network retries

A retry of createTask after a connection error is not always safe. If the first request reached the server but the reply was lost, the retry creates a second task, and if both are solved, both are charged. Two ways to limit this: keep connection timeouts generous for createTask so replies are rarely lost, and if you do retry, keep only one task id per item and ignore any later answer. The idempotency entry explains the general problem.

When the site rejects a good answer

Some failures happen after the API has done its job: the task is ready, you submit the token, and the target site still refuses. That is not an API error and does not appear in any error code, so log it separately. Typical causes are an expired or reused token, a wrong page URL or action in the task, or a cookie used from a different IP. Re-solve once with corrected parameters, and if the site keeps rejecting, look at the session rather than the solver. The token rejected answer lists the checks.

What is not charged

  • Any response with errorId: 1.
  • Tasks that end as failed, including those that hit the 120 second limit.
  • Tasks reported as unsolvable.

Charges happen only at the moment a task is solved, and the amount appears in the cost field of the ready result.

Surface errors to people at the right level

Not every error deserves an alert. Transient codes that resolve on retry belong in metrics only. Unsolvable tasks belong in a daily summary per site, since a rising count there usually means the site changed its challenge. Stop-category codes such as a zero balance or a denied key deserve an immediate message to whoever owns the job, because nothing will progress until a person acts.

Log enough to debug later

For every call, record the path, task id, error code, description and how long it took. Count errors per code per hour. A sudden rise in one code points straight at the cause: unsolvable for a site change, rate limit for a polling bug, invalid data for a parser that stopped finding the site key.

Common questions

Which errors should my client retry automatically?

ERROR_SERVICE_UNAVAILABLE and ERROR_RATE_LIMIT, with growing pauses. ERROR_CAPTCHA_UNSOLVABLE warrants a new task once or twice.

Am I charged for error responses?

No. Error responses, failed tasks and unsolvable tasks are all free. Only solved tasks are charged.

Why do I get ERROR_TASKID_INVALID for a task I just created?

The id is being polled with a different key than the one that created it, often after a key was replaced, or the id got mixed up in your code.

What should happen on ERROR_ZERO_BALANCE?

Pause the job and alert someone to top up. Retrying in a loop will not succeed until the balance is restored.

Is it safe to retry createTask after a timeout?

Only with care. If the first request was received, a retry creates a second task that may also be charged when solved.

Keep reading