Atlys
Bahasa Indonesia

Embed guide

How to put Atlys Captcha on your site and verify the result on your server.

Status: final Fase 3, 20 November 2026. This document finalises the P12 draft (19 November 2026). Every code snippet below has been matched against the real loader in atlys-captcha (src/loader/loader.ts, build output public/widget/v1/widget.js) and against the route patterns in wrangler.toml. All URLs use the production origin https://captcha.atlys.ai.id.

Scope: v1 owner-only. Site keys are issued manually by the owner. There is no self-service registration (PROTOCOL Ch. 5 §5.7.1). Magic links are excluded from this phase and the Layer 5 endpoints (pass tokens) are still inactive. Error codes relating to both are still listed and marked.

What changed from the P12 draft

This final version fixes four things from the P12 draft:

  1. The loader URL is /widget/v3/widget.js, not /widget/v1.2.0/widget.js. The route patterns in wrangler.toml only cover /widget/v3/widget.js, and the versioned asset directories use the major number only (v3/, then v4/ for the next release). The v1.2.0 example in spec §6.1 only illustrates the URL pattern.
  2. The per-site-key limit for challenges is 200/hour, not 400/hour. Spec §5.6.1b lowered that figure (F2-22/D8), and the rate limiter code (src/lib/rate-limit.ts) uses 200/hour.
  3. The data-action attribute was added. The real loader already supports it (P6C): the action is passed to the iframe and used at verify.
  4. The loader mounts the iframe inside the container, rather than replacing the container. (container.appendChild(iframe) in loader.ts.)

1. How the flow works

  1. Your page loads the Atlys loader and shows the widget.
  2. The visitor completes a check. Usually that check is only a light background proof-of-work.
  3. The widget hands a single-use token to your page's JavaScript.
  4. Your server must verify that token with the Atlys server (POST /v1/verify) before processing the action. An unverified token means nothing (Ch. 5 §5.4.3).

The widget never decides pass or fail. Every decision is made by the server (Ch. 1 §1.1).

2. Step 1: load the loader

One script tag, with a versioned URL and Subresource Integrity (SRI) SHA-384. SRI is mandatory (Ch. 6 §6.1):

<script
  src="https://captcha.atlys.ai.id/widget/v3/widget.js"
  async defer
  integrity="sha384-hLETDynr4cZyBxMXg+mygJ9M7+74N7tLgq3/yrxpRf6a3JoDsAGx51lq39DUam4I"
  crossorigin="anonymous"></script>

Take the hash from the release notes for the version you embed. Never copy a hash from another version. Without SRI, a compromise of the script-serving path directly executes arbitrary code on every embedding site.

Releases N and N-1 are served together; N-1 is removed when N+1 ships. You get one full release cycle to migrate (Ch. 6 §6.1). Files under /widget/v3/ are served with Cache-Control: public, max-age=31536000, immutable, because their content never changes at the same URL (public/widget/v3/_headers).

The unversioned URL (/widget.js) redirects (302) to the latest release. That URL is only for embedders without SRI, because redirect and SRI are incompatible.

3. Step 2: place the widget container

<div class="atlys-captcha"
     data-sitekey="atlys_pk_<your-public-key>"
     data-session-binding="<128-bit-base64url-value-from-your-server>"
     data-action="login"
     data-theme="light"
     data-language="auto"></div>

The loader scans the page once the DOM is ready, finds the .atlys-captcha container, and mounts an iframe inside it. The iframe comes from captcha.atlys.ai.id and measures 300x65 px for the standard variant or 300x55 px for the compact variant (src/loader/types.ts, Ch. 6 §6.4.1). Reserve that height in your layout so the page does not shift when the widget appears.

Data attributes (Ch. 6 §6.2, verified in loader.ts)

AttributeValueNotes
data-sitekeyPublic key (atlys_pk_...)Required. Without a sitekey the widget does not render and render() returns an empty string
data-session-bindingEmbedder session binding value (random 128-bit, base64url)Required before the widget requests a challenge. Without it the widget still shows but does not request a challenge
data-actionProtected action (login, checkout, signup, ...)An invalid value falls back to login. Your server must verify with the same action
data-themelight / dark / autoWhen left out, the loader follows the visitor's system setting
data-variantstandard / compactDefault standard
data-languageLanguage code (id, en) / autoDefault auto (browser detection). The loader uses id or en; other languages fall back to en
data-callbackSuccess callback function nameReceives the token as its argument
data-expired-callbackExpiry callback function nameCalled with no arguments
data-error-callbackError callback function nameReceives the error code as its argument

