Skip to content

Testing ​

CaptchaLa publishes two fixed key pairs for automated tests, CI pipelines and local development. They work like real app credentials with every client SDK (Web, Android, iOS and the other platform SDKs) and every server SDK. Nothing in your integration code has to change. You only swap the keys.

  • No CAPTCHA is shown. The widget completes on its own.
  • You do not need an account or an app.
  • The keys work from any origin, including localhost, 127.0.0.1 and pages opened from file://. Mobile apps can use any package name or bundle id.
  • Test traffic has no risk checks and is not subject to production rate limits (it has its own, see Limits). It does not count toward any quota, is never billed and never appears in any dashboard statistics.

Never ship test keys

The test keys are public and their tokens prove nothing about the visitor. Keep them out of production configuration. As a second safeguard, reject any /v1/validate answer that has data.test === true in production.

Test keys ​

BehaviorApp key (sitekey, X-App-Key)App secret (X-App-Secret)
Always passestest_pass_7f3c9a2e5b18d4f6test_secret_pass_c41e8b0d27a95f3e
Always failstest_fail_2d9e6b4a0c7f1835test_secret_fail_9b5f03e7d1a46c28

Use the app key in your frontend and the matching secret on your server, exactly where the real values would go.

What each pair does ​

Always passes ​

  • Widget: completes without showing a challenge, after a very short invisible check, and calls your success callback with a pass token. Test pass tokens start with pt_test_.
  • POST /v1/validate with the always-pass secret:
    • A pt_test_ token issued by the widget returns valid: true and test: true. Like a real token it is single-use: validating it a second time returns valid: false with error: "token_invalid", unless you pass keep_token=true. It expires after 5 minutes (token_not_found).
    • A placeholder string, such as XXXX.DUMMY.TOKEN, returns valid: true. Use this when you test only your backend and do not run the widget. Placeholders are not consumed.
    • A real pass token (pt_… from a real app) or a degraded token (dg_…) returns valid: false with error: "token_invalid". A test secret never accepts a real token.

Always fails ​

  • Widget: runs as usual, then reports a failure. On the web the widget shows its error state and calls your error callback with too_many_failures. It does not retry and never falls back to offline mode. The Android and iOS SDKs call their error callback with verify_failed. No pass token is produced.
  • POST /v1/validate with the always-fail secret: any non-empty pass_token returns valid: false with error: "test_always_fail".

The test flag ​

Every answer to a test key carries data.test: true. A successful validation has the same fields as a real one, with neutral values, so your parsing code is exercised:

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "valid": true,
    "test": true,
    "challenge_id": null,
    "action": "test",
    "uid": null,
    "captcha_args": {
      "platform": "web",
      "user_ip": null,
      "referer": null,
      "pkg": null,
      "solved_at": 1750000000,
      "risk_score": 0
    },
    "hostname": null,
    "challenge_ts": "2025-06-15T15:06:40Z",
    "risk_level": "low",
    "risk_labels": []
  }
}

Failures use the normal failure shape:

json
{ "code": 0, "msg": "success", "data": { "valid": false, "error": "test_always_fail", "test": true } }

action is always "test". expected_action and expected_hostname are ignored, and identity bindings such as bind_uid are not echoed back.

Credentials are never interchangeable ​

  • A test secret paired with a real app key, a real secret paired with a test key, or the always-pass secret with the always-fail key (or the reverse): invalid_app_secret.
  • A test token (pt_test_…) sent to a real app's /v1/validate: valid: false, error: "token_invalid".
  • A real token sent with a test secret: valid: false, error: "token_invalid".

Server-issued tokens ​

POST /v1/server/challenge/issue accepts both test pairs, so you can test the server_token flow end to end:

bash
curl -X POST https://verify.captcha.la/v1/server/challenge/issue \
  -H "X-App-Key: test_pass_7f3c9a2e5b18d4f6" \
  -H "X-App-Secret: test_secret_pass_c41e8b0d27a95f3e" \
  -d "action=login&ttl=300&max_uses=1"

# → { "code": 0, "data": { "server_token": "sct_test_...", "expires_in": 300, "issued_at": 1750000000, "test": true } }
  • Pass the sct_test_ token to the widget as serverToken, as you would in production.
  • ttl and max_uses behave as documented. A test server token that is used up returns server_token_exhausted, and an expired one returns server_token_invalid.
  • A test key refuses any server token that is not a sct_test_ token, and real apps refuse sct_test_ tokens.
  • bind_ip, bind_uid and the other bindings are accepted but not enforced.

Example: end-to-end test ​

html
<!-- test page, e.g. served from localhost or opened from file:// -->
<script>
loadCaptchala(function () {
  Captchala.init({ appKey: 'test_pass_7f3c9a2e5b18d4f6', product: 'embed', action: 'login' })
    .onSuccess(function (res) { document.body.dataset.token = res.token; })
    .appendTo('#captcha');
});
</script>
bash
# your backend, configured with the matching test secret
curl -X POST https://verify.captcha.la/v1/validate \
  -H "X-App-Key: test_pass_7f3c9a2e5b18d4f6" \
  -H "X-App-Secret: test_secret_pass_c41e8b0d27a95f3e" \
  -d "pass_token=$TOKEN"

On Android and iOS, set .appKey("test_pass_7f3c9a2e5b18d4f6") in the SDK configuration. The flow and callbacks are unchanged.

Limits ​

  • Test traffic has its own generous limit of 600 requests per minute per IP address. Above that, requests get the normal ip_rate_limit_exceeded answer with retry_after.
  • The test keys never show a visible challenge. To check how your page looks with a real challenge, use your own app in the dashboard.

MIT-licensed examples · CaptchaLa is operated independently