Skip to content

Add to your Agent

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 / Dedicated Agent Docs, 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.

  1. Katcha to website or app: Load Widget (Site Key)
  2. Website or app to Katcha: Request & Solve Challenge
  3. Katcha to website or app: Issue Token katcha-token
  4. Website or app to website server: Submit Form + Token
  5. Website server to Katcha: POST Verification (Token + Secret Key)
  6. Katcha to website server: Valid Token Response (success)

1. Get your Site Key and Secret Key ​

Before adding the widget, you need credentials from the Katcha dashboard:

  1. Sign up or log in to the Katcha dashboard.
  2. Create a new site (or select an existing one).
  3. Copy your site key, used client-side in data-site-key.
  4. Copy your secret key, used server-side when calling the verify API.

WARNING

Never expose your secret key in client-side code or public repositories.

2. How it works ​

You embed the Katcha widget on your site, for example, on a login or signup form.

Frontend ​

  1. You embed the Katcha widget on your website, for example, in a login form.
Frontend Code Example (Simple)
html
<html>
  <head>
    <title>Katcha Demo</title>
    <script src="https://widget.katcha.eu/1/api.js" async defer></script>
  </head>
  <body>
    <form method="POST" action="/login">
      <!-- Your other fields, like email and password, go here -->
      <input type="text" name="email" placeholder="Email" />
      <input type="password" name="password" placeholder="Password" />

      <!-- Katcha widget -->
      <div class="katcha" data-site-key="YOUR_SITE_KEY"></div>

      <br />

      <!-- The hidden `katcha-token` is added automatically after solving -->
      <input type="submit" value="Submit" />
    </form>
  </body>
</html>
Frontend Code Example (Programmatic)
html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Katcha Execute Example</title>
    <!-- 1. Load Katcha Widget -->
    <script src="https://widget.katcha.eu/1/api.js" async defer></script>

    <script>
      let widgetId = null;

      // 2. Render invisible Katcha widget programmatically
      function initKatcha() {
        widgetId = katcha.render("#katcha-container", {
          site_key: "YOUR_SITE_KEY",
          size: "invisible",
          callback: onSolve,
          error_callback: onError,
          expired_callback: onExpired,
        });
      }

      function onSolve(token) {
        // Called after successful challenge solve
        console.log("Katcha solved:", token);
        document.getElementById("demo-form").submit();
      }

      function onError(err) {
        console.error("Katcha error:", err);
      }

      function onExpired() {
        console.warn("Katcha token expired");
      }

      function onManualStep(event) {
        event.preventDefault();
        // 3. Trigger the Katcha workflow programmatically
        if (widgetId === null) {
          console.error("Widget not yet initialized");
        } else {
          katcha.execute(widgetId);
        }
      }

      window.onload = initKatcha;
    </script>
  </head>
  <body>
    <form id="demo-form" action="/submit" method="POST">
      <input type="text" name="name" placeholder="Name" required /><br /><br />
      <!-- 4. Widget container -->
      <div id="katcha-container"></div>
      <br />
      <button id="submit-btn" onclick="onManualStep(event)">Submit</button>
    </form>
  </body>
</html>
  1. The user completes a Katcha challenge (checkbox or interactive challenge).
  2. Katcha returns a token, which is embedded in your form as katcha-token.
  3. The user submits the form. The token is sent to your server along with the form data.

Backend ​

  1. Your server sends the token, site key, and secret key to the Katcha verify API.
Backend Code Example (Python / Flask)
python
import os
import requests
from flask import Flask, request, jsonify

# Katcha verification API endpoint
KATCHA_VERIFY_URL = "https://api.katcha.eu/katcha/api/verify"

# Your credentials from the Katcha dashboard
SITE_KEY = os.getenv("KATCHA_SITE_KEY", "your_site_key")
SECRET_KEY = os.getenv("KATCHA_SECRET_KEY", "your_secret_key")

app = Flask(__name__)

def verify_katcha_token(token: str) -> dict:
    """
    Sends a POST request to Katcha's verify endpoint
    and returns a result dict including 'success' (bool)
    and any error or response fields.
    """
    payload = {
        "secret_key": SECRET_KEY,
        "site_key": SITE_KEY,
        "challenge_id": token,
    }
    headers = {"Content-Type": "application/json"}

    response = requests.post(KATCHA_VERIFY_URL, json=payload, headers=headers)
    response.raise_for_status()

    data = response.json()
    return {
        "success": data.get("success", False),
        "data": data,
    }

@app.route("/login", methods=["POST"])
def login():
    # 1) Retrieve token from form POST
    token = request.form.get("katcha-token")
    if not token:
        return jsonify({"error": "Missing Katcha token"}), 400

    # 2) Verify token via Katcha API
    result = verify_katcha_token(token)

    # 3) Decision logic
    if result["success"]:
        # Token is valid -> proceed with your business logic
        return jsonify({"status": "Logged in"}), 200
    else:
        # Verification failed
        return jsonify({
            "error": "Verification failed",
            "details": result["data"],
        }), 403

if __name__ == "__main__":
    app.run(debug=True, port=5000)
  1. Katcha verifies the token and returns whether it is valid, allowing your server to determine whether to accept the request.
  2. Based on the verification result, your server determines that the requester is not a bot and allows the request to proceed (e.g., login or signup). Pretty simple!

3. Integrate with AI Agents ​

Using an AI coding assistant like Claude Code, Cursor, ChatGPT, or OpenCode? You can integrate Katcha automatically without writing integration boilerplate manually.

1-Click Agent Prompt ​

Copy this prompt and provide it to your agent:

text
Please read https://docs.katcha.eu/onboard.md and help me integrate Katcha into this project.

Machine-Readable Specifications ​

For deep technical specifications or full context ingestion:

Desktop Sidebar Widget

You can also use the "Add to your Agent" widget in the right sidebar Table of Contents on any documentation page to launch Claude Code, Cursor, ChatGPT, or copy prompts in one click!