Setup
Before you start
- PHP 8.1 or newer with the
curlextension (included in most builds) - No Composer needed. Guzzle is optional, see the variant below
- A bypass.so API key (create one) with a positive balance
Install
php -v
php -m | grep curlStore your key
The examples read your key from the BYPASS_API_KEY environment variable, so it never lands in source control.
export BYPASS_API_KEY="your-api-key"Check that the key works: curl -H "Authorization: Bearer $BYPASS_API_KEY" https://bypass.so/balance returns your balance.
Step 1
Add the helper
Save this file next to your code. It wraps the whole task lifecycle in one call, bypass_solve($type, $params), so the rest of your project never deals with polling.
- createTask: sends your key, the task type and its fields as one flat JSON object.
- Fast path: if the answer is already ready, it returns at once.
- Polling: otherwise it checks
/getTaskResult/{taskId}every two seconds until the result is ready or the timeout runs out. - Errors: any reply with a non-zero
errorId, including afailedtask, becomes an error carrying theerrorCode, so you can branch on it. - taskId: kept with the solution, so you can report a wrong answer later.
<?php
declare(strict_types=1);
const BYPASS_API_URL = 'https://bypass.so';
final class BypassError extends RuntimeException
{
public function __construct(
public readonly string $errorCode,
string $description = '',
public readonly ?string $taskId = null,
) {
parent::__construct("$errorCode: $description");
}
}
function bypass_key(): string
{
return getenv('BYPASS_API_KEY') ?: '';
}
/** Sends one request and returns the decoded JSON. Any errorId != 0 becomes a BypassError. */
function bypass_call(string $method, string $path, ?array $body = null, bool $bearer = false): array
{
$headers = [];
if ($body !== null) {
$headers[] = 'Content-Type: application/json';
}
if ($bearer) {
$headers[] = 'Authorization: Bearer ' . bypass_key();
}
$ch = curl_init(BYPASS_API_URL . $path);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
]);
if ($method === 'POST') {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body === null ? '' : json_encode($body, JSON_THROW_ON_ERROR));
}
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$error = curl_error($ch);
if ($raw === false) {
throw new BypassError('HTTP_ERROR', $error);
}
$data = json_decode($raw, true);
if (!is_array($data)) {
throw new BypassError('HTTP_ERROR', "HTTP $status without a JSON body");
}
if (!empty($data['errorId'])) {
throw new BypassError($data['errorCode'] ?? 'ERROR_UNKNOWN', $data['errorDescription'] ?? '', $data['taskId'] ?? null);
}
return $data;
}
/** Creates a task and polls every $pollEvery seconds until it is ready. Returns the solution plus taskId. */
function bypass_solve(string $type, array $params, int $timeout = 120, int $pollEvery = 2): array
{
$key = bypass_key();
if ($key === '') {
throw new BypassError('ERROR_KEY_INVALID', 'set the BYPASS_API_KEY environment variable');
}
$data = bypass_call('POST', '/createTask', ['clientKey' => $key, 'type' => $type] + $params);
$taskId = $data['taskId'];
$deadline = time() + $timeout;
while (($data['status'] ?? '') !== 'ready') {
if (($data['status'] ?? '') === 'failed') {
throw new BypassError('ERROR_CAPTCHA_UNSOLVABLE', 'task failed', $taskId);
}
if (time() > $deadline) {
throw new BypassError('CLIENT_TIMEOUT', "task $taskId was not ready after {$timeout}s", $taskId);
}
sleep($pollEvery);
$data = bypass_call('GET', '/getTaskResult/' . rawurlencode($taskId) . '?clientKey=' . rawurlencode($key));
}
return ($data['solution'] ?? []) + ['taskId' => $taskId];
}
/** The token for widget types, or the text for recognition types. */
function bypass_answer(array $solution): ?string
{
return $solution['gRecaptchaResponse'] ?? $solution['token'] ?? $solution['text'] ?? null;
}
function bypass_balance(): array
{
return bypass_call('GET', '/balance', null, true);
}
function bypass_report_bad(string $taskId): array
{
return bypass_call('POST', '/reportBad?task_id=' . rawurlencode($taskId), null, true);
}Good to know
bypass_solve simply waits with sleep() between polls. In a web request, keep the timeout below your max_execution_time, or hand the work to a queue worker.Project layout used below:
bypass-demo/ bypass.php the helper (step 1) solve_math.php your script (step 2)
Step 2
Solve any supported type
Every task type uses the same call. Only the type name and its fields change. Pick a tab to see a complete, runnable file, then run it with php solve_math.php (rename to match the tab). Tabs marked soon are ready for launch day, but those types are not live yet.
<?php
require __DIR__ . '/bypass.php';
$solution = bypass_solve('MathCaptchaTask', ['captchaText' => '12 + 30 = ?']);
echo $solution['text'], PHP_EOL;php solve_math.phpreCAPTCHA v3 and hCaptcha are coming soon
RecaptchaV3Task and HCaptchaTask are not live yet. Until launch, createTask returns ERROR_TASK_NOT_SUPPORTED and nothing is charged. Get notified when they ship.Token types and your form
g-recaptcha-response, h-captcha-response or cf-turnstile-response. Send the exact URL of the page that shows the widget as websiteURL.Step 3
Handle errors and retries
Some failures are worth a second try and some are not. A missing balance or a wrong key will fail again, so stop and fix it. An unsolvable task, a timeout or a network hiccup is worth one or two more attempts with a short pause. The helper throws a BypassError with the API code in $e->errorCode. Network failures from cURL arrive as HTTP_ERROR, so one list covers both.
<?php
require __DIR__ . '/bypass.php';
const RETRYABLE = ['ERROR_CAPTCHA_UNSOLVABLE', 'ERROR_INTERNAL', 'HTTP_ERROR', 'CLIENT_TIMEOUT'];
function bypass_solve_with_retry(string $type, array $params, int $attempts = 3): array
{
for ($attempt = 1; ; $attempt++) {
try {
return bypass_solve($type, $params);
} catch (BypassError $e) {
if (!in_array($e->errorCode, RETRYABLE, true) || $attempt >= $attempts) {
throw $e;
}
fwrite(STDERR, "attempt $attempt: {$e->errorCode}, retrying\n");
sleep(2 * $attempt);
}
}
}
$solution = bypass_solve_with_retry('MathCaptchaTask', ['captchaText' => '12 + 30 = ?']);
echo $solution['text'], PHP_EOL;Failed tasks cost nothing
Step 4
Check your balance and flag wrong answers
GET /balance and POST /reportBad use your key as a Bearer token. Report a task only when the target site actually rejected its answer. The refund is applied once per task, and the task is closed afterwards.
<?php
require __DIR__ . '/bypass.php';
function flag_wrong_answer(array $solution): void
{
$result = bypass_report_bad($solution['taskId']);
echo 'refunded units: ', $result['refunded'], ' balance now: ', $result['balanceUsd'], PHP_EOL;
}
$info = bypass_balance();
printf("balance: $%.2f\n", $info['balanceUsd']);Optional
Prefer Guzzle?
If your project already loads Guzzle through Composer, this class does the same job. http_errors is turned off so that error replies, which carry a JSON body with the errorCode, are read instead of thrown away.
composer require guzzlehttp/guzzle<?php
declare(strict_types=1);
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
final class BypassError extends RuntimeException
{
public function __construct(
public readonly string $errorCode,
string $description = '',
public readonly ?string $taskId = null,
) {
parent::__construct("$errorCode: $description");
}
}
final class Bypass
{
private Client $http;
private string $key;
public function __construct(?string $key = null)
{
$this->key = $key ?? (getenv('BYPASS_API_KEY') ?: '');
$this->http = new Client([
'base_uri' => 'https://bypass.so',
'timeout' => 30,
'connect_timeout' => 10,
'http_errors' => false, // error replies carry JSON we want to read
]);
}
public function solve(string $type, array $params, int $timeout = 120, int $pollEvery = 2): array
{
if ($this->key === '') {
throw new BypassError('ERROR_KEY_INVALID', 'set the BYPASS_API_KEY environment variable');
}
$data = $this->call('POST', '/createTask', [
'json' => ['clientKey' => $this->key, 'type' => $type] + $params,
]);
$taskId = $data['taskId'];
$deadline = time() + $timeout;
while (($data['status'] ?? '') !== 'ready') {
if (($data['status'] ?? '') === 'failed') {
throw new BypassError('ERROR_CAPTCHA_UNSOLVABLE', 'task failed', $taskId);
}
if (time() > $deadline) {
throw new BypassError('CLIENT_TIMEOUT', "task $taskId was not ready after {$timeout}s", $taskId);
}
sleep($pollEvery);
$data = $this->call('GET', '/getTaskResult/' . rawurlencode($taskId), [
'query' => ['clientKey' => $this->key],
]);
}
return ($data['solution'] ?? []) + ['taskId' => $taskId];
}
public function balance(): array
{
return $this->call('GET', '/balance', ['headers' => $this->bearer()]);
}
public function reportBad(string $taskId): array
{
return $this->call('POST', '/reportBad', ['query' => ['task_id' => $taskId], 'headers' => $this->bearer()]);
}
private function bearer(): array
{
return ['Authorization' => 'Bearer ' . $this->key];
}
private function call(string $method, string $uri, array $options): array
{
try {
$res = $this->http->request($method, $uri, $options);
} catch (GuzzleException $e) {
throw new BypassError('HTTP_ERROR', $e->getMessage());
}
$data = json_decode((string) $res->getBody(), true);
if (!is_array($data)) {
throw new BypassError('HTTP_ERROR', 'HTTP ' . $res->getStatusCode() . ' without a JSON body');
}
if (!empty($data['errorId'])) {
throw new BypassError($data['errorCode'] ?? 'ERROR_UNKNOWN', $data['errorDescription'] ?? '', $data['taskId'] ?? null);
}
return $data;
}
}<?php
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/Bypass.php';
$bypass = new Bypass();
$solution = $bypass->solve('MathCaptchaTask', ['captchaText' => '12 + 30 = ?']);
echo $solution['text'], PHP_EOL;
$info = $bypass->balance();
printf("balance: $%.2f\n", $info['balanceUsd']);Reference
Task type reference
What each type expects and returns. Prices are per 1,000 solved tasks; larger top-ups add bonus credit (see pricing).
| Task type | You send | You get | Price / 1k |
|---|---|---|---|
Task typeMathCaptchaTask | You sendcaptchaText | You gettext | Price / 1k$0.35 |
Task typeImageToTextTask | You sendimageBase64 | You gettext | Price / 1k$0.28 |
Task typeAudioCaptchaTask | You sendaudioBase64 | You gettext | Price / 1k$0.35 |
Task typeRecaptchaV2Task | You sendwebsiteURLwebsiteKey | You getgRecaptchaResponse and token, plus tokenField | Price / 1k$0.56 |
Task typeTurnstileTask | You sendwebsiteURLwebsiteKey | You gettoken, plus tokenField | Price / 1k$0.84 |
Task typeRecaptchaV3TaskComing soon | You sendwebsiteURLwebsiteKeyaction | You getgRecaptchaResponse and token, plus tokenField | Price / 1kAt launch |
Task typeHCaptchaTaskComing soon | You sendwebsiteURLwebsiteKey | You gettoken, plus tokenField | Price / 1kAt launch |
Errors
Troubleshooting
| Error | Source | What it means | How to fix it |
|---|---|---|---|
ErrorERROR_KEY_INVALID | SourceHTTP 403 | What it meansThe key is missing, mistyped or revoked. | How to fix itCheck that BYPASS_API_KEY is set in the same shell that runs your code, with no quotes or spaces around it. |
ErrorERROR_INSUFFICIENT_CREDITS | SourceHTTP 402 | What it meansYour balance cannot cover the task price. | How to fix itTop up from the dashboard. Nothing was charged for this request. |
ErrorERROR_TASK_NOT_SUPPORTED | SourceHTTP 200 | What it meansThe type string is unknown, or the type is still coming soon (reCAPTCHA v3, hCaptcha). | How to fix itCopy the exact name, for example TurnstileTask. Names are case-sensitive. Nothing is charged. |
ErrorERROR_BAD_REQUEST | SourceHTTP 400 | What it meansThe body is not valid JSON, or a field has the wrong type. | How to fix itSend Content-Type: application/json and string values for clientKey, type and the task fields. |
ErrorERROR_CAPTCHA_UNSOLVABLE | SourceHTTP 200 | What it meansThis task could not be completed. | How to fix itYou are not charged. Check the image, sitekey and page URL, then submit a new task. |
ErrorERROR_NOT_FOUND | SourceHTTP 404 | What it meansThe taskId is unknown or belongs to another key. | How to fix itPoll with the taskId returned by your own createTask call, using the same key. |
ErrorERROR_INTERNAL | SourceHTTP 500 | What it meansSomething went wrong on our side. | How to fix itRetry after a short pause. The helper’s retry wrapper does this for you. |
| ErrorHelper timeout | Sourceyour code | What it meansNo result inside your timeout. | How to fix itToken types usually need several seconds. Keep at least 60–120 s and retry with a new task. |
ErrorHTTP_ERROR | Sourceyour code | What it meansA proxy or network layer answered without JSON. | How to fix itRetry with backoff. If it persists, check that your code calls https://bypass.so. |
Every error body has the same shape: {"errorId":1,"errorCode":"…","errorDescription":"…"}. Full list in the API reference.
Production
Best practices
Keep the key out of code
Read it from an environment variable or your secret store. Never commit it or ship it to a web page.
Solve right before submit
Tokens are short-lived. Fill the form first, then request the token and submit at once.
Cap your concurrency
Start with 5–10 parallel tasks and raise it while you watch error rates and spend.
Log every taskId
It is the only thing you need to debug a result or report a wrong answer.
Match the page exactly
Send the URL where the widget renders and the sitekey from that page, not from a different form.
Report wrong answers
If a site rejects a solved result, call reportBad with its taskId. The price returns to your balance once.
FAQ
Questions
"status": "ready" and a solution, so the helper returns without polling. Token types always come back as processing first.reportBad with its taskId and the price returns to your balance once. A reported task is closed, so submit a new one to try again.BypassError.Policy
Responsible use
Use it where you are allowed to
Automate pages you own, test environments you run, or sites whose terms permit automated access. Do not use bypass.so for fraud, account takeover, spam, scalping, evading bans or collecting personal data without a lawful basis. Keep request rates reasonable and stop when a site asks you to. Our acceptable use policy applies to every key, and keys used for abuse are closed.
Keep going
Next steps
- API referenceEvery endpoint, field and error code
- PricingPer-task prices and top-up bonuses
- Python guideScripts, backends and data jobs
- Node.js guideServices, CLIs and serverless functions
- Go guideServices and workers on the standard library
- Java guideJVM backends on Java 17+, no libraries
- C# / .NET guideAsync .NET 8 services and tools
- Ruby guideScripts, Rails apps and background jobs
- Selenium guideQA suites and WebDriver flows
- Playwright guideEnd-to-end tests in Node.js or Python
- Puppeteer guideChrome automation scripts
- Scrapy guideCrawls that run into captcha pages