Skip to content

For AI agents

This page is written for AI coding agents that add NoptCHA to someone’s code, and for developers who want to give their agent the rules in one place. Each rule links to the page with the details. The same content is available as Markdown at /docs/for-ai-agents.md, and the whole site is indexed in /llms.txt.

  1. Use the native API (v1): POST https://api.noptcha.com/v1/tasks, key in Authorization: Bearer ….
  2. Get it working in the keyless sandbox first (/v1/sandbox/tasks, no key, no account), then with a test key (nop_test_…), and only then with a live key (nop_live_…). The code does not change between them.
  3. Send Prefer: wait=60 and an Idempotency-Key: one request usually returns the finished task.
  4. Retry only 429, 5xx and network errors, honouring Retry-After; fix everything else. A task with status: "failed" is not charged.
  5. Put the token back where the page reads it (hidden field, callback), then submit. See Browser automation.
  6. Read the key from the environment. Never put it in front-end code, never commit it.
  7. Do not install packages named noptcha from PyPI or npm: the SDKs are not published yet. Use plain HTTP (examples below) or the helper modules.

NoptCHA has three APIs that share keys, prices and tasks. For new code, use the native API (v1): one request can wait for the result, retries are safe with idempotency keys, and errors are RFC 9457 problem details with a stable code. Use the createTask API or the in.php API only when the code already speaks one of those protocols (for example, it was written for anti-captcha or 2captcha) and you are only changing its base URL.

A request names a task type and its parameters:

{ "type": "turnstile", "params": { "website_url": "https://example.com/signup", "website_key": "0x4AAAAAAA…" } }

The type names and parameters are on the task type pages; each has a JSON Schema at https://noptcha.com/schemas/<type>.params.json, and /openapi.json describes every endpoint. Read the parameters from the page that shows the captcha: where the parameters are.

Stage Endpoint Key Answers
Keyless sandbox POST /v1/sandbox/tasks, GET /v1/sandbox/tasks/{id} none fixed test answers, limited per IP
Test key POST /v1/tasks, GET /v1/tasks/{id} nop_test_… the same fixed test answers, never charged
Live key POST /v1/tasks, GET /v1/tasks/{id} nop_live_… real solutions, charged only when solved

The request bodies, responses, validation and error codes are the same in all three. In the sandbox a token is NOPTCHA_TEST_TOKEN_<task id>, and magic values such as website_key: "test-unsolvable" or "test-slow-5" simulate failures and slow tasks, so you can test the error and polling paths before spending anything. A site will not accept a sandbox token: the sandbox checks your code, not the site.

The keyless sandbox runs without an account, so you can run this as is:

Terminal window
# no key needed: the keyless sandbox returns fixed answers (limited per IP)
# waits up to 60 s; 200 = finished (solved or failed), 202 = still processing
curl -s -X POST "https://api.noptcha.com/v1/sandbox/tasks?wait=60" \
-H 'Content-Type: application/json' \
-d @- <<EOF
{
"type": "turnstile",
"params": {
"website_url": "https://example.com/signup",
"website_key": "1x00000000000000000000AA",
"action": "signup"
}
}
EOF
# on 202: long-poll with the "id" from the response
TASK_ID=sbx_...
curl -s "https://api.noptcha.com/v1/sandbox/tasks/$TASK_ID?wait=60"

This is the shortest working call: ?wait=60 is the same as Prefer: wait=60 (the query form also works from a browser), and it does not retry. For real code, send Prefer: wait=60 with an Idempotency-Key and retry as described below, or copy solve() from the helper modules, which does both.

To move to a key, the user creates one in the console (API keys → Create key, mode Test first) and puts it in the NOPTCHA_KEY environment variable. Then use /v1/tasks instead of /v1/sandbox/tasks and add the Authorization: Bearer <key> header; nothing else changes. The keyless sandbox differs in a few details (no callback_url; Idempotency-Key is accepted but a retry creates another free sandbox task; smaller bodies; its own limits): see Keyless sandbox. Write the code so that the endpoint and key come from configuration, as the helper modules do: with NOPTCHA_KEY=keyless they use the keyless sandbox, with a nop_test_ or nop_live_ key they use /v1/tasks.