Session binding value, read carefully (Ch. 5 §5.9 item 11)

  • Generate one random 128-bit value per visitor session, store it on your server, and render it into the page via data-session-binding.
  • On verify, send that value from your own server session store, not from the client.
  • A static value for all visitors, or a value forwarded from the client, voids session binding. A token stolen from another session becomes usable.

4. Step 3: get the token on the page

The widget delivers the token via the success callback or via the JavaScript API (Ch. 6 §6.2). Callback example:

<script>
  function onAtlysSuccess(token) {
    document.getElementById("atlys-token").value = token;
  }
  function onAtlysExpired() {
    document.getElementById("atlys-token").value = "";
  }
  function onAtlysError(code) {
    console.warn("Atlys error: " + code);
  }
</script>

<div class="atlys-captcha"
     data-sitekey="atlys_pk_<your-public-key>"
     data-session-binding="<value-from-your-server>"
     data-action="login"
     data-callback="onAtlysSuccess"
     data-expired-callback="onAtlysExpired"
     data-error-callback="onAtlysError"></div>
<input type="hidden" id="atlys-token" name="atlys-token">

Or read the token at any time through the API:

const token = atlys.getResponse(widgetId);

getResponse returns an empty string when no valid token exists yet.

JavaScript API (window.atlys, Ch. 6 §6.2, verified in loader.ts)

FunctionPurpose
atlys.render(container, params)Render the widget explicitly (dynamic pages). Returns the widget id (atlys-N) or an empty string on failure
atlys.reset(widgetId)Reset the widget to idle (after a token is used or expired)
atlys.getResponse(widgetId)Get the current token
atlys.setSessionBinding(widgetId, value)Set the session binding value programmatically. This reloads the iframe and clears the old token
atlys.remove(widgetId)Remove the widget from the page

render takes a container (element or CSS selector) and optional params: sitekey, sessionBinding, theme, variant, language, action, callback, expiredCallback, errorCallback. Params take priority over data attributes. Rendering twice into the same container returns the id that already exists.

const widgetId = atlys.render("#captcha-box", {
  sitekey: "atlys_pk_<your-public-key>",
  sessionBinding: "<value-from-your-server>",
  action: "checkout",
  theme: "dark",
  callback: (token) => { submitForm(token); },
  expiredCallback: () => { showNotice("Verification expired, please try again."); },
  errorCallback: (code) => { showNotice("Verification failed: " + code); },
});

A documented risk (Ch. 6 §6.2, RT-28): the token is fetched via getResponse() by any JavaScript on the page, including third-party scripts. This exposure cannot be eliminated while the token must reach the page's JavaScript. What limits it: session binding (a stolen token is useless from another session), the 2-minute validity, and a strict CSP (§8).

Token validity: 2 minutes (server clock; TOKEN_TTL_SECONDS = 120 in src/lib/tokens.ts). If a token expires before use, the widget calls data-expired-callback and returns to idle. Ask the visitor to complete the check again (Ch. 6 §6.3).

The widget has eight states (§6.3): idle, checking (minimum 1,500 ms), pow, challenge, alternative, success, fail, and locked (the session locks for 15 minutes after the attempt limit is hit).

5. Step 4: verify on the server (required)

POST /v1/verify, server-to-server only. Never call it from the browser (Ch. 5 §5.4.3).

Authentication: header Authorization: Bearer <atlys_sk_...> (secret key). Every request field is required; a missing field means failure:

{
  "token": "<opaque-token-from-widget>",
  "action": "login",
  "session_binding": "<value-from-your-server-session-store>",
  "origin": "https://your-site.example"
}

curl example:

curl -X POST https://captcha.atlys.ai.id/v1/verify \
  -H "Authorization: Bearer atlys_sk_<your-secret-key>" \
  -H "Content-Type: application/json" \
  -d '{"token": "<token>", "action": "login",
       "session_binding": "<value-from-server-session>",
       "origin": "https://your-site.example"}'

Node.js example:

const res = await fetch("https://captcha.atlys.ai.id/v1/verify", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.ATLYS_SECRET_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    token: req.body["atlys-token"],
    action: "login",
    session_binding: req.session.atlysBinding,
    origin: "https://your-site.example",
  }),
  signal: AbortSignal.timeout(10000),
});

if (res.status !== 200) {
  // Failed: reject the action. Do not process the form.
  return res.status(403).json({ error: "Verification failed." });
}
const { data } = await res.json();
// data.valid === true, data.via === "standard", data.action === "login"

