Extended

Advanced integration options, verification flow, and API reference.

Last updated Jan 27, 2026

SDK (Preferred)

bun add @requestguard/js
import RequestGuard from "@requestguard/js";

RequestGuard.captcha({
  el: ".rg-captcha",
  theme: "dark",
  onVerify: (result) => {
    document.getElementById("contact-send").disabled = !result.success;
  }
});
<div class="rg-captcha"></div>
<button id="contact-send" disabled>Send</button>

Script Tag

<script src="https://requestguard.com/js/captcha.js"></script>
<div class="rg-captcha"></div>
<button id="contact-send" disabled>Send</button>
<script>
  RequestGuard.captcha({
    el: ".rg-captcha",
    theme: "dark",
    onVerify: (result) => {
      document.getElementById("contact-send").disabled = !result.success;
    }
  });
</script>

What onVerify Means

When the user completes the challenge, the widget exchanges the proof‑of‑work solution for a short‑lived verification token from RequestGuard, then the SDK verifies it in the background.

onVerify fires after the SDK’s background check and gives you { success, token, challenge_ts }. You can trust success for UX (enable buttons, auto‑submit). Tokens expire quickly and are single‑use by default, which prevents replay.

Invisible Mode

Use invisible mode to run verification in the background without showing the widget.

RequestGuard.captcha({
  el: ".rg-captcha",
  invisible: true,
  onVerify: (result) => {
    if (result.success) {
      document.getElementById("contact-send").disabled = false;
    }
  }
});

Language Override

Language is auto-detected from the browser by default. To force a specific language:

RequestGuard.captcha({
  el: ".rg-captcha",
  language: "de"
});

Verify Tokens Server-Side (Optional)

The SDK already verifies tokens with RequestGuard in the background. If you want stricter control, you can disable autoVerify and verify on your own backend.

POST https://requestguard.com/api/captcha/siteverify
{
  "response": "<token-from-client>"
}

Response

{
  "success": true,
  "challenge_ts": "2026-01-27T10:11:12.000Z"
}

Options

OptionTypeDescription
elstring | HTMLElementTarget element (required)
theme”auto” | “light” | “dark”Widget theme (default: auto)
invisiblebooleanHide the widget and auto-run verification (default: false)
onVerifyfunctionCalled after background verification
onErrorfunctionCalled when the widget reports an error
onResetfunctionCalled when the widget resets
fieldNamestringHidden input name (default: rg-captcha-token)
autoVerifybooleanVerify token automatically in the background (default: true)
verifyUrlstringOverride verification endpoint
apistringOverride API base used by the widget (default: /api/captcha/)
hoststringOverride RequestGuard host for self-hosting
originstringOverride origin sent to RequestGuard (default: window.location.origin)
instanceIdstringCustom instance ID for multi-captcha pages
titlestringIframe title for accessibility
widthstringIframe width (default: 100%)
heightstringIframe height (default: 90px)
borderRadiusstringIframe border radius (default: 12px)

Listening for Verification

You can listen via the instance or a DOM event:

<script>
  const instance = RequestGuard.captcha({ el: ".rg-captcha" });
  instance.on("verified", (event) => {
    console.log("verified token", event.detail.token);
  });

  document.addEventListener("rg:captcha:verified", (event) => {
    console.log("verified token", event.detail.token);
  });
</script>

API Endpoints

Challenge

POST https://requestguard.com/api/captcha/challenge

Returns challenge data and a challenge token for the widget.

Redeem

POST https://requestguard.com/api/captcha/redeem

Body:

{
  "token": "<challenge-token>",
  "solutions": [123, 456, 789]
}

Returns a short-lived verification token.

Site Verify

POST https://requestguard.com/api/captcha/siteverify

Body:

{
  "response": "<verification-token>"
}

Notes

  • No dashboard setup or domain registration is required.
  • The widget is delivered via iframe to keep branding and updates consistent.
  • Tokens expire automatically (typically within 20 minutes).
  • Use server-side verification for security.