Ofage

Docs

Add Ofage to your site

Everything you need on one page: the one-line script, the WordPress plugin, the server-side check and the API.

Quick start

  1. Sign up and confirm your email.
  2. Add your site: its name and every web address it uses (for example https://www.example.com).
  3. On the site’s Geo rules tab, pick the preset for your industry, or set your own rules and ages.
  4. Install it with the one-line script, the WordPress plugin or a server-side kit, using the test keys first.
  5. When everything works, switch to the live keys.

One-line script

Add this to the <head> of every page. It asks Ofage whether the visitor’s region needs a check, covers the page when it does, and opens it after a pass. A pass is kept in the browser for the site’s pass lifetime (30 days by default).

<script src="https://verify.ofageid.com/sdk/av.js" data-site="pk_your_public_key" defer></script>
  • data-fail="verify" (default) keeps the page covered if Ofage cannot be reached; allow opens it.
  • Events on window: ageverify:decision, ageverify:passed, ageverify:error. The state is also in window.OfageCheck.
  • If your site sends a Content-Security-Policy, allow https://verify.ofageid.com in script-src and connect-src.

The script runs in the browser, so a visitor who knows how can get past it. For goods that need a firm gate (an online shop’s checkout), also check the token on your server: see Server-side check.

WordPress and WooCommerce

Install the Ofage plugin (Plugins, Add New, Upload Plugin), enter the site’s keys, and choose a mode: check every visitor when they arrive, or check at WooCommerce checkout before payment. The plugin redeems each token on your server and stores the pass with the order. Your dashboard’s Integration tab shows the steps with your site’s keys.

WordPress plugin (with WooCommerce), 1.0.0

Server-side check

Ready-made kits do all of this for PHP, Node.js and ColdFusion:

PHP kit, 1.0.0 Node.js kit (Express, Connect, node:http), 1.0.0 ColdFusion kit (Lucee), 1.0.0

The flow in any language:

  1. Ask POST /v1/geo/decision with the visitor’s IP. If the policy is allow, no check is needed; deny means the region is blocked.
  2. Create a random state, keep it in a short-lived cookie, and send the visitor to
    https://verify.ofageid.com/start?site=pk_…&return_url=<your callback>&state=<state>&min_age=<min_age from step 1>
  3. On your callback: the URL state must equal the cookie. With av_error (under_age, region_blocked, unavailable, cancelled, failed) show a message. region_blocked and unavailable come back at once when the visitor came from your site; someone who followed a link from elsewhere first sees an Ofage page with a button back to your site.
  4. Redeem the av_token once with POST /v1/tokens/verify (header Authorization: Bearer sk_…). Accept only when valid is true, state matches and age_over is at least the age you required.
  5. Set your own signed pass cookie, then redirect to a page on your own site only.

Treat timeouts, 401, 429 and 5xx answers as “service unavailable”, never as a pass.

Ages by region

A site can set its own age for a country, US state or Canadian province. The geo decision returns that age as min_age, the check proves it, and the token’s age_over carries it. Send the age you require to /start as min_age: the check then proves at least that age, even if Ofage places the visitor elsewhere.

What Ofage keeps

Photos are never saved. For 30 days Ofage keeps a coded fingerprint of the ID number (so one ID can pass at most 5 times in 24 hours), the scores and the page the visitor came from; after that only the result, the method, the times, the region and the failure reasons. Your site never gets the scores.

Some US state laws for adult sites forbid keeping anything that identifies the visitor after the check. Switch such a site to keep nothing (General tab; the adult presets do it for you): then none of that is ever stored, and there is no limit on reusing one ID. Make sure your own site keeps no identifying information either: store that the check passed, not the check’s ID with the customer’s account. Ask a lawyer what your states require.

The face data policy tells visitors how face data is used and deleted, and the check page asks for their consent.

Test mode

Every site has test keys (pk_test_…, sk_test_…). With them the check page shows Pass and Fail buttons, so you can run the whole flow without a camera, and ?geo=US-TX on /start pretends a location. Test checks are free, never counted, and their tokens say "test": true: never accept those in production.

API

CallWhat it does
GET /startStarts a check in the browser (site, return_url, state, optional min_age).
POST /v1/geo/decisionServer: the policy and age for a visitor’s IP.
POST /v1/sessionsServer: creates a check (optional visitor ip and min_age) and returns its URL.
POST /v1/tokens/verifyServer: redeems a token once.
GET /v1/sessions/:id/resultServer: the result of a check you created.
GET /v1/siteServer: which site your key belongs to (for setup screens).
GET /v1/geo/checkBrowser: the region answer the one-line script uses.
GET /.well-known/jwks.jsonThe public key that signs tokens (ES256).

Server calls send Authorization: Bearer sk_…. Never put a secret key in a page or an app.

Errors and limits

  • Errors are JSON: {"error": "code"}. 402 plan_limit_reached: your plan’s passes are used up this month. 403 region_blocked: the visitor’s region is blocked for this site.
  • A token works once and expires after 10 minutes. A check expires after 30 minutes.
  • Server calls: 6,000 a minute per secret key. Browser calls are limited per IP address.

Help

Write to [email protected]. Signed-in customers find their keys, ready-made snippets and statistics in the dashboard.