Verena Presence
Prove a real person is there, without a CAPTCHA
Presence is a widget for your page and one API call for your server. The visitor taps once on their phone, with Face ID or a fingerprint. Your server gets a yes or no, and learns nothing else about them.
init, mount, callbacks and errors.
Server APIPOST /v1/verify and what it returns.
Using a coding agent? Give it this prompt. More
Tick the box. The proof your onVerified callback receives shows up here.
Quickstart
Three pieces: a key pair from the dashboard, the widget on your page, and a check on your server before you act on the request.
-
Create a key pair
Sign in and create a key in the dashboard. You get a site key (
site_…) for the page and a secret key (sk_…) for your server. The secret key is shown once, so store it right away. -
Add the widget
Load the script, give it a container, and call
initandmount. When the visitor has verified,onVerifiedreceives a proof token. -
Check the token on your server
Send the token along with the request you want to protect. Your server posts it to
/v1/verifywith the secret key and proceeds only ifvalidistrue.
/v1/verify counts.<div id="verena"></div>
<script src="https://widget.verena.se/js/verena.min.js"></script>
<script>
Verena.init({
siteKey: "site_your_key",
onVerified: (proof) => {
// Send proof.token with the request you want to protect
form.elements.verenaToken.value = proof.token;
},
});
Verena.mount("#verena");
</script>
app.post("/signup", async (req, res) => {
let valid = false;
try {
const check = await fetch("https://verena.se/v1/verify", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.VERENA_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ token: req.body.verenaToken }),
signal: AbortSignal.timeout(10_000),
});
valid = check.ok && (await check.json()).valid === true;
} catch {
// Network error or timeout: fail closed
}
if (!valid) return res.status(403).send("Verify you're human first.");
// A real person is here: go ahead
});
@app.post("/signup")
def signup():
try:
check = requests.post(
"https://verena.se/v1/verify",
headers={"Authorization": f"Bearer {VERENA_SECRET_KEY}"},
json={"token": request.form.get("verenaToken", "")},
timeout=10,
)
valid = (check.status_code == 200
and check.json().get("valid") is True)
except (requests.RequestException, ValueError):
valid = False # error or timeout: fail closed
if not valid:
return "Verify you're human first.", 403
# A real person is here: go ahead
curl https://verena.se/v1/verify \
-H "Authorization: Bearer sk_your_secret_key" \
-H "Content-Type: application/json" \
-d '{ "token": "3f9a2c…" }'
How a check works
The widget runs in a frame on Verena's domain, so your page never handles keys, biometrics or proofs. Your page only passes an opaque token to your server, and your server asks Verena whether it is good.
In step 2, the visitor confirms with their device, and Verena checks that interaction with local device attestation: the device's own secure hardware vouches that a real person used it, in a way a script can't fake. How that runs differs per platform and device, and can change over time; nothing in your integration depends on it.
What you can rely on is the outside: onVerified gives you a token, and /v1/verify answers the same whichever way the visitor verified.
Build with AI
Using a coding agent like Claude Code, Cursor or Codex? Give it these docs and the rules on the right, and it can add Verena to your app with the details right: the secret key stays on the server, the token is checked before anything happens, and the iPhone return is handled.
Rules for adding Verena, written for an agent. Paste them into your prompt, or into a file your agent reads, like AGENTS.md or CLAUDE.md.
This whole reference as one Markdown file, with the instructions included.
Example prompt
## Instructions for AI agents integrating Verena Presence
Verena Presence proves that a real person is present on a real device, as a replacement for a CAPTCHA. It has two parts: a widget on the page, and one API call on the server. Follow these rules when you add it to an application.
### Integration
1. Load the widget with a script tag: `<script src="https://widget.verena.se/js/verena.min.js"></script>`. Do not install `@verena/js` from npm: it is not published.
2. Call `Verena.init({ siteKey, onVerified, onError })` once, then `Verena.mount(container)`. The whole client API is `init`, `mount`, `status` and `reset`. There is no `Verena.verify()`, no modal, and no `onDismiss` or `externalStyles` option. Do not invent other functions or options.
3. The site key (`site_…`) goes in frontend code. The secret key (`sk_…`) goes only in a server-side environment variable, such as `VERENA_SECRET_KEY`: never in client code, logs or version control. If the user has no keys yet, tell them to create a key pair at https://verena.se/account/keys.
4. Pass `proof.token` from `onVerified` to the backend with the request it protects, as a form field or a header.
5. On the server, before acting on the request, `POST https://verena.se/v1/verify` with the header `Authorization: Bearer <secret key>` and the JSON body `{ "token": "<token>" }`. Proceed only if the status is 200 and the response has `"valid": true`. Set a timeout on the call (about 10 seconds), and treat a network error, a timeout or a non-200 status as not verified: fail closed.
6. Never trust `onVerified`, `Verena.status()` or `sessionStorage` on the server. Only the answer from `/v1/verify` counts.
7. A plain token can be verified any number of times within its hour. If the action must happen once per check (a sign-up, a vote, a purchase), store the token, or its SHA-256 hash, after the first use and refuse it the second time.
8. Keep the protected submit button disabled until `onVerified` fires. To ask again, empty the container and call `Verena.mount` again.
9. Give the widget's container `min-height: 88px`, so the page doesn't shift while it loads. The widget is at most 380 px wide.
### Redirects
- In some cases the check sends the visitor away from the page and brings them back through a redirect to `returnUrl` (by default the current page), which can open in a **new tab**. The application must handle this.
- Mount the widget on the `returnUrl` page on load: it picks up the proof there and calls `onVerified(proof, { returned: true })`. Don't rely on the original tab receiving the proof.
- If the page has a form or other state, save it to `localStorage` on input and restore it in `onVerified` when `returned` is `true`, because the new tab starts empty. The saved state can be missing, since the visitor may return in a different browser: then keep the proof and ask the visitor to fill in the form again. Don't save passwords or other secrets.
- In a single-page app, make sure the router keeps the `verena_session` query parameter until the widget has read it.
- `returnUrl` must be on the page's own origin; other values are ignored.
- Leave `appClipRedirect` at its default; do not set it.
### Configuration
- If the site has a Content Security Policy, add `https://widget.verena.se` to `script-src` and `frame-src`. Nothing else is needed: the widget talks to Verena through a privacy relay from inside its own frame.
- Tell the user to set the key's allowed origins in the dashboard to the production origins, written as scheme and host, like `https://example.com`. Handle `onError` with `err.code === "origin_not_allowed"` by logging a clear message for the developer.
- Use events only if the user wants one entry per device, such as a queue or a vote. Any site key works: the user creates the event in the dashboard (it works at once), and the app passes the event's slug as `event` to both `Verena.init` and `/v1/verify` (without it, `/v1/verify` would also accept a plain token from a page that left `event` out), and uses the `entry` id from the response to recognise a device that comes back. Event tokens work once, and `/v1/verify` spends them before the app saves anything, so decide by the app's own records keyed by `entry`, not by `repeat`: if the save fails, a later check reports `repeat: true` with nothing stored. On a failed save, have the page empty the widget's container and mount it again for a new token.
### Do not
- Do not self-host, proxy or bundle the widget script, wrap the widget in your own iframe, or call the `/widget/*` endpoints directly.
- Do not use the old hosts `api.verena.dev` or `cdn.verena.dev`.
- Do not try to decode the token. It is a random string with no claims.
- Do not add a fallback that skips verification when Verena can't be reached, unless the user asks for one.
- Do not collect personal data to go with the check. Verena is designed so that the site learns nothing about the visitor.
Full reference: https://presence.verena.se/docs.md
Install
Load the script from Verena. It defines a global Verena with four functions: init, mount, status and reset.
The widget is a 380 × 88 frame that fills its container's width up to 380 px. It works on any page served over HTTPS, and on localhost.
@verena/js is not on npm yet. Until it is, load the script tag; it is versioned and cached by the CDN.<script src="https://widget.verena.se/js/verena.min.js"></script>
Verena.init(config)
Configures the widget. Call it once, before mount. It throws if siteKey is missing.
Parameters
Your public site key, site_…. Safe to put in page source.
Called when the visitor has verified.
The proof token. Send it to your server.
Unix time in seconds when the token expires, one hour after it was issued.
Only at an event: this device had entered before and gets its same entry back.
true when the visitor came back through a redirect, on a new tab. Anything they had in the original tab, like a half-filled form, isn't here. See Handling redirect URLs.
Called with an Error when the widget can't start or the check fails. Many carry a code: see Errors.
"auto" follows the visitor's system setting.
The slug of one of your events, made on this site key. With it, the check is an entry to that event; without it, plain verification. Any site key does both.
Where the visitor returns after verifying, when the check sends them away from your page, as on iPhone or in an in-app browser. Must be on your page's origin; any other value is ignored. See Handling redirect URLs.
Set to false to keep iPhones in Safari instead of the Verena App Clip. A new iPhone can't verify there, so use it for testing only. Ignored at events.
Verena.init({
siteKey: "site_your_key",
theme: "auto",
onVerified(proof, { returned }) {
tokenInput.value = proof.token;
submitButton.disabled = false;
if (returned) restoreDraft();
},
onError(err) {
errorText.textContent = err.message;
},
});
{
"token": "3f9a2c7d1e…",
"expiresAt": 1764460800
}
Verena.mount(container)
Renders the widget into container, a CSS selector or an element. The widget runs the whole check: the checkbox, the tap, the phone hand-off and the result.
It throws if init hasn't been called or the container doesn't exist. To start over, for example after the token was used, empty the container and mount again.
Parameters
Where to put the widget. Give it a min-height of 88 px to avoid a layout shift while it loads.
Verena.mount("#verena");
// Later, to ask again
const box = document.querySelector("#verena");
box.innerHTML = "";
Verena.mount(box);
Verena.status()
Whether this tab holds an unexpired proof. The widget keeps the last proof in sessionStorage, so it lasts across page loads in the tab and is gone when the tab closes.
Use it to skip the widget for a visitor who just verified. It says nothing your server can rely on: check the token there as usual.
Returns
true if an unexpired proof is stored.
Unix time in seconds. Only when verified is true.
const { verified } = Verena.status();
if (!verified) Verena.mount("#verena");
Verena.reset()
Forgets the stored proof, so status() reports verified: false. Call it on sign-out, or whenever you want the visitor to verify again. Tokens already issued stay valid on the server until they expire.
signOutButton.addEventListener("click", () => {
Verena.reset();
location.href = "/";
});
Errors
onError receives an Error whose message is readable as is. When the cause is in your setup, it also has a code. Setup errors are logged to the console too, prefixed with [verena].
| code | Meaning | Fix |
|---|---|---|
| invalid_key | The site key doesn't exist. | Check siteKey; it may have been deleted. |
| origin_not_allowed | The page's origin isn't in the key's allowed origins. | Add it in the dashboard. |
| unknown_event | No event with that slug on this key. | Check the slug, and that the event is on the key in siteKey, in Events. |
| bad_event | event isn't a string. | Pass the slug as a string, or leave event out. |
Errors without a code come from the check itself, such as a cancelled fingerprint prompt. The widget shows them and lets the visitor try again, so you usually don't need to do anything.
Content Security Policy
If your site sends a Content Security Policy, allow the script and the frame from widget.verena.se.
That is all. The widget talks to Verena from inside its frame, through an independent privacy relay, so your page makes no requests to Verena and needs no connect-src entry.
Content-Security-Policy:
script-src 'self' https://widget.verena.se;
frame-src https://widget.verena.se
Authentication
The server API takes your secret key as a bearer token. Keep it on your server, out of page source and out of version control.
Each secret key belongs to one site key. A token issued for one key pair can only be verified with that pair's secret key.
Base URL
https://verena.se
Authorization: Bearer sk_your_secret_key
{
"valid": false,
"error": "Invalid secret key."
}
Verify a token
POST/v1/verify
Checks a proof token. Call it before you act on the request it came with. A token that isn't valid always returns 200 with valid: false and an error; 401 and 400 mean the call itself was wrong.
Body parameters
The token from onVerified.
For event tokens: the slug you expect. Always pass it when you expect an entry: a site key gives plain tokens too, and with event those are refused (not_event_token). A token for another event of the same key is refused, and stays unused.
Response
Whether to let the request through.
"device-entry" for event tokens, "personhood" for all others.
Why the token isn't valid, in words.
The same, for code: token_invalid (unknown, expired, or an event token already spent), wrong_key (issued for another site key), not_event_token (you passed event; the page didn't), other_event, or token_used. Your event's page in the dashboard counts each of these.
Event tokens: the event's slug.
Event tokens: an id for this device's entry, the same every time it enters this event. Use it to give a returning visitor back their place.
Event tokens: the device had entered before.
const res = await fetch("https://verena.se/v1/verify", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.VERENA_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ token }),
signal: AbortSignal.timeout(10_000),
});
// Not 200, a network error or a timeout: not verified
const result = res.ok ? await res.json() : { valid: false };
res = requests.post(
"https://verena.se/v1/verify",
headers={"Authorization": f"Bearer {VERENA_SECRET_KEY}"},
json={"token": token},
timeout=10,
)
# Not 200, a network error or a timeout: not verified
ok = res.status_code == 200
result = res.json() if ok else {"valid": False}
curl https://verena.se/v1/verify \
-H "Authorization: Bearer sk_your_secret_key" \
-H "Content-Type: application/json" \
-d '{ "token": "3f9a2c…" }'
{
"valid": true,
"scope": "personhood"
}
{
"valid": true,
"scope": "device-entry",
"event": "spring-sale",
"entry": "9b2e41c07d5fa3e8c16b0f42d97a5e13",
"repeat": false
}
{
"valid": false,
"code": "token_invalid",
"error": "Token is invalid or expired."
}
Proof tokens
A token is a random 64-character hex string. It carries no claims and can't be decoded: /v1/verify is the only way to check one. Verena stores only its hash.
| Property | Behaviour |
|---|---|
| Lifetime | One hour from issue (expiresAt). |
| Scope | Valid only with the secret key of the site key it was issued for. |
| Reuse | A plain token can be verified any number of times until it expires. If an action should happen once per check, mark the token as used on your side. |
| Single use | Event tokens are spent by the first successful /v1/verify. Verifying again returns valid: false. |
| Revocation | None. Tokens are short-lived; let them expire. |
/v1/verify answers the same. You can't tell flows apart, and don't need to.Guide
Allowed origins
A site key is public: anyone can copy it from your page. Allowed origins make sure it only works on your sites. Set them per key in the dashboard, as a comma-separated list.
| Entry | Allows | Doesn't allow |
|---|---|---|
| https://example.com | https://example.com, and the same host on another port | https://www.example.com, http://example.com |
| http://localhost:3000 | Your dev server on that port | Other ports |
| empty | Any origin |
- Write scheme and host, plus a port if it isn't the default. No path, no trailing slash.
- Subdomains are separate origins: list
https://www.example.comtoo if you use it. - Anywhere else, the widget doesn't start and
onErrorgetsorigin_not_allowed, with the origin it saw. The message is logged to the console too. - Leaving the list empty is handy while you build. Set it before you go live.
Keep separate keys for production and for development or staging, so their origins and traffic stay apart. Every key does plain verification and any of its events. The first key's origin defaults to the website you gave at sign-up; change it any time with Edit on the key.
https://example.com, https://www.example.com
Guide
Handling redirect URLs
Most checks finish inside the widget, on your page. In some cases, depending on the device and on how the visitor moves through the check, Verena sends them back to your site through a redirect instead, and that can land in a new tab. Your site must handle it.
The two common cases:
- iOS. The check runs in the Verena App Clip, and when it's done, iOS opens your page again in a new Safari tab rather than returning to the one the visitor left.
- In-app browsers, the browser views inside apps like Instagram, TikTok or Gmail. The check can't finish there, so it continues in the device's regular browser, and the visitor comes back to your page in a new tab there, not in the app they started in.
The visitor leaves your page
For example, the App Clip opens over Safari, or an in-app browser hands over to the regular browser.
They verify
Verena issues the token for the session.
Back to
returnUrlThe visitor lands on
returnUrl(by default the page they came from), possibly in a new tab, with averena_sessionquery parameter.The widget picks it up
It removes the parameter from the address bar, scrolls back to where the visitor was, shows as verified and calls
onVerified(proof, { returned: true }).
What your site must do:
- Mount the widget on the
returnUrlpage, on load. Without it, the proof isn't picked up and the visitor would have to verify again. - Restore state when
returnedistrue. The new tab starts fresh, so anything the visitor typed or chose before verifying is gone unless you saved it, for example tolocalStorage. - Handle a missing draft.
localStorageis shared only within one browser. When an in-app browser hands over to the regular browser, the visitor returns in a different browser and the draft isn't there. The proof still counts: tell the visitor and let them fill in the form again. - Single-page apps: point
returnUrlat a route that mounts the widget, and don't let your router drop theverena_sessionparameter before the widget reads it. - Don't rely on the original tab. It may still be open, but it won't receive the proof.
returnUrl must be on your page's origin. Other values are ignored, so a session can't be turned into an open redirect.
const KEY = "signup-draft";
form.addEventListener("input", () => {
const draft = Object.fromEntries(new FormData(form));
delete draft.password; // never store secrets
try {
localStorage.setItem(KEY, JSON.stringify(draft));
} catch {} // private mode or full: the fallback below covers it
});
form.addEventListener("submit", () => {
localStorage.removeItem(KEY);
});
Verena.init({
siteKey: "site_your_key",
returnUrl: "/signup",
onVerified(proof, { returned }) {
form.elements.verenaToken.value = proof.token;
if (!returned) return;
let draft = null;
try {
draft = JSON.parse(localStorage.getItem(KEY));
} catch {} // storage blocked, or not valid JSON
if (draft) {
for (const [k, v] of Object.entries(draft)) {
if (form.elements[k]) form.elements[k].value = v;
}
} else {
// Back in another browser, without the draft.
// The proof still counts: ask for the form again.
notice.textContent =
"You're verified. Please fill in the form again.";
}
},
});
Verena.mount("#verena");
Guide
Events
An event lets each device in once: a ticket queue, a drop, a vote, a sign-up. A device that comes back gets its same entry, so a visitor who reloads keeps their place instead of being turned away.
Create the event
Under Events, give it a name; the dashboard suggests a slug from it. Put it on any of your keys, which keep working for plain verification, or let the dashboard make a new one. Optionally an opening time, from which the dashboard charts entries, and an image (PNG, JPEG or WebP, up to 512 KB) that the App Clip shows as the visitor enters.
Pass the slug
Give
eventtoVerena.initand to/v1/verify. Store theentryfrom the response, and look it up in your own records to give a returning device its place back.
- Entering needs a phone: the Verena app on iPhone, or Chrome on Android. A computer shows a QR code.
- Event tokens work once. A token for another event of the same key is refused and stays unused.
- A failed save.
/v1/verifyspends the token before your app saves anything. If the save then fails, the visitor needs a new token, and that check reportsrepeat: truethough you never recorded the sign-up. So look theentryup in your own records: none there means accept the retry, one there means they already signed up. Put a unique index onentry, so two retries at once save one row. - Timeouts and errors. A timeout, a network error or a non-200 from
/v1/verifyis never a pass. Answer503and let the page ask for a new check. - The dashboard counts devices entered: one per device, at its first entry; a device that returns isn't counted again. Next to it, the last server verification: when
/v1/verifylast answeredvalid: truefor the event. Verena can't see your database, so count the sign-ups you saved and compare. - When nothing comes in, the event's page shows each stage as Verena saw it, as counts only: checks your page started, refusals (
origin_not_allowed,unknown_event), QR handoffs no phone finished, phones turned away, and/v1/verifyanswers bycode. - Clear entries lets every device enter again: a device keeps its
entryid but comes back withrepeat: false, and tokens not verified yet stop working. Remove deletes the event; a new one with the same slug gives devices newentryids. Neither touches what your app saved. A key can't be deleted while it has events.
Entries counted in zero knowledge, up to a number of uses per device that you choose.
Verena.init({
siteKey: "site_your_key",
event: "spring-sale",
async onVerified(proof) {
const res = await fetch("/signup", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
token: proof.token,
...Object.fromEntries(new FormData(form)),
}),
signal: AbortSignal.timeout(15_000),
}).catch(() => null); // network error or timeout
if (res?.ok) return showDone(await res.json());
// Not saved. The token may be spent, so get a new one.
// The server accepts the retry: it has no record of
// this entry yet, whatever `repeat` says.
notice.textContent = "That didn't go through. Verify again.";
const box = document.querySelector("#verena");
box.innerHTML = "";
Verena.mount(box);
},
});
Verena.mount("#verena");
// The /v1/verify call, failing closed. `unavailable`:
// Verena couldn't answer, so ask for a new check later.
async function verify(body) {
try {
const res = await fetch("https://verena.se/v1/verify", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.VERENA_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
signal: AbortSignal.timeout(10_000),
});
if (!res.ok) return { valid: false, unavailable: res.status >= 500 };
return await res.json();
} catch {
return { valid: false, unavailable: true }; // network error, timeout
}
}
app.post("/signup", async (req, res) => {
const result = await verify({ token: req.body.token, event: "spring-sale" });
if (result.unavailable) return res.status(503).end();
if (!result.valid) return res.status(403).end();
// The token is now spent. Decide by your own record of
// this entry, never by `repeat`: if an earlier save failed,
// this retry says repeat: true and you have nothing stored.
// signups.entry has a unique index.
const saved = await signups.findByEntry(result.entry);
if (saved) return res.json({ id: saved.id, already: true });
try {
const { id } = await signups.insert({ entry: result.entry, email: req.body.email });
res.json({ id });
} catch (e) {
if (isUniqueViolation(e)) return res.json({ already: true }); // a parallel retry won
console.error("signup not saved", e);
res.status(503).end(); // the page asks for a new check, and we accept it
}
});
Guide
Privacy relay
We use a private relay to mask visitor's IP addresses from our servers. As a result, the widget never talks to Verena's servers directly. Its requests are encrypted with Oblivious HTTP and sent through an independent relay run by Oblivious Network.
| Who | Sees | Doesn't see |
|---|---|---|
| The relay | The visitor's IP address | The content: it's encrypted for Verena |
| Verena | The content | The visitor's IP address, only the relay's |
| Your site | The token | Anything from the check itself |
- The widget's page and script load from
widget.verena.se, a static host, so loading it doesn't reach Verena's servers either. - Your page makes no requests to Verena. That's why a Content Security Policy needs only
script-srcandframe-src. - It fails closed: if the relay can't be reached, the widget shows an error. It never falls back to a direct connection.
- It's on by default; there's nothing to set up. To debug, add
?verena_ohttp=0to your page's address to turn it off for that page load.
Privacy and security
What your site learns
That a person verified on a real device: valid: true. No name, no email, no device id, no biometrics. At events, an entry id that is only meaningful within that event.
What Verena learns
For a standard check, that one of the registered devices proved itself, not which one: the proof is zero-knowledge, over a set of all registered keys. The device fetches its place in that set with private information retrieval (PIR), so even that lookup doesn't single it out. Biometrics never leave the device.
The widget sends its requests through an independent privacy relay: the relay sees the visitor's IP address but not the content, and Verena sees the content but not the IP address.
Security
- Every check answers a fresh, single-use challenge, so a captured proof can't be replayed.
- The widget runs in a cross-origin frame. Scripts on your page can't read it or click it on the visitor's behalf.
- Tokens are bound to your key pair, expire after an hour, and are stored only as hashes.
More in the privacy policy.
Testing
- The widget works on
http://localhost. Leave the key's allowed origins empty, or add your dev origin, such ashttp://localhost:3000. - Use a real phone: an iPhone, or an Android phone with Chrome. From a computer, scan the QR code with your phone.
- Check your server path with a real token from
onVerified; anything else returnsvalid: false. Remember that tokens expire after an hour. - See it end to end in the contact form demo, the ticket queue demo and the article demo.
Questions or something missing here? [email protected]