A 200 response means pass: all checks succeeded and the token nonce is atomically marked used. The response carries a via field (completion path: standard / magic-link / pass-token) and the action bound to the token. A 422 response means fail. The specific reason is not disclosed in the public response (server logs only). All three token codes are masked into one: TOKEN_VERIFICATION_FAILED (Ch. 5 §5.2).

Embedder contract, 5 conditions (Ch. 5 §5.4.3)

Violating any one of them voids the security guarantee:

  1. Verify is called from the server, not from the browser.
  2. The secret key never appears in client code, HTML, or a public repository.
  3. Verify results are checked explicitly (200 means pass; any other status means fail). No "no error means pass" reading.
  4. Verify is called through one central gate for all paths to the protected action.
  5. Verify is retried only inside the 30-second grace window and only for timeouts/5xx, not for 422.

30-second grace window (Ch. 5 §5.4.3)

A successful verify result is kept for 30 seconds (keyed by nonce + site key + action). A re-verify inside that window with the same nonce/site key/action returns the same success result (not TOKEN_REUSED). Outside the window, TOKEN_REUSED applies in the server logs. A legitimate double-submit (user pressing the button twice) is handled by the same window. Retry only for timeouts/5xx. A 422 means the token is genuinely invalid, so do not retry.

6. Response format (JSON envelope, Ch. 5 §5.2)

Success:

{ "success": true, "data": { "...": "..." }, "meta": { "timestamp": "2026-11-18T08:00:00Z" } }

Error:

{
  "success": false,
  "error": { "code": "VALIDATION_ERROR", "message": "A clear, actionable explanation", "details": null },
  "meta": { "timestamp": "2026-11-18T08:00:00Z" }
}

meta.timestamp is the server timestamp (ISO 8601, UTC). Do not use the client clock for expiry decisions. Error messages never leak internal details (stack traces, table names, key values, specific security reasons). Verification failure uses 422, not 200, because a 200 with success: false is easily misread as "pass" (Ch. 5 §5.3).

7. Error codes, complete (Ch. 5 §5.5)

Spec §5.5 contains 22 codes. That count comes from counting the table rows directly, and the §5.5 text confirms it ("This table contains 22 error codes"). All 22 are copied below without change of meaning.

CodeMeaningHTTPv1 note
VALIDATION_ERRORInvalid payload (format, missing field, out-of-range value)400
AUTHENTICATION_ERRORKey missing or invalid401
AUTHORIZATION_ERRORValid key but not entitled to this action/origin403
NOT_FOUNDChallenge/endpoint not found404
CHALLENGE_EXPIREDChallenge already expired (server clock)422
CHALLENGE_FAILEDWrong completion proof422
CHALLENGE_ALREADY_SOLVEDChallenge already used to issue a token422
TOKEN_VERIFICATION_FAILEDToken invalid / expired / already used. One public code for all three (masking decided; distinguished only in server logs)422
MAGIC_LINK_INVALIDMagic link invalid / expired / already used422Not applicable in v1, magic links excluded
MAGIC_LINK_RATE_LIMITEDMagic link send limit exceeded (per address / per session / global)429Not applicable in v1
PROOF_INVALIDPoW proof for POST /v1/proofs/verify invalid422Endpoint not yet launched (404 until magic links launch)
RECEIPT_INVALIDProof receipt invalid / expired / already consumed422Endpoint not yet launched
EXTENSION_LIMIT_REACHEDChallenge already extended 2x (maximum, Ch. 4 §4.8.2)422
PASS_TOKEN_NOT_ELIGIBLEStandard token not from a full interactive challenge (challenge_type is not interactive), cannot issue pass tokens422Not applicable in v1, Layer 5 flag OFF
PASS_TOKEN_ALREADY_ISSUEDStandard token already issued pass tokens422Not applicable in v1
MAGIC_LINK_TOKEN_ALREADY_ISSUEDToken already issued for this magic link record422Not applicable in v1
PROOF_RECEIPT_ALREADY_ISSUEDProof receipt already issued for this challenge422Endpoint not yet launched
AGENT_NOT_REGISTEREDAgent key unknown / revoked401AI agent path
AGENT_RATE_LIMITEDAgent daily quota exceeded429AI agent path
ATTEMPT_LIMIT_EXCEEDEDAttempt limit exceeded (3/challenge, 5/session)429
RATE_LIMITEDRate limit exceeded429
VERIFICATION_UNAVAILABLEVerification component unreachable (fail-closed)503

The codes TOKEN_INVALID, TOKEN_EXPIRED, and TOKEN_REUSED exist only in server logs for audit. Public responses always use TOKEN_VERIFICATION_FAILED (Ch. 5 §5.2, §5.5).

