# Katcha documentation — complete English reference Source: /markdown/api/verify.md Page: /api/verify # Verify a response Verification is a **server-to-server POST** using `Content-Type: application/json`. Store your operator-approved full URL as `KATCHA_VERIFY_URL` on the server. The local widget demo uses a legacy verification path; do not infer or rename the endpoint from product branding. The public Katcha origin is unconfirmed. ## Request | JSON field | Required | Description | | --- | --- | --- | | `challenge_id` | Yes | Token submitted in the browser's `katcha-token` field | | `site_key` | Yes | Expected site key from trusted server configuration | | `secret_key` | Yes | Secret for the same account/site, read only on the server | ```json { "challenge_id": "TOKEN_FROM_FORM", "site_key": "YOUR_SITE_KEY", "secret_key": "YOUR_SERVER_ONLY_SECRET" } ``` Do not accept a verification URL, expected site key, or success flag from the browser. Treat tokens as single-use and time-limited; verify during the protected request rather than caching a token for later actions. ## Response | Field | Meaning | | --- | --- | | `success` | Boolean; only the literal `true` permits the action | | `error-codes` | Optional list of verification errors | Illustrative responses from the v4 contract: ```json { "success": true } ``` ```json { "success": false, "error-codes": ["invalid-input-response"] } ``` The local widget demo confirms request fields and the `success` check. Error identifiers also exist in the local API catalog. The verification service itself is not present in this workspace, so confirm its response serialization against staging before release. Do not substitute the separate `/2/siteverify` protocol (`sitekey`, `secret`, `response`) used by some older clients. ## Node.js example This framework-neutral helper uses server-side `fetch`. Supply the form token; it returns `false` on missing values, HTTP failure, timeout, malformed JSON, or any response without `success: true`. ```js export async function verifyKatcha(token) { const verifyUrl = process.env.KATCHA_VERIFY_URL; const siteKey = process.env.KATCHA_SITE_KEY; const secretKey = process.env.KATCHA_SECRET_KEY; if (typeof token !== 'string' || !token.trim()) return false; if (!verifyUrl || !siteKey || !secretKey) return false; try { const endpoint = new URL(verifyUrl); if (endpoint.protocol !== 'https:') return false; const response = await fetch(endpoint, { method: 'POST', redirect: 'error', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ challenge_id: token, site_key: siteKey, secret_key: secretKey }), signal: AbortSignal.timeout(5000) }); if (!response.ok) return false; const result = await response.json(); return result?.success === true; } catch (error) { return false; } } ``` In your route, after parsing the form, call `await verifyKatcha(request.body['katcha-token'])`. If it returns `false`, stop before any protected side effect. Otherwise apply normal authentication, authorization, input validation, and CSRF checks. Never log the token or secret, and do not automatically replay verification after a timeout. ## Error code reference | Error code | Meaning | | --- | --- | | `missing-input-sitekey` | `site_key` is missing | | `missing-input-secret` | `secret_key` is missing | | `missing-input-response` | `challenge_id` is missing | | `bad-request` | Invalid or malformed request | | `invalid-input-sitekey` | Invalid site key | | `invalid-input-secret` | Invalid secret | | `invalid-input-response` | Invalid token | | `timeout-or-duplicate` | Expired or already used token | Ask for a fresh challenge after expiry or duplicate use. Correct server configuration errors rather than bypassing verification. Do not assume a precise token lifetime without confirmation from your deployment. --- Source: /markdown/guide/agents.md Page: /guide/agents # AI agent integration An assistant can help wire the widget and server verification into your project. Review generated changes as carefully as hand-written code. Begin with [quick start](/markdown/guide/quick-start.md), [configuration](/markdown/guide/configuration.md), and [verification](/markdown/api/verify.md). ## 1-click agent prompt Copy this text manually and provide the assistant with the guides or their content. Supply approved deployment URLs, not secrets. ```text Integrate Katcha into this project's protected form and server endpoint. Read the Katcha quick-start, configuration, and verification guides first. Ask for the deployed widget URL and verification URL if absent. Use window.katcha, the katcha container class, and the katcha-token form field. Verification JSON fields are challenge_id, site_key, and secret_key. Read the secret only on the server from KATCHA_SECRET_KEY. Never put secrets in browser code, public environment variables, prompts, or logs. Reject absent tokens, timeouts, malformed responses, and success values other than true. Retain authentication, authorization, input validation, and CSRF protection. Test both successful verification and failure paths. Do not invent package names, hosts, or renamed API paths. ``` Use **Copy integration prompt** in the page tools below for a prompt containing this page's Markdown URL and the onboarding URL on the current documentation host. Assistant cards copy the prompt for your project session; they do not launch third-party apps or send documentation automatically. ## Supported AI assistants This text workflow is assistant-independent: use Claude Code, Cursor, ChatGPT, OpenCode, or another assistant that can read your project. This does not imply a Katcha extension, partnership, or verified deep-link launch integration. ## Security architecture and best practices | Value | Placement | Review rule | | --- | --- | --- | | `site_key` | Browser and trusted server configuration | Public identifier, not proof of success | | `secret_key` | Server environment (`KATCHA_SECRET_KEY`) | Never expose in frontend bundles or prompts | | `katcha-token` | Form submission | Map to `challenge_id` on the server | | Verification URL | Server environment (`KATCHA_VERIFY_URL`) | Operator-approved HTTPS endpoint | **Keep secrets out of generated code** Use placeholders in prompts and examples. Exclude local secret files from source control. Rotate exposed secrets rather than only deleting the visible copy. ## Step-by-step workflow 1. Obtain credentials and deployment URLs from your operator. 2. Configure `KATCHA_SITE_KEY`, `KATCHA_SECRET_KEY`, and `KATCHA_VERIFY_URL` in the trusted server environment. These names are application conventions, not widget requirements; do not use a framework's public-variable prefix. 3. Identify the exact form and server action to protect. 4. Confirm the script serves the renamed Katcha distribution. 5. Review token mapping and require verification before side effects. 6. Test absent, expired, and duplicate tokens, network failure, malformed JSON, and success. Use mocks for failures and staging for deployment checks. 7. Inspect browser bundles to ensure they contain no secret key. ## Machine-readable specifications for agents Every published page provides copy actions and raw/download Markdown links on desktop and mobile. If clipboard access is blocked, select and copy the displayed fallback text. These actions do not read secrets or project files. - [Onboarding instructions](/onboard.md) are curated and validated against the published integration contract. - [Page index](/llms.txt) lists only approved English documentation. - [Full reference](/llms-full.txt) combines those same pages. - [This page as clean Markdown](/markdown/guide/agents.md) is available separately. The legacy skills ZIP has not been approved or regenerated for Katcha and is intentionally unavailable. Do not use legacy onboarding files as Katcha contracts. --- Source: /markdown/guide/configuration.md Page: /guide/configuration # Widget configuration This reference targets the CDN API exposed as `window.katcha`, not the native package factory API. Obtain your deployed widget URL from your operator. ## Katcha container configuration | HTML attribute | Render option | Values and behavior | | --- | --- | --- | | `data-site-key` | `site_key` | Required public site key | | `data-size` | `size` | `normal` (default) or `invisible` | | `data-theme` | `theme` | `light` (default) or `dark` | | `data-color` | `color` | Optional color name or hex code | | `data-error-print` | `error_print` | `0` shows inline errors (default); `1` hides them | | `data-lang` | `lang` | Use `en` for English; implementation default is `fa` | | `data-callback` | `callback` | Success; receives the token string | | `data-rendered-callback` | `rendered_callback` | Widget rendered | | `data-blocked-callback` | `blocked_callback` | Challenge blocked | | `data-error-callback` | `error_callback` | Receives legacy `{ code, message }` errors | | `data-reset-callback` | `reset_callback` | Reset notification; public `reset()` does not emit it | | `data-expired-callback` | `expired_callback` | Token expired | | `data-chlexpired-callback` | `chlexpired_callback` | Challenge expired | | `data-clicked-callback` | `clicked_callback` | Checkbox clicked or execution started | | `data-opened-callback` | `opened_callback` | Challenge opened | | `data-closed-callback` | `closed_callback` | Challenge closed | For automatic rendering, callback names must resolve to functions on `window`. For explicit rendering, pass functions or global function names. Success callbacks receive a **string**, unlike the object returned by `execute()`. ```html
``` Provide a status element and load your deployment's widget script after defining callbacks. A completion message is not authorization: [verify on the server](/markdown/api/verify.md). ## JavaScript API The following methods belong to the CDN/SDK public API. Reset, token retrieval, and execution target the first widget when the widget ID is omitted. Pass an explicit ID when a page contains more than one widget. ### katcha.render(container, params) Renders a widget and returns a **string widget ID**. Supply a CSS selector (for example, `#captcha`) or element, and options from the table above. The native package's `createKatcha()` interface returns a widget handle instead; do not mix the APIs. ### katcha.reset(widgetID) Resets the selected widget and clears its token. Returns `undefined` without invoking `reset_callback`. Use it to prepare a fresh attempt, not to reuse tokens. ### katcha.getKatchaToken(widgetID) Returns the current token, or no usable token before success or after reset. The old `getArcToken` name is not a Katcha alias. ### katcha.execute(widgetID) Starts the workflow, normally on an invisible widget. Await its promise and handle rejection, including dismissal and expiration. Success resolves to `{ katcha_token, site_key }`; success callbacks still receive only a token string. ```js try { const { katcha_token } = await window.katcha.execute(widgetId); if (katcha_token) { document.getElementById('protected-form').requestSubmit(); } } catch (error) { document.getElementById('captcha-status').textContent = 'Please try again.'; } ``` Here `widgetId` must be the ID returned by `render`. Do not use this pattern in a submit handler that recursively invokes itself through `requestSubmit()`. ## Explicitly render Katcha Use a container **without** the `.katcha` discovery class. Render only after the script loads; an asynchronous script is not necessarily ready for adjacent code. Replace the `.example` script host with your deployed Katcha host. ```html ``` This uses the script element's `onload`, not an assumed `?onload=` query contract. Do not render the same element both explicitly and through automatic discovery. ## Error handling (client-side) Set `data-error-callback="onCaptchaError"` and define the function before loading the script. Provide a status element and a retry path without logging tokens. ```js window.onCaptchaError = function ({ code, message }) { document.getElementById('captcha-status').textContent = `Challenge failed (${code}). Please try again.`; }; ``` | Legacy code | Meaning | | --- | --- | | `101` | Challenge creation server error | | `102` | Challenge creation network error | | `201` | Answer server error | | `202` | Answer network error | | `203` | Incorrect answer | | `401` | Unknown-error conversion fallback; not emitted by the legacy error callback | The legacy callback does not report all rejected executions. Handle the promise separately for dismissal, blocked challenges, and expiration. Client errors are not [server verification error codes](/markdown/api/verify.md#error-code-reference). ## Integration testing: test keys **No bot protection** The built-in test key bypasses challenge requests. Never use it on production forms or treat its deterministic token as proof of a real challenge. ### Test key set | Widget test value | Default | | --- | --- | | Site key | `0000000000` | | Generated token | `000000000000000000000000000000` | These widget defaults are configurable at build time and test browser integration only. The source documentation's test secret is not verified against the Katcha verification deployment and is not published here. Use a mocked verification service for automated application tests, or operator-approved staging credentials for end-to-end checks. --- Source: /markdown/guide/installation.md Page: /guide/installation # Installation You need a site key, a server-only secret, and operator-approved widget and verification URLs. Start with the [key separation guide](/markdown/guide/quick-start.md). ## 1. Add the Katcha widget to your webpage Load the widget over HTTPS. Replace the `.example` host below with your deployed Katcha widget host; the local server serves `/api.js`. A historical CDN address is not proof that it serves the renamed widget. ```html ``` The script discovers `.katcha[data-site-key]` containers automatically. Keep the container inside the form so the hidden `katcha-token` field is submitted with other fields. Deployments may override this field name; confirm your configuration. Your server must reject unverified submissions even if JavaScript is disabled. For WebViews without a reliable hostname, the script supports a domain override. Use the domain registered for your site, not an arbitrary value: ```html ``` Include only one script, not both examples. For dynamically inserted containers, use [explicit rendering](/markdown/guide/configuration.md#explicitly-render-katcha). ## 2. Verify the user response server-side Read `katcha-token` on your server and construct this JSON body: ```json { "challenge_id": "TOKEN_FROM_FORM", "site_key": "YOUR_SITE_KEY", "secret_key": "YOUR_SERVER_ONLY_SECRET" } ``` POST it to your configured verification URL with `Content-Type: application/json`. The backend field remains `challenge_id`: changing a form input's name does not rename the service protocol. Only `success: true` permits the protected action. Treat tokens as short-lived, single-use values. Do not cache successful tokens for later requests or retry business actions with an already consumed token. Ask for a fresh challenge after failure or expiration. See [Verify a response](/markdown/api/verify.md) for server code and errors, and [configuration](/markdown/guide/configuration.md) for callbacks, reset, and test behavior. The flow diagram and video from the older product are omitted: the text flow in quick start is complete without unreviewed branding or remote embeds. --- Source: /markdown/guide/invisible-captcha.md Page: /guide/invisible-captcha # Invisible CAPTCHA Invisible mode omits the checkbox. A challenge may still appear when a user submits. Your server must verify the token just as it does for a normal widget. ## Automatically bind the challenge to a button A `.katcha` button or input host runs in invisible mode. Supply your site key and a callback that submits only after success. Replace the `.example` script host with your deployed Katcha host. ```html ``` The widget adds the hidden `katcha-token` field. The server must reject unverified submissions, including those that bypass the button. ## Programmatically bind the challenge to a button or invoke the challenge Use [explicit rendering](/markdown/guide/configuration.md#explicitly-render-katcha) with `size: 'invisible'`. Keep the returned ID to avoid executing the wrong widget. ## Programmatically invoke the challenge Validate the form first, then await [katcha.execute](/markdown/guide/configuration.md#katchaexecutewidgetid). Handle cancellation and errors; do not accept a browser success as server authorization. ### Example ```html ``` Execution is bound to the button, not a submit handler that calls itself again through `requestSubmit()`. Ordinary keyboard submission must also be safe: enforce [verification](/markdown/api/verify.md) at the server regardless of how the request arrives. --- Source: /markdown/guide/quick-start.md Page: /guide/quick-start # Quick start **Integrate with AI Agents in Seconds** Building with **Claude Code**, **Cursor**, **ChatGPT**, or **OpenCode**? You can integrate Katcha automatically without writing integration boilerplate manually. Just copy this prompt to your agent: ```text Please read https://docs.katcha.eu/onboard.md and help me integrate Katcha into this project. ``` Or jump to [Section 3: Integrate with AI Agents](#integrate-with-ai-agents) / [Dedicated Agent Docs](/markdown/guide/agents.md), or click your assistant in the **"Add to your Agent"** sidebar widget! The Katcha widget can protect your applications from bots, spam, SMS fraud, and other forms of automated abuse. Installing Katcha is fast and easy. It requires adding some simple HTML and server-side code.katcha-tokenEverything needed to drop Katcha into a site: the script tag, the verify endpoint, and how to test both before going live.