Xuda Bot Protection API Reference
Xuda Bot Protection API Reference
This reference covers the full method surface of Xuda Bot Protection: the two unauthenticated endpoints your website and your backend integrate against, and the nine dashboard methods that drive the Bot Protection Manager. It is written for developers wiring the "I'm not a robot" widget into their own pages, verifying passes server side, or understanding exactly what each screen in the manager does. Every parameter name, type and required flag below is taken from the shipped method contract.
How To Call These Methods
Every method here is a CPI method. CPI methods are dispatched by name over the Xuda API and MCP layer, and the normal credential for that layer is the account API key. For the transport-level detail, including how requests are framed and how the MCP layer exposes methods, see /api-mcp-integration.
Bot Protection is an unusual case and you should know it before you write a line of code. None of these methods is exposed in the API-key catalog. All eleven are flagged private, and a private method is excluded from the API-key catalog and refused for API-key callers. What that leaves you today is:
- Two methods with public clearance,
captcha_verifyandcaptcha_siteverify, which are callable unauthenticated athttps://<xuda origin>/cpi/<method>. These are the shipped integration surface. Your page calls the first through the Xuda-hosted widget, and your server calls the second directly. - Nine methods with user clearance that require a signed-in dashboard session, with the caller
uidinjected from that session. These are what the product's own screens call. They are documented in full because they define the product's behavior and because any future API tier would expose them.
Do not build against the nine session methods with an API key. They will be refused.
What The Availability Labels Mean
Every method below carries one explicit availability line. Read it first, because it tells you whether you can call the method from your own code today.
- Availability: API key means an external developer API key or the MCP layer can call it. No Bot Protection method currently carries this label.
- Availability: Dashboard session means a signed-in user in the Xuda dashboard can call it, and an API key cannot. The account identity comes from the session, never from a parameter.
- Availability: Public endpoint means no authentication at all. It is called from a browser or from your own server. Where a credential is involved, such as the secret key on
captcha_siteverify, it is carried in the body rather than in a session. - Availability: Operator only means Xuda staff, listed only for completeness. No Bot Protection method currently carries this label.
Method Index
| Method | What It Does |
|---|---|
| captcha_verify | Drives the escalation ladder for a visitor and returns pass, challenge or fail. |
| captcha_siteverify | Server-to-server check of a pass token, in the shape of reCAPTCHA and Turnstile siteverify. |
| get_bot_protection_settings | Reads one profile's widget setup, keys, escalation config and embed snippets. |
| update_bot_protection_settings | Saves the widget setup, mints keys on first enable, and rotates the secret. |
| get_bot_protection_profiles | Lists every protection profile the account owns, with target, state and stats. |
| bot_protection_attach | Attaches origin-side protection to a Xuda target and creates its profile and keys. |
| bot_protection_arm | Arms or disarms origin-side enforcement for a protected target. |
| bot_protection_detach | Removes protection from a target and deletes its profile, keys and rules. |
| bot_protection_set_custom_rules | Sets the sanitized custom rules object for one profile. |
| get_bot_protection_plans | Reads the four-tier plan ladder, the account's tier, its capabilities and its usage. |
| bot_protection_set_plan | Chooses the account's tier and moves the billing line for it. |
captcha_verify
Captcha Verify
Public endpoint behind the "I'm not a robot" widget. It drives the escalation ladder from the collected signals and returns one of three outcomes: pass with a single-use response token, challenge with the challenge to display, or fail with a reason. At level 0 it checks the honeypot, the proof-of-work nonce, the minimum age of the session token and the passive signal score. A failure there escalates to a level 1 image challenge of 9 tiles with one target shape, and then, if that is failed, to a level 2 AI check that either passes the visitor outright, blocks them, or asks one generated question. Answering an issued challenge is the same call with challenge_id and answer set. The session token and proof-of-work parameters it expects come from the widget bootstrap, which the Xuda router performs when it renders /captcha/<site_key>.
Availability: Public endpoint
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
site_key |
string | Yes | Public site key of the protection profile. |
session_token |
string | Yes | Session token minted by the widget bootstrap. |
signals |
object | No | Collected client signals: timing, interaction entropy, environment and fingerprint hashes, honeypot. |
pow_nonce |
number | No | Nonce found by the widget for the proof of work challenge. |
level |
number | No | Escalation level the client is answering (0 checkbox, 1 image, 2 AI). Declared in the API contract; the current implementation infers the level from the challenge being answered and does not read this field. |
challenge_id |
string | No | Id of the issued image or AI challenge being answered. |
answer |
object | No | Answer to the current challenge (image tile selection or AI challenge response). |
Notes
- Auth: none. The profile must exist and be enabled, or the call answers
status: fail, reason: not_enabled. - Failure reasons you can receive:
bad_request,not_enabled,rate_limited,session_bad_token,session_bad_sig,session_expired,session_too_fast,pow,challenge_expired,automation,ai_bot,ai_uncertainandexhausted. - The honeypot fails silently. When the decoy input is filled, the response is
status: failwith the deliberately uninformative reasonok. - Rate limited at 60 attempts per 60 seconds per IP and site key pair, and 600 per 60 seconds per site key. Both are in-process sliding windows.
- The session token lives 15 minutes by default. A pass attempted less than 800 ms after it was minted is rejected at level 0 as
session_too_fast. - Proof-of-work difficulty defaults to 16 leading zero bits, rises by 1 for medium aggressiveness and 2 for high, is floored at 8, and is clamped to 8..24 when an owner sets it by hand.
- An issued image challenge is good for 2 minutes, an issued AI challenge for 3 minutes. Past that the answer returns
challenge_expired. - Level 2 uses AI in two ways: a structured risk verdict of human, bot or borderline with a score, and, when the verdict is borderline, one generated common-sense question. The verdict must score at least 0.7 to pass at level 2. When the scorer is unreachable, the module degrades to a borderline verdict with the reason
scorer_unavailablerather than failing the visitor. - The level 2 AI calls run with the profile owner's account identity and count as the account's AI calls for the month. They are included in the plan and are never charged to credits.
- A check is counted after the proof holds. A plan's limit reads the checks on
surface: 'widget'setups only: anything hosted with Xuda (a target) is unlimited. AI calls count everywhere. - The check never stops and no form breaks. Past the month's checks or AI calls, level 2 is skipped for that account and the escalation falls through as if
l2_enabledwere false. - A pass returns a response token that lives 2 minutes and is burned on first verification. Hand it to your backend and verify it with
captcha_siteverify.
captcha_siteverify
Captcha Siteverify
Server-to-server verification of a captcha response token, in the shape of reCAPTCHA and Turnstile siteverify. The embedding site's own backend calls it with its secret key and the response token the widget put in the form, and it confirms whether the visitor passed. A success returns {success: true, score, level_reached, hostname, challenge_ts, "error-codes": []}. A failure returns {success: false, "error-codes": [...]}. Call it from your server only, never from page markup, because it carries the secret key.
Availability: Public endpoint
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
secret |
string | Yes | Private secret key of the protection profile. |
response |
string | Yes | The response token returned by the widget on pass. |
remoteip |
string | No | Optional visitor IP for auditing. |
Notes
- Auth: the secret key is the credential. No session and no API key is required.
- Idempotency: the token is single use. A second attempt with the same token answers
timeout-or-duplicate. Verify each token exactly once. - The response token lives 2 minutes. Verify on receipt, not from a delayed job.
- Error codes:
missing-input,invalid-input-secret,invalid-input-response,timeout-or-duplicate,internal-error. - Rotating the secret with
update_bot_protection_settingsinvalidates the old secret immediately, and every server still calling with it starts answeringinvalid-input-secret. - No plan gate above the activated Free tier. This is the only genuinely key-free programmatic surface the product has today.
- Because the request and response shapes match reCAPTCHA and Turnstile siteverify, existing backend code usually only needs its URL changed.
get_bot_protection_settings
Get Bot Protection Settings
Reads the widget setup of one account profile: whether it is enabled, the plan tier label, the public site key, the private secret key, the escalation configuration, the custom rules object, the contact-form gate flag, the widget profile id, the iframe URL and the two ready-to-paste snippets. Read only, and it never mints anything.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_id |
string | No | Account profile id whose bot protection settings to read. Omit for the active profile. |
Notes
- Auth: session user,
uidinjected from the session. - The caller must own the profile, or the call answers
-403 not_profile_owner. - The snippets it returns are built from the profile's own site key: a
<script src=".../dist/runtime/js/captcha-loader.js" data-sitekey="...">tag, an inline<div class="xuda-captcha" data-sitekey="...">mount, and the raw iframe URL/captcha/<site_key>. - No
min_plangate. Entitlement for this feature is enforced inside the module with a-402payload rather than by the platform plan gate.
update_bot_protection_settings
Update Bot Protection Settings
Saves the widget setup. Turning it on for the first time mints both keys. Turning it off is always allowed. Escalation values are sanitized and clamped. Returns the same shape as get_bot_protection_settings, refreshed.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_id |
string | No | Account profile id to update. Omit for the active profile. |
enabled |
boolean | No | Turn the widget on or off for this profile. |
escalation |
object | No | Escalation config: { aggressiveness (low|medium|high), pow_difficulty, clearance_ttl_ms, l1_enabled, l2_enabled }. |
custom_rules |
object | No | Custom protection rules (honored only on a plan with custom rules). |
require_on_contact_form |
boolean | No | Also require the check on this profile's embedded contact form. |
rotate_secret |
boolean | No | Mint a new secret key, invalidating the old one. |
Notes
- Auth: session user, profile ownership enforced.
- Plan gate: the
formscapability to enable the widget, andcustom_rulesfor the rules object. - Turning the widget on when the account has never chosen a plan answers
-402with the message "Activate the Free plan to use this. It costs nothing." - Passing
custom_ruleswithout the Business plan answers-402with aplan_requiredobject. In that case the rest of the save still applies but the rules do not. rotate_secret: truemints a new secret key and deletes the index entry for the old one, so any server still callingcaptcha_siteverifywith the old secret starts failing immediately. The site key is unaffected.- Clamps applied on save:
pow_difficultyto 8..24,clearance_ttl_msto 60000..86400000.
get_bot_protection_profiles
Get Bot Protection Profiles
Lists every protection profile the account owns, for the protection console. Each entry carries profile_id, the target object (type, kind, id, label, region), enabled, armed, plan_tier, surface (widget, origin or both), the site_key and a stats object with served, passed, challenged and blocked. Read only.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
- Capped at 500 profiles per account.
- Stats are approximate. Counters are buffered in process and only merged into the profile document when something else writes it, such as a settings save, an attach, an arm or a rules save, so a restart between writes loses the buffered delta.
bot_protection_attach
Bot Protection Attach
Attaches origin-side bot protection to a Xuda target, creating the protection profile, its site and secret keys and its enforcement index. Returns the profile summary. Attaching does not arm the target; call bot_protection_arm for that.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target_id |
string | Yes | Id of the target to protect (from ipv4_attach_targets). |
kind |
string | Yes | Target kind: vps, deployment, datacenter or balancer. |
plan_tier |
string | No | standard or custom. Declared in the API contract; the current implementation derives the tier label from the account plan and ignores this field. |
escalation |
object | No | Optional escalation config overrides. |
Notes
- Auth: session user.
- The target id must appear in the account's own attachable-target list, the same picker the dedicated-IP flow uses. A target that is not on the account is refused with
-404. - Plan gate: the
hostedcapability for Xuda-hosted targets,externalotherwise. Anything Xuda hosts is covered by the Free tier. - Idempotency: a repeated attach of the same target maps to the same profile, because the profile slug is derived from the target id.
- The attachable-target list returns Xuda-hosted targets only today, so in practice the
externalgate has nothing to consume.
bot_protection_arm
Bot Protection Arm
Arms or disarms the origin-side challenge for a protected target. Arming re-checks entitlement, mints keys if the profile has none, sets the profile enabled and stamps the current tier label. Disarming is always allowed. Returns the profile summary.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_id |
string | No | Bot protection profile id. Provide this or app_id. |
app_id |
string | No | App id of the protected target. Provide this or profile_id. |
armed |
boolean | Yes | True to enforce the challenge, false to stand down. |
Notes
- Auth: session user, ownership enforced,
-403 not_ownerotherwise. - Plan gate: the target's own capability when arming.
- Enforcement begins or ends at the edge within one 30 second refresh of the router's armed-target cache, not instantly.
app_idis the path the app-level "Bot Protection (Under Attack)" toggle uses. The app module'schange_under_attack_modereaches this behavior internally.- An armed target serves a full-page "Checking your browser" interstitial to uncleared visitors and, on pass, sets an httpOnly, secure, SameSite=Lax clearance cookie for the profile's clearance window, 30 minutes by default.
bot_protection_detach
Bot Protection Detach
Removes bot protection from a target: it deletes the site key, secret key and target index entries, deletes the profile document itself and drops any buffered stats.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_id |
string | Yes | Bot protection profile id to detach. |
Notes
- Auth: session user, ownership enforced.
- Custom rules on that profile are discarded with it and are not recoverable.
- Idempotency: detaching a profile that no longer exists answers
{ok: true}rather than an error.
bot_protection_set_custom_rules
Bot Protection Set Custom Rules
Sets the custom protection rules for one profile. Everything is sanitized server side: unknown modes are dropped, strings are truncated to 80 characters, lists are capped, the rate window is clamped, and the clearance TTL is clamped. Returns the refreshed profile summary.
The accepted rule object is { geo: {mode: off|challenge|block|allow, countries: [ISO2], regions: []}, hours: {mode: off|challenge, list: [0..23]}, days: {mode: off|challenge, list: [0..6]}, paths: [{pattern, action: challenge|block|allow}], rate: {window_s, max, action: challenge|block}, reputation: {allow_verified_search_bots, challenge_bad_asn}, allow_list: [ip|cidr|ISO2], block_list: [ip|cidr|ISO2], require_referer: bool, fingerprint_rules: [{match, action: challenge|block}], aggressiveness: low|medium|high, clearance_ttl_ms }.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_id |
string | Yes | Bot protection profile id to update. |
rules |
object | Yes | The custom rules object. |
Notes
- Auth: session user, ownership enforced.
- Plan gate:
custom_rules. Without the Business plan the call answers-402with aplan_requiredobject. - Caps enforced on save: 200 entries per list, 100 path rules, 20 fingerprint rules, 80 characters per entry, rate window clamped to 1..3600 seconds, rate maximum clamped to 1..100000 requests,
clearance_ttl_msclamped to 60000..86400000. - Rules are honored at the edge only when the profile is stamped
plan_tier: 'custom', which is derived from the account plan on every write. - Evaluation order at the edge is fixed: block list, allow list, verified search bots, geo, path prefix, hours, days, referer requirement, then the aggressiveness and clearance TTL overrides.
- Stored but not acted on at the edge today: the
ratethreshold,fingerprint_rules, andreputation.challenge_bad_asn. The router also always reports a request as not a verified bot, soreputation.allow_verified_search_botscannot fire as written. Do not depend on these four.
get_bot_protection_plans
Get Bot Protection Plans
Reads the plan ladder for the Bot Protection Manager: the four tiers with their names, taglines, descriptions, prices, ranks, feature lists, capability flags and a purchasable flag, plus which tier this account is on (plan_id, plan_name), whether it has activated at all (activated), when it last changed, whether a billing line exists for it (subscribed), a can map of capability booleans, and a usage object counting profiles, widgets, armed, external and custom beside the month's figures. Read only.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
- The month's figures in
usageare{ month, checks, ai, plan_checks, limit_checks, limit_ai, over }, andget_bot_protection_setupsreturns them too.plan_checksis what the limit reads (the widget surface), andoveris true past either limit. purchasableis true for all four tiers. A paid tier carries an emptyprice_id, and its Stripe price is minted on first purchase.- The
apicapability flag is defined and reported in thecanmap, but nothing in the module checks it, and no Bot Protection method is reachable with an API key.
bot_protection_set_plan
Bot Protection Set Plan
Chooses the account's bot protection tier, and it is the only place billing for this feature is ever attached. Paid tiers create or reprice one line item on the consolidated subscription under the bot_protection category. Moving back to Free removes that line. Returns the same payload as get_bot_protection_plans.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
plan_id |
string | Yes | bot_protection_free, bot_protection_starter, bot_protection_pro or bot_protection_business. |
deactivate |
boolean | No | Not declared in config.json, but implemented: moves the money as if Free was chosen and then unsets the account's plan field entirely, which is what every surface reads as "switched off". |
Notes
- Auth: session user. Answers
-401without a session,-404when the account document is missing, and-402when the payment side refuses the charge. - Billing moves first and the plan field is only written once the payment side agreed, so a failed charge can never leave the account holding a tier it is not paying for.
- Moving between paid tiers reprices the single existing line rather than adding a second charge.
- A downgrade that would strand external targets or active custom rules is refused with a sentence naming what is in the way.
- A downgrade to a paid plan waits for the end of the period already paid for: the answer carries
scheduled: trueandeffective(unix seconds), andplan_idstays the plan held until then. A move to Free takes the line off now, with the unused part credited on the next invoice. - After the plan changes, every one of the account's profiles is restamped with the new tier label so the enforcement edge stays in step.
- One plan per account, not per protected thing. There is no per-target, per-challenge or overage price anywhere in this feature: going over a limit skips the AI step and charges nothing.
The Plan Ladder And Its Capability Flags
Entitlement is cumulative: each tier carries everything below it.
| Plan id | Name | Price | Rank | checks_per_month |
ai_per_month |
Capabilities it adds |
|---|---|---|---|---|---|---|
bot_protection_free |
Free | $0 | 0 | 50,000 | 1,000 | forms, hosted_targets |
bot_protection_starter |
Starter | $9 / mo | 1 | 250,000 | 5,000 | adds brand |
bot_protection_pro |
Pro | $29 / mo | 2 | 1,000,000 | 20,000 | adds external_targets, api |
bot_protection_business |
Business | $99 / mo | 3 | 5,000,000 | 100,000 | adds custom_rules |
The two limits ride each plan as limits: { checks_per_month, ai_per_month }. Above Business, talk to us.
bot_protection_external, bot_protection_api and bot_protection_custom stay in the catalog at their prices for anyone already on them, and are left out of the ladder. They carry the limits of Starter, Pro and Business in that order, and api and custom carry brand.
Two honest caveats for anyone planning an integration:
- The
external_targetscapability is fully implemented as a gate, but the attachable-target list returns Xuda-hosted targets only, so there is no path in the product that consumes it today. - The
apicapability is reported in thecanmap but is never checked, and every Bot Protection method is flagged private, so an account API key cannot call any of them.captcha_siteverifyis the key-free surface, and it is available on the Free tier.
Errors
Method-level error codes, returned on the CPI envelope:
| Code | Meaning |
|---|---|
-401 |
No session on a method that requires one. |
-402 |
Entitlement refusal, or the payment side refused a plan change. |
-403 |
Ownership refusal. not_profile_owner on the settings methods, not_owner on arm and detach. |
-404 |
The target is not on this account, or the account document is missing. |
The -402 contract. A refusal returns code: -402, a data.message written as a readable sentence, for example "This needs the Business plan ($99/mo)." or "Activate the Free plan to use this. It costs nothing.", plus a top-level plan_required object of {capability, current_plan, required_plan, required_plan_name, price}. The structured part rides its own top-level key because the HTTP layer flattens an object data on a negative code down to data.message.
None of the eleven methods carries a min_plan key, so the platform's membership plan gate never fires for this feature. All entitlement is decided inside the module and surfaced as -402.
captcha_verify fail reasons, returned as status: fail, reason: <value> rather than as an error code: bad_request, not_enabled, rate_limited, session_bad_token, session_bad_sig, session_expired, session_too_fast, pow, challenge_expired, automation, ai_bot, ai_uncertain, exhausted. A tripped honeypot also answers status: fail, but with the deliberately uninformative reason ok.
captcha_siteverify error codes, returned in the "error-codes" array: missing-input, invalid-input-secret, invalid-input-response, timeout-or-duplicate, internal-error.
Rate Limits
| Scope | Limit |
|---|---|
| Verification attempts per visitor IP and site key pair | 60 per 60 seconds |
| Verification attempts per site key | 600 per 60 seconds |
Both are in-process sliding windows and they apply to the visitor-facing verification path. Exceeding either answers reason: rate_limited.
Idempotency And Token Lifetimes
- Response tokens are single use. A response token is burned on first verification, so a replay of the same token answers
timeout-or-duplicate. - Tokens are self-contained and signed rather than backed by a server-side session, and signatures are compared in constant time.
- Attach is idempotent per target. A repeated
bot_protection_attachon the same target maps to the same profile. - Detach is safe to repeat. Detaching a profile that no longer exists answers
{ok: true}.
| Lifetime | Default |
|---|---|
| Widget session token | 900000 ms (15 minutes) |
| Response token | 120000 ms (2 minutes) |
| Origin clearance cookie | 1800000 ms (30 minutes), settable 60000..86400000 |
| Image challenge | 120000 ms (2 minutes) |
| AI challenge | 180000 ms (3 minutes) |
| Minimum age of a level 0 pass | 800 ms |
Other Limits And Defaults
| Setting | Default |
|---|---|
pow_difficulty |
16 leading zero bits, plus 1 on medium aggressiveness and plus 2 on high, floor 8, owner-settable range 8..24 |
image_grid |
9 tiles |
image_correct_min |
2 correct tiles minimum |
aggressiveness |
medium (low, medium or high) |
l1_score_low / l2_score_low |
0.35 / 0.7. The AI verdict must score at least 0.7 to pass at level 2 |
| Level 0 pass threshold | 0.6 plus 0.1 per aggressiveness step: 0.6 low, 0.7 medium, 0.8 high |
| Custom rules caps | 100 path rules, 20 fingerprint rules, 200 entries per list, 80 characters per entry, rate window 1..3600 s, rate max 1..100000 |
| Armed-target cache refresh | every 30 seconds, first run 4 seconds after router start |
| Profiles listed per account | 500 |
| Armed targets cached fleet-wide | 2000 |
Passive signals scored before any challenge is shown include pointer, key and scroll event counts, touch, WebGL and canvas presence, hardware concurrency, languages, timezone, the webdriver and headless markers and dwell time. They produce a 0..1 human likelihood with named reasons such as no_interaction, webdriver, headless and instant_click.
Webhooks
Bot Protection publishes no webhooks of its own. The Stripe webhooks that maintain the consolidated subscription belong to the billing module, not to this feature. There are also no crons and no queue workers here. The only recurring work is the router refreshing its armed-target list every 30 seconds, in process.
A Note On The Rest Of The Surface
Beyond the eleven methods above, the module exports a set of broker-only functions used by the Xuda router, the AI module's embedded contact form and the app module's under-attack toggle. No HTTP route reaches them, they are not part of any documented or supported surface, and they are not listed here.