Recommended error handling

SituationEmbedder action
422 TOKEN_VERIFICATION_FAILEDReject the action. Ask the visitor to complete the check again (atlys.reset()). Do not retry verify
429 (RATE_LIMITED, ATTEMPT_LIMIT_EXCEEDED)Back off with delay (honour Retry-After); no aggressive retries. Attempt limits: 3/challenge, 5/session; session locked 15 minutes after the limit is hit
503 VERIFICATION_UNAVAILABLEFail-closed: reject the action for now; back off and retry later. Never pass an action without verification
Timeout / 5xx on verifyRetry only inside the 30-second grace window (§5)
401 / 403Check the secret key and registered origins; the key may be wrong, revoked, or used from an unregistered origin

8. Page security recommendations

  1. Strict CSP (recommended, Ch. 5 §5.9 item 13): script-src 'self' https://captcha.atlys.ai.id + nonce/hash for your own inline scripts. A compromised third-party script can steal tokens from your page.
  2. Referrer-Policy (recommended, Ch. 5 §5.9 item 12): allow at least origin-level Referer to captcha.atlys.ai.id (strict-origin-when-cross-origin or looser) so browser-context verification can run. Total no-referrer does not break the widget, it only raises the minimum friction (level 2, origin-unverified session).
  3. CORS: the Atlys server only reflects origins registered for your site key. Access-Control-Allow-Origin: * is forbidden (Ch. 5 §5.8).
  4. SRI on the loader: mandatory (§2).
  5. One central gate: every path to the protected action (form, API, AJAX, mobile) must pass through the same verify gate, including logged-in users (Ch. 5 §5.9 items 2, 6).
  6. The widget uses IntersectionObserver and refuses to complete verification when the card is less than 50% visible, opacity is below 0.5, or another element covers it at the moment of click or completion (Ch. 6 §6.1). Do not hide the widget behind an overlay.

9. Rate limits (summary, Ch. 5 §5.6.1b, DEFAULT)

EndpointPer sessionPer site keyPer IP
POST /v1/challenges, /solve, /extend, /proofs/verify30/hour200/hour300/hour
POST /v1/verifyn/a2,000/hour1,000/hour (embedder server)
GET /v1/healthn/an/a60/hour
All endpoints (global emergency)n/an/an/a (global cap 80,000/day)

The per-session limit (30/hour) is far above human behaviour (under 10 challenges/hour). Repeated violations increase the wait time exponentially (Ch. 5 §5.6.3). A 429 response carries a Retry-After header. The required backoff: wait 2 seconds, then 4 seconds, then 8 seconds, plus a random delay.

10. Accessibility for your users

  • The widget meets WCAG 2.2 AA: full keyboard, screen reader, 200% zoom, no strict countdown (Ch. 10 §10.6; Ch. 6 §6.8).
  • A non-cognitive alternative path must be available for users who cannot complete a challenge. In v1 that path is heavier PoW (magic links follow post-launch) (Ch. 5 §5.9 item 10; Ch. 10 §10.6.1 criterion 3.3.8). Audio transcription does not count as an alternative.
  • Users without JavaScript currently cannot use the widget. The no-JS path is an open item (W4; Ch. 6 §6.1) and must not be claimed to exist.

11. Go-live checklist (13 items, Ch. 5 §5.9)

  1. Secret key on the server only; never in client code, HTML, or a repo.
  2. Verify called from the server through one central gate for all paths.
  3. Verify results checked explicitly (200 means pass; anything else means fail).
  4. Verify retried only inside the 30-second grace window and only for timeouts/5xx; never for 422.
  5. A missing/malformed/expired/reused token means fail, without exception.
  6. Logged-in users still pass through the same gate.
  7. CORS and registered origins correct; no *.
  8. 429 rate limits handled with backoff.
  9. Verification logs monitored. A "passed without verification" pattern must be detectable.
  10. Non-cognitive alternative path (heavier PoW in v1) available.
  11. Session binding value: random 128-bit per session, from the server store, not from the client.
  12. Referrer-Policy allows at least origin-level Referer to captcha.atlys.ai.id.
  13. Strict CSP limiting third-party scripts (recommendation).

12. Limits you need to know

Atlys Captcha is not an absolute anti-bot guarantee (Ch. 1 §1.4): human farms, C++-level stealth browsers, PoW relay, and interactive relay cannot be fully stopped by any captcha. The service raises attacker cost above the value of the protected action. Classify your action values (low/medium/high/very high) at site key issuance. An unclassified action means MEDIUM (Ch. 5 §5.7.1 item 6).