Skip to content

2Captcha format API

2Captcha's in.php and res.php for Turnstile, so a 2Captcha client works after changing only its base URL and key. Priced and charged as the other dialects are. Every reply is HTTP 200, as plain text or, with `json=1`, JSON; only a failure outside the endpoint is a problem document.

Every operation of the API reference is generated from the contract the API serves, version 0.1.0. Replace YOUR_API_KEY in the samples with your key; each response shows an example in the contract's shape.

Submit a task (2Captcha)

GET/in.php

Authentication. Your API key, as key in the query string, as 2Captcha's clients send it.

2Captcha's in.php for Cloudflare Turnstile: method=turnstile with sitekey and pageurl, and optionally action, data, proxy and pingback. The reply is OK|<task id>, or {"status": 1, "request": "<task id>"} with json=1; poll res.php with the ID. Priced, held and charged as POST /v1/tasks is; an Idempotency-Key header works as it does there.

Parameters

Parameters of Submit a task (2Captcha)
FieldWhat it is
keyquerystringRequired

Your API key, zc_live_…. A missing or malformed one is ERROR_WRONG_USER_KEY, an unknown or revoked one ERROR_KEY_DOES_NOT_EXIST.

methodquerystringRequired

turnstile; any other method is ERROR_BAD_PARAMETERS.

sitekeyquerystringRequired

The widget's site key.

pageurlquerystringRequired

The page the widget is on: a public http or https page, as websiteURL is on REST. Missing or invalid, ERROR_PAGEURL.

actionquerystring

The widget's action, if it sets one.

dataquerystring

The widget's cData, if it sets one.

pingbackquerystring

Where to POST the result once the task ends: 2Captcha's pingback form, id and code, signed with your callback secret. Any public URL, with no registration.

jsonqueryinteger

1 for JSON replies; 0, the default, for plain text.

proxyquerystring

Your proxy as login:password@host:port or host:port; the task then runs through it.

proxytypequerystring

HTTP, the default, or HTTPS. SOCKS is not supported yet (ERROR_PROXY_FORMAT).

soft_idquerystring

Accepted and ignored.

header_acaoqueryinteger

Accepted and ignored: this service sends no CORS headers.

pagedataquerystring

Sent for a Turnstile widget on a Cloudflare challenge page, which this format does not serve: a task with it is ERROR_BAD_PARAMETERS, and nothing is charged. Pass the page as a CloudflareChallengeTask through createTask or the REST API instead.

userAgentquerystring

Accepted and ignored.

Idempotency-Keyheaderstring

Your ID for this task, 1 to 255 visible ASCII characters, as on POST /v1/tasks.

Responses

Responses of Submit a task (2Captcha)
StatusWhat it means
200 OK

OK|<task id>, or an error code such as ERROR_ZERO_BALANCE; with json=1, the same as JSON.

text/plain, TwoCaptchaReply (application/json)

Any other status

Only a failure outside the dialect, as RFC 9457 problem details: a body over the size limit (413), a request that ran out of time (504), this instance shedding load (503, with Retry-After) or a fault in the server (500). Every other failure is HTTP 200 with an error code.

Problem (application/problem+json)

Error codes

The errors reference says what each means, whether a retry helps and what it costs.

Request

Terminal window
curl 'https://api.zerocaptcha.io/in.php?key=YOUR_API_KEY&method=turnstile&sitekey=0x4AAAAAAAB1cD2eF3gH4iJ5&pageurl=https%3A%2F%2Fexample.com%2Flogin&json=1' \
-H "Idempotency-Key: order-4521-attempt-1"

Response

200 OK text/plain, TwoCaptchaReply (application/json)

OK

{
  "status": 1,
  "request": "10000004821"
}

ERROR_ZERO_BALANCE

{
  "status": 0,
  "request": "ERROR_ZERO_BALANCE",
  "error_text": "Your available balance does not cover the task. Add funds."
}

JSON, as the samples ask with json=1. Without it, the same replies in plain text: OK|10000004821, ERROR_ZERO_BALANCE.

Example values in the contract's shape, version 0.1.0.

Submit a task by POST (2Captcha)

POST/in.php

Authentication. Your API key, as key in the form or JSON body, or in the query string, which wins, as 2Captcha's clients send it.

in.php as a POST, the way 2Captcha's own clients send it: the parameters as a form (application/x-www-form-urlencoded or multipart/form-data) or a JSON object, and any in the query string too, which win. The replies are those of GET /in.php.

Parameters

Parameters of Submit a task by POST (2Captcha)
FieldWhat it is
Idempotency-Keyheaderstring

Your ID for this task, 1 to 255 visible ASCII characters, as on POST /v1/tasks.

Request body Form · TwoCaptchaSubmit

Also taken as multipart/form-data or a JSON object.

Fields of the request body
FieldWhat it is
keystringRequired

Your API key, zc_live_…. A missing or malformed one is ERROR_WRONG_USER_KEY, an unknown or revoked one ERROR_KEY_DOES_NOT_EXIST.

methodstringRequired

turnstile; any other method is ERROR_BAD_PARAMETERS.

pageurlstringRequired

The page the widget is on: a public http or https page, as websiteURL is on REST. Missing or invalid, ERROR_PAGEURL.

sitekeystringRequired

The widget's site key.

actionstring or null

The widget's action, if it sets one.

datastring or null

The widget's cData, if it sets one.

header_acaointeger or null

Accepted and ignored: this service sends no CORS headers.

jsoninteger or null

1 for JSON replies; 0, the default, for plain text.

pagedatastring or null

Sent for a Turnstile widget on a Cloudflare challenge page, which this format does not serve: a task with it is ERROR_BAD_PARAMETERS, and nothing is charged.

pingbackstring or null

Where to POST the result once the task ends: 2Captcha's pingback form, id and code, signed with your callback secret. Any public URL, with no registration.

proxystring or null

Your proxy as login:password@host:port or host:port; the task then runs through it.

proxytypestring or null

HTTP, the default, or HTTPS. SOCKS is not supported yet (ERROR_PROXY_FORMAT).

soft_idstring or null

Accepted and ignored.

userAgentstring or null

Accepted and ignored.

Responses

Responses of Submit a task by POST (2Captcha)
StatusWhat it means
200 OK

OK|<task id>, or an error code such as ERROR_ZERO_BALANCE; with json=1, the same as JSON.

text/plain, TwoCaptchaReply (application/json)

Any other status

Only a failure outside the dialect, as RFC 9457 problem details: a body over the size limit (413), a request that ran out of time (504), this instance shedding load (503, with Retry-After) or a fault in the server (500). Every other failure is HTTP 200 with an error code.

Problem (application/problem+json)

Error codes

The errors reference says what each means, whether a retry helps and what it costs.

Request

Terminal window
curl -X POST https://api.zerocaptcha.io/in.php \
-H "Idempotency-Key: order-4521-attempt-1" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d 'key=YOUR_API_KEY&method=turnstile&pageurl=https%3A%2F%2Fexample.com%2Flogin&sitekey=0x4AAAAAAAB1cD2eF3gH4iJ5&json=1'

Response

200 OK text/plain, TwoCaptchaReply (application/json)

OK

{
  "status": 1,
  "request": "10000004821"
}

ERROR_ZERO_BALANCE

{
  "status": 0,
  "request": "ERROR_ZERO_BALANCE",
  "error_text": "Your available balance does not cover the task. Add funds."
}

JSON, as the samples ask with json=1. Without it, the same replies in plain text: OK|10000004821, ERROR_ZERO_BALANCE.

Example values in the contract's shape, version 0.1.0.

Get a result or the balance (2Captcha)

GET/res.php

Authentication. Your API key, as key in the query string, as 2Captcha's clients send it.

2Captcha's res.php. action=get&id=<task id> answers CAPCHA_NOT_READY while the task runs, then OK|<token>, or an error code such as ERROR_CAPTCHA_UNSOLVABLE (nothing charged) or ERROR_TOKEN_EXPIRED; action=get2 adds the price, OK|<token>|<price>. action=get&ids=<id>,<id>,… reads up to 100 tasks at once: each one's token, CAPCHA_NOT_READY or error code, in order, joined by |. action=reportbad or reportgood with id records whether the site took the token (OK_REPORT_RECORDED): recorded for our staff, never refunded, as tasks are final. action=getbalance answers the available balance in US dollars, such as 12.3456. With json=1, each as {"status": …, "request": …}. Reads share their budgets with REST; over one, the reply is ERROR: 1005 with Retry-After. action=get or get2 with id, of a task still running, is answered as soon as the task ends, or after a few seconds with CAPCHA_NOT_READY.

Parameters

Parameters of Get a result or the balance (2Captcha)
FieldWhat it is
keyquerystringRequired

Your API key, as for in.php.

actionquerystringRequired

get for a task's token (or several tasks' with ids), get2 for its token and price, reportbad or reportgood to say whether the site took its token, or getbalance for the available balance. Missing, ERROR_EMPTY_ACTION.

idquerystring

The task's ID, as in.php gave it, for get, get2, reportbad and reportgood; a task's UUID from another format works too. Not a task ID, ERROR_WRONG_ID_FORMAT; no task of this key's account, ERROR_WRONG_CAPTCHA_ID.

idsquerystring

With action=get, in place of id: up to 100 task IDs, comma-separated. The reply is each one's answer in order, joined by |, such as CAPCHA_NOT_READY|0.AbC…|ERROR_CAPTCHA_UNSOLVABLE.

jsonqueryinteger

1 for JSON replies; 0, the default, for plain text.

Responses

Responses of Get a result or the balance (2Captcha)
StatusWhat it means
200 OK

The token, CAPCHA_NOT_READY, several tasks' answers, OK_REPORT_RECORDED, the balance, or an error code; with json=1, the same as JSON.

text/plain, TwoCaptchaReply (application/json)

Any other status

Only a failure outside the dialect, as RFC 9457 problem details: a body over the size limit (413), a request that ran out of time (504), this instance shedding load (503, with Retry-After) or a fault in the server (500). Every other failure is HTTP 200 with an error code.

Problem (application/problem+json)

Error codes

The errors reference says what each means, whether a retry helps and what it costs.

Request

Terminal window
curl 'https://api.zerocaptcha.io/res.php?key=YOUR_API_KEY&action=get&id=10000004821&json=1'

Response

200 OK text/plain, TwoCaptchaReply (application/json)

OK

{
  "status": 1,
  "request": "token"
}

OK, with action=get2

{
  "status": 1,
  "request": "token",
  "price": "0.0004"
}

CAPCHA_NOT_READY

{
  "status": 0,
  "request": "CAPCHA_NOT_READY"
}

ERROR_CAPTCHA_UNSOLVABLE

{
  "status": 0,
  "request": "ERROR_CAPTCHA_UNSOLVABLE",
  "error_text": "The task was not solved, or not before its deadline; nothing is charged."
}

JSON, as the samples ask with json=1. Without it, the same replies in plain text: OK|token, OK|token|0.0004, CAPCHA_NOT_READY, ERROR_CAPTCHA_UNSOLVABLE.

Example values in the contract's shape, version 0.1.0.