POST /v1/tasks with Prefer: wait=60 waits up to 60 seconds (at most 90) and returns:

  • 200 with the finished task: status is solved (read solution) or failed (read error.code);
  • 202 with status: "processing" if the task was not finished in time: long-poll GET /v1/tasks/{id}?wait=60 until the status is final.

Always handle 202, even if your tasks are usually fast: when many requests are waiting, the server can answer 202 at once. Send an Idempotency-Key (a new UUID per task) and, if you retry the request after a network error, the same key with the byte-for-byte same body, so that a retry returns the same task instead of creating a second one (Idempotency). A finished task can be read for 10 minutes. Details: Synchronous waiting.

There are two kinds of failure, and both need handling:

  • The request failed: HTTP 4xx or 5xx with a problem details body. Branch on its code, not on the message.
  • The task failed: HTTP 200 with status: "failed" and error.code. Nothing is charged.
Code What to do
rate_limited, concurrency_limited (429) Wait Retry-After seconds, then retry
service_unavailable (503) Wait Retry-After seconds, then retry; nothing was created or charged
internal (500), other 5xx Retry with backoff, with the same Idempotency-Key and body
Network error or timeout Retry the same request with the same Idempotency-Key and body
idempotency_conflict (409) If the first request is still being admitted, retry shortly; if the body differs, use a new key
invalid_params (422), invalid_request (400), unsupported_type (400), request_too_large (413) Fix the request; errors[].pointer names the field. Do not retry unchanged
unauthorized (401), forbidden (403) Check the key, its scopes and restrictions. Do not retry in a loop: invalid keys get the IP blocked
insufficient_balance, budget_exceeded (402) Stop and tell the user: the balance or the key’s budget needs topping up
Task unsolvable, timeout, proxy_error Free; you may create a new task for the same captcha (with a new idempotency key)
Task invalid_site, invalid_image Free; the parameters are wrong (site key, domain, image). Fix them before trying again

Clients must accept codes they do not know: treat an unknown 4xx as “fix first” and an unknown 5xx as retryable. The full list: Errors, What to retry, Rate limits.

The API returns a token; the captcha is solved only when the page’s own code receives it. Where it goes depends on the captcha (a hidden g-recaptcha-response, h-captcha-response or cf-turnstile-response field, a callback named in data-callback, or grecaptcha.execute() for reCAPTCHA v3): see the table in Putting the token back. Solve right before you submit, because tokens expire after a couple of minutes.

The helper modules (one Python file, one Node.js file, no dependencies besides requests) find the captcha’s parameters in the page, solve it and put the token back. Copy the module next to the script and wire it up as the framework page shows:

Framework Page
Playwright for Python Playwright (Python)
Playwright for Node.js Playwright (Node.js)
Puppeteer Puppeteer
Selenium for Python Selenium (Python)
browser-use browser-use
Stagehand Stagehand
Crawl4AI Crawl4AI

To run a framework example without an account, set NOPTCHA_KEY=keyless:

Terminal window
export NOPTCHA_KEY=keyless # keyless sandbox; later nop_test_..., then nop_live_...
python signup.py # the Playwright (Python) example
  • Read the key from an environment variable (NOPTCHA_KEY) or a secret manager. Do not hard-code it, and do not write it into files that are committed: keep it in an ignored .env file or the CI’s secrets.
  • Never send a nop_test_ or nop_live_ key to a browser: not in front-end JavaScript, not in a browser extension, not in the page you are automating (page.evaluate arguments end up in the page). Call the API from the server or the automation script; only the token goes into the page. (The keyless sandbox may be called from a browser; it needs no key.)
  • Prefer a key restricted to the task types you use, with a budget and, if the script runs from fixed addresses, an IP allowlist (Restrictions).
  • Do not print the key in logs or error messages. If it leaks, revoke it in the console and create a new one.

To make an agent follow these rules in a repository, add a short section to its instructions file (AGENTS.md, CLAUDE.md, .cursor/rules or similar):

## NoptCHA (captcha solving)
- Read https://noptcha.com/docs/for-ai-agents.md before changing captcha code.
- Use the v1 API (POST https://api.noptcha.com/v1/tasks, Prefer: wait=60, Idempotency-Key); handle 202 by long-polling.
- Develop and test against the sandbox (NOPTCHA_KEY=keyless or a nop_test_ key); never use a nop_live_ key in tests.
- The key comes from the NOPTCHA_KEY environment variable: never hard-code, commit, log or send it to a browser.