# 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.

<figure class="katcha-flow" aria-label="Katcha installation walkthrough">
<div class="katcha-flow__lanes" aria-hidden="true">
<span><svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/></svg>Website / App</span>
<span><img class="katcha-flow__logo is-light" src="/brand/katcha-horizontal-black.svg" alt="Katcha"><img class="katcha-flow__logo is-dark" src="/brand/katcha-horizontal-green-white.svg" alt="Katcha"></span>
<span><svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="7" rx="1.5"/><rect x="3" y="13" width="18" height="7" rx="1.5"/><path d="M7 7.5h3M7 16.5h3"/></svg>Website Server</span>
</div>
<ol class="katcha-flow__steps">
<li class="is-left is-reverse"><span class="visually-hidden">Katcha to website or app: </span>Load Widget (Site Key)</li>
<li class="is-left"><span class="visually-hidden">Website or app to Katcha: </span>Request &amp; Solve Challenge</li>
<li class="is-left is-reverse"><span class="visually-hidden">Katcha to website or app: </span>Issue Token <code>katcha-token</code></li>
<li class="is-full"><span class="visually-hidden">Website or app to website server: </span><span class="katcha-flow__crossing">Submit Form + Token</span></li>
<li class="is-right is-reverse"><span class="visually-hidden">Website server to Katcha: </span>POST Verification (Token + Secret Key)</li>
<li class="is-right"><span class="visually-hidden">Katcha to website server: </span>Valid Token Response (success) <svg class="katcha-flow__check" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="10"/><path d="m6 10.4 2.6 2.6L14 7.6"/></svg></li>
</ol>
</figure>

## 1. Get your Site Key and Secret Key

Before adding the widget, you need credentials from the [Katcha dashboard](https://dashboard.katcha.eu/log-in):

1. [Sign up or log in](https://dashboard.katcha.eu/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.

<details>
<summary>Frontend Code Example (Simple)</summary>

```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>
```

</details>

<details>
<summary>Frontend Code Example (Programmatic)</summary>

```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>
```

</details>

2. The user completes a Katcha challenge (checkbox or interactive challenge).
3. Katcha returns a token, which is embedded in your form as `katcha-token`.
4. The user submits the form. The token is sent to your server along with the form data.

### Backend

5. Your server sends the token, site key, and secret key to the Katcha verify API.

<details>
<summary>Backend Code Example (Python / Flask)</summary>

```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)
```

</details>

6. Katcha verifies the token and returns whether it is valid, allowing your server to determine whether to accept the request.
7. 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:
- **[Agent Onboard Specification](https://docs.katcha.eu/onboard.md)**: Authoritative integration instructions detailing client script embedding, container placement, token extraction, server verification endpoints, and official SDKs.
- **[Documentation Index (llms.txt)](https://docs.katcha.eu/llms.txt)**: High-density index of all documentation guides and resources.
- **[Consolidated Documentation (llms-full.txt)](https://docs.katcha.eu/llms-full.txt)**: Full technical documentation in a single unified reference.

**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!
