GET /api/partner/prices · production
Allowed
reason: ok
The registered key may read this route in production.
Give a partner agent read access to one endpoint. Run an allowed request, try a write, then revoke the key and retry.
This walk-through uses the existing partner-agent example: allow GET /api/partner/prices in production, deny a write, then revoke the key. Enterprise access controls are part of Business and Enterprise, or a pilot (402 plan_required otherwise).
Sign in at the dashboard with a Bitcoin wallet, add your site, pick which tokens or names unlock it, and add each origin that will call TOKENLOCK. The origin must be one of the site addresses in the dashboard; a challenge from any other origin is denied with 403 origin_not_allowed. You get a publishable key (pk_…, safe in the browser) and a secret key (sk_…, server only, shown once).
In the dashboard, open Enterprise access & decision log for the site and turn on registered keys, or from your server:
curl -sS https://tokenlock.ai/api/v1/tokenlock/access/settings \
-H 'Authorization: Bearer sk_…' \
-H 'Content-Type: application/json' \
-d '{"registered_keys":true}'
Then create an active key for the partner agent, limited to GET /api/partner/prices in production:
curl -sS https://tokenlock.ai/api/v1/tokenlock/access/keys \
-H 'Authorization: Bearer sk_…' \
-H 'Content-Type: application/json' \
-d '{"address":"bc1q…","label":"Partner agent","owner_type":"agent","routes":["/api/partner/prices"],"methods":["GET"],"environments":["production"]}'
The response includes the key id (key_ plus 12 hex characters). Keep it for revocation.
The agent signs a challenge once with the Bitcoin wallet that controls the registered address. Later API calls present the pass; they are not signed one by one. A registered agent key sends its address with the challenge (and still has to sign):
curl -sS https://tokenlock.ai/api/v1/gate/challenge \
-H 'Content-Type: application/json' \
-d '{"site_key":"pk_…","origin":"https://yoursite.com","address":"bc1q…"}'
Sign the returned message exactly with that wallet (BIP-322 or the wallet's "sign message"), then:
curl -sS https://tokenlock.ai/api/v1/gate/signin \
-H 'Content-Type: application/json' \
-d '{"challenge_id":"…","address":"bc1q…","signature":"…"}'
A valid answer includes pass, address, assets_held, origin and expires_at. Default pass lifetime is 900 seconds (15 minutes); the minimum is 60 and the maximum is 86400.
Route checks use POST (recommended) with path, method and environment, and the site secret key:
curl -sS https://tokenlock.ai/api/v1/gate/verify \
-H 'Authorization: Bearer sk_…' \
-H 'Content-Type: application/json' \
-d '{"pass":"pp1…","path":"/api/partner/prices","method":"GET","environment":"production"}'
# Allowed registered-keys answer (hosted check is live). cache_max_s: 5 is a
# client hint: reuse this allowed result for at most 5 seconds. Denied answers
# use cache_max_s: 0.
# → { "valid": true, "allowed": true, "correlation_id": "…", "cache_max_s": 5,
# "resource": { "path": "/api/partner/prices", "method": "GET", "environment": "production" },
# "access": { "mode": "registered_keys", "allowed": true, "reason": "ok", "key": { "id": "key_…", "label": "…", "owner_type": "agent" }, "permissions": { … } } }
curl -sS https://tokenlock.ai/api/v1/gate/verify \
-H 'Authorization: Bearer sk_…' \
-H 'Content-Type: application/json' \
-d '{"pass":"pp1…","path":"/api/partner/prices","method":"POST","environment":"production"}'
# → { "valid": false, "allowed": false, "code": "method_not_allowed",
# "reason": "This key is not allowed to use this method here." }
curl -sS https://tokenlock.ai/api/v1/tokenlock/access/keys/key_0123456789ab/revoke \
-H 'Authorization: Bearer sk_…' \
-H 'Content-Type: application/json' \
-d '{}'
curl -sS https://tokenlock.ai/api/v1/gate/verify \
-H 'Authorization: Bearer sk_…' \
-H 'Content-Type: application/json' \
-d '{"pass":"pp1…","path":"/api/partner/prices","method":"GET","environment":"production"}'
# → { "valid": false, "allowed": false, "code": "key_revoked",
# "reason": "This key was revoked by the site admin." }
Replace key_0123456789ab with the id returned when you created the key.
GET /api/partner/prices · production
Allowed
reason: ok
The registered key may read this route in production.
POST /api/partner/prices · production
Denied
method_not_allowed
This key is not allowed to use this method here.
GET /api/partner/prices · production · after revocation
Denied
key_revoked
This key was revoked by the site admin.
Check every request to the protected route on your server with the site secret key. Do not send the secret key to the browser. POST /api/v1/gate/verify with the pass, path, method and environment (the same check as the quickstart).
A hand-written check looks like the curl in the quickstart. If you use the npm package (current release 0.5.0; see release notes for earlier versions), verifyPass is the same check:
// current SDK 0.5.0
const info = await verifyPass(pass, {
secretKey: process.env.TOKENLOCK_SECRET_KEY,
path: '/api/partner/prices',
method: 'GET',
environment: 'production'
});
if (!info.valid || !info.allowed) {
// 401 no, invalid or expired pass; 403 signed in but not allowed
}
That verifyPass example is from the 0.5.0 package README, using the partner-prices path. The package name on the import line is in the install examples under TOKENLOCK.
Put a public sign-in page in front of the locked path, store a verified pass in an HttpOnly cookie, and clear that cookie on sign-out. The complete, copyable Vercel example (session and sign-out branches included) is in Lock a whole section of your site.
TOKENLOCK has its own MCP server (Streamable HTTP, no API key) at https://tokenlock.ai/mcp. It has the four TOKENLOCK tools below and nothing else. Add that URL as a Streamable HTTP server in your client. A Cursor config (~/.cursor/mcp.json) looks like this:
{
"mcpServers": {
"tokenlock": { "url": "https://tokenlock.ai/mcp" }
}
}
Call tokenlock_info with no arguments. The stable fields of the result are:
{
"name": "TOKENLOCK",
"tagline": "Zero-trust access for the token era",
"pitch": "An extra layer in front of your login, admin, or API. Only verified token holders get through.",
"audiences": ["Security teams", "AI agents", "Mining operations"]
}
The same result also includes how_it_works, for_agents, integrations, links, and a plans object (the live catalog from GET /api/v1/tokenlock/plans, or a built-in fallback if that request fails). Other TOKENLOCK tools on the same server: check_token_access (free, read-only), start_token_signin and finish_token_signin (the agent signs the challenge with its own wallet; this server never signs for you).
When a request uses Accept: application/json, or is under a configured API path, denials are JSON: 401 no, invalid or expired pass; 403 signed in but not allowed (including method_not_allowed and key_revoked); 400 rejected path; 503 verification unavailable (tokenlock_unavailable if the TOKENLOCK API is unreachable, times out or answers 5xx; kv_unavailable if the access store is down on a registered-keys site). Body: { error, code, reason, correlation_id }. The fail-closed guarantee lists every denial.
The Token sign-in, and the drop-in that keeps locked content on your server.
The wallet signs a one-time challenge. A short-lived pass is used on later requests. It does not prove legal identity.
Sign-in docs →Add the middleware or drop-in, point it at a path, and locked content stays on your server until the Token check has passed.
Protect a route →Zero-trust access for the token era. An extra layer in front of your login, admin, or API. Only verified token holders get through. Built for security teams, AI agents, and mining operations. A visitor clicks Sign in with your Token; we check that the address holds one of the required assets right now (it owns the name, or has a balance above zero), and return a short-lived signed pass. Your server checks the pass with one verify request (POST recommended). Live demo: /gate-demo. Every site needs a free TOKENLOCK site key.
Self-verify (SDK 0.3.0 and later, current 0.5.0; PHP drop-in current 0.5.0; Enterprise or pilot): your server issues the challenge, checks the wallet signature and reads holdings from a source you choose, with no call to our API for the sign-in. Node (@proveitonchain/tokenlock/self-verify) and PHP. Spec, trust table and revocation timing: /docs/self-verify.
Recommended: check the pass on your server with the PHP drop-in, npm @proveitonchain/tokenlock, or POST /api/v1/gate/verify, so locked content is never sent until we do the Token check. gate.js is only the "Sign in with your Token" button.
Soft gate: a browser-only gate.js snippet still sends the content to the visitor, so an extension or dev tools can pull it out. Fine for teasers and soft paywalls, not for anything that must stay private.
See it live: /vault/ is only for holders of GOTPROOF or TOKENLOCK. Every page and file there is checked on the server before anything is sent, so a copied link or a direct file URL shows the sign-in page, not the content. The pattern:
ProveItGate.signIn and POSTs the pass to your server./api/v1/gate/verify and stores it in an HttpOnly, Secure, SameSite=Lax cookie scoped to the locked path (1 hour is a good length).valid, not expired, origin is your site, and assets_held includes your token. No pass: redirect to sign-in.<!-- /signin.html (public) -->
<script src="https://tokenlock.ai/gate.js" data-site-key="pk_…"></script>
<button id="go">Sign in with your Token</button>
<script>
go.onclick = () => ProveItGate.signIn({ assets: ['YOURTOKEN'], passTtlSeconds: 3600 })
.then((r) => fetch('/members/__session', { method: 'POST', body: JSON.stringify({ pass: r.pass }) }))
.then((x) => { if (x.ok) location.href = '/members/'; });
</script>
Vercel (Routing Middleware, works with any framework):
// middleware.js at the project root (Vercel Routing Middleware, any framework)
import { next } from '@vercel/functions';
export const config = { matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'] };
const SITE = 'https://yoursite.com';
const ALLOWED = ['YOURTOKEN'];
const COOKIE = 'gate_pass';
const SECRET = process.env.TOKENLOCK_SECRET_KEY; // sk_… from your dashboard; never in browser code
async function passOk(pass) {
if (!pass) return false;
const v = await fetch('https://tokenlock.ai/api/v1/gate/verify',
{ method: 'POST', headers: { authorization: 'Bearer ' + SECRET, 'content-type': 'application/json' },
body: JSON.stringify({ pass, identity_only: true }) })
.then((r) => r.json()).catch(() => null);
return !!(v && v.valid && v.origin === SITE && v.assets_held.some((a) => ALLOWED.includes(a)));
}
export default async function middleware(req) {
const url = new URL(req.url);
// Broad matcher: this function decides which paths are protected. Skip everything outside /members (case-insensitive).
if (!url.pathname.toLowerCase().startsWith('/members')) return next();
if (url.pathname === '/members/__session' && req.method === 'POST') {
if (req.headers.get('origin') !== SITE) return new Response('Wrong site', { status: 403 });
const { pass } = await req.json().catch(() => ({}));
if (!(await passOk(pass))) return new Response('Not a holder', { status: 401 });
return new Response('ok', { headers: { 'set-cookie':
`${COOKIE}=${pass}; Path=/members; Max-Age=3600; HttpOnly; Secure; SameSite=Lax` } });
}
if (url.pathname === '/members/signout') {
return new Response(null, { status: 303, headers: { location: '/signin.html',
'set-cookie': `${COOKIE}=; Path=/members; Max-Age=0; HttpOnly; Secure; SameSite=Lax` } });
}
const pass = (req.headers.get('cookie') || '').match(/(?:^|;\s*)gate_pass=([^;]+)/)?.[1];
if (await passOk(pass)) return next(); // pass is good: serve the page or file
return Response.redirect(new URL('/signin.html', url), 302);
}
Next.js, Netlify and Cloudflare use the same passOk() and the same session and sign-out branches. Only the entry point changes:
// Next.js: middleware.ts — same passOk() and session/signout handling as above
import { NextResponse, type NextRequest } from 'next/server';
export const config = { matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'] };
export async function middleware(req: NextRequest) {
// Broad matcher: decide here which paths are protected (case-insensitive).
if (!req.nextUrl.pathname.toLowerCase().startsWith('/members')) return NextResponse.next();
// …same __session / signout branches…
if (await passOk(req.cookies.get('gate_pass')?.value)) return NextResponse.next();
return NextResponse.redirect(new URL('/signin', req.url));
}
// Netlify: netlify/edge-functions/gate.js — same passOk() and session/signout handling
export const config = { path: '/members/*' };
export default async (req, context) => {
// …same __session / signout branches…
if (await passOk(context.cookies.get('gate_pass'))) return context.next();
return Response.redirect(new URL('/signin.html', req.url), 302);
};
// Cloudflare Pages: functions/members/_middleware.js — same passOk() and session/signout handling
export async function onRequest({ request, next }) {
// …same __session / signout branches…
const pass = (request.headers.get('cookie') || '').match(/(?:^|;\s*)gate_pass=([^;]+)/)?.[1];
if (await passOk(pass)) return next();
return Response.redirect(new URL('/signin.html', request.url), 302);
}
These hand-written snippets are for token-only sites and match paths exactly as the platform does (usually case-sensitively). If your app or framework routes case-insensitively or decodes paths (Express does by default), use @proveitonchain/tokenlock 0.5.0 (current) or the PHP drop-in 0.5.0, which match paths in canonical form, case-insensitively, and reject encoded-slash tricks. See Security model.
PHP (7.4+, shared hosting and cPanel): a drop-in with no Composer packages. Upload the tokenlock/ folder, add your site key and secret key to config.php, and put this at the top of any page you want locked:
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/tokenlock/tokenlock.php';
tokenlock_require();
$visitor = tokenlock_pass(); // address, assets_held, expires_at
?>
Early block (PHP drop-in 0.3.0). tokenlock/early.php runs before your app boots, from auto_prepend_file or the first line of index.php. It checks the pass for the paths you list, and app code never runs for a visitor who is turned away. Admin paths and admin IPs you list are never blocked, and neither is the TOKENLOCK sign-in folder. A tokenlock/early.off file switches it off. Outages always fail closed (503); an invalid configuration answers 500 on protected paths (0.4.2 removed fail_open).
The package includes a sign-in page that uses gate.js with the button label Sign in with your Token, a session endpoint that sets an HttpOnly cookie, and a sample locked /holders/ page. Download: TOKENLOCK for PHP (PHP drop-in version 0.5.0, current; 0.4.4 security correction: self-verify validation, policy expiry and the pass secret are checked on every path; 0.4.3: malformed authorization requests refused (bad_resource), identity-only checks explicit ('identity_only' => true); 0.4.2 security hardening: removed fail_open, check_resource and 'strict' => false, configuration validation; since 0.4.0 explicit route authorization ('token_only' => true on token-only sites, see advisory 2026-11-18), strict checks of the route and method with registered keys, case-insensitive canonical path matching, JSON 401/403 for API requests, fails closed with a 503 "try again" page if we are unreachable, self-verify and early block). Which tokens unlock the site is set in your dashboard.
Each check is one verify request (POST recommended). On token-only sites you may cache a good identity result for up to 60 seconds in memory, but never past the pass's expires_at. In strict mode (always on since 0.4.2; default in SDK and PHP drop-in 0.4.0 and later) the hosted API checks a registered key live on every verify. Allowed registered-key answers include cache_max_s: 5 as a client hint (reuse that yes for at most five seconds); denied answers use cache_max_s: 0. Do not cache a registered-key yes longer than cache_max_s.
Route checks need a route policy (0.4.0, security advisory 2026-11-18). No path, method or environment is authorized unless a policy explicitly permits it. On a token-only site (registered keys off) a check that names a path, method or environment answers valid: false, allowed: false, code: "policy_required" (with identity_valid: true when the pass is good); identity-only checks are unchanged. Token-only sites using the middleware set tokenOnly: true (Node) or 'token_only' => true (PHP) so every holder may open every protected path. The hosted API answers this way to every client version, 0.2.x/0.3.x included (since the 18 Nov 2026 9 PM PT deployment), so older token-only middleware now denies protected paths until upgraded.
Fail-closed guarantee (SDK and PHP drop-in 0.5.0, current; hardening in 0.4.2, corrections in 0.4.3 and 0.4.4, security release 0.5.0). No setting turns this off. Each of these denies: a malformed authorization request in any adapter or the hosted API (0.4.3: unknown field or option, path without method, empty, whitespace-only, padded, null or non-string value: bad_resource; relative or non-canonical path: bad_path; identity-only checks must be explicit, { identityOnly: true } / 'identity_only' => true / identity_only: true, and are never inferred); a self-verify policy past its expires_at or issued in the future, wherever it is used (0.4.4: policy_expired / policy_invalid); a missing or short self-verify pass secret (0.4.4: bad_secret); a path, method or environment with no applicable route policy (policy_required); SDK, PHP and Cloudflare clients 0.2.x/0.3.x sending a resource to the hosted API on a token-only site (policy_required); tokenOnly / token_only on a site with registered keys (the route, method and environment are still checked); the TOKENLOCK API unreachable, timing out or answering 5xx (503 tokenlock_unavailable); in self-verify, a policy bundle that can't be loaded, is expired or has a bad signature (policy_unavailable / policy_expired), and a holdings source that fails (lookup_failed); a malformed policy (policy_invalid); an invalid configuration, including the removed options failOpen / 'fail_open', checkResource / 'check_resource' and strict: false, unknown options and a malformed secret key (bad_config at startup; PHP and the Cloudflare worker answer 500); and a malformed, oversized (over 64 KiB), non-JSON or contradictory API answer. Remaining limits, not switches: on hosted registered-keys sites, a pass younger than 2 × recheck_holdings_s keeps working during a holdings-source outage unless require_fresh_holdings is on (the route policy is still enforced), and switching a site between token-only and registered keys can take up to 30 s per server instance to reach the hosted API.
<script src="https://tokenlock.ai/gate.js" data-site-key="pk_…"></script>
<script>
ProveItGate.signIn({ assets: ['GOTPROOF', 'A1234567890123456789'] }) // any one is enough
.then((r) => fetch('/members', { headers: { 'x-pass': r.pass } }));
// or: ProveItGate.signIn({ anyName: true }) // anyone who holds a name on Bitcoin
</script>
<!-- no-code version -->
<div data-proveit-gate data-assets="GOTPROOF" data-on-pass="onPass"></div>
The sign-in window offers the browser wallets the site supports (Unisat, Xverse, Leather, Horizon and more) when installed, and always lets the visitor paste a signature from any wallet with "Sign message" (Sparrow, Electrum, Bitcoin Core). Options: siteKey (or data-site-key on the script tag), assets, anyName, passTtlSeconds (60 to 86400, default 900), title. Also exposed: ProveItGate.verifyPass(pass), ProveItGate.sign(walletId, message), ProveItGate.renderSigner(el, opts).
Used alone in the browser, this is a soft gate. Send the pass to your server and check it before you send anything private.
Body {"site_key":"pk_…","assets":["GOTPROOF"],"any_name":false,"origin":"https://yoursite.com","pass_ttl_seconds":900}. The Origin must be one of the site's addresses in your dashboard (403 origin_not_allowed); a browser call without a key gets 401 site_key_required. Up to 10 assets: names, numbered tokens (A…) or sub-tokens (PARENT.child). From a browser the site is taken from the Origin header. Returns challenge_id and message (valid 10 minutes, single use).
Body {"challenge_id","address","signature","name"?} (name is the name they hold, for any_name gates). Returns {"valid":true,"pass","address","assets_held","origin","expires_at"}, or valid:false with bad_signature, not_holder, expired, already_used, origin_mismatch or holder_changed. With a site key the response also has site_id and usage, and every attempt goes to the site's attempt log.
Check a pass on your server. POST is recommended: body {"pass","identity_only":true} for an identity check, or {"pass","path","method","environment"} for a route check. Since 0.4.3 a GET identity check must say identity_only=true, and route checks send path and method together (POST recommended); malformed requests answer bad_resource. Send your secret key as Authorization: Bearer sk_… and we also confirm the pass was issued for your site (wrong_site otherwise). Returns {"valid","address","assets_held","name","origin","site_id","issued_at","expires_at"}. Accept it only if valid is true, origin is your site, and assets_held includes what you require. Holdings are checked when the pass is issued, so keep passes short. A GET identity check, /api/v1/gate/verify?identity_only=true&pass=…, still works when identity_only=true is present.
curl -sS https://tokenlock.ai/api/v1/gate/verify \
-H 'Authorization: Bearer sk_…' \
-H 'Content-Type: application/json' \
-d '{"pass":"pp1.…","identity_only":true}'
A pass proves the visitor controlled a wallet holding the asset when they signed. It does not prove legal identity. Signing moves no funds and costs nothing.
Limits and abuse protection. The gate endpoints are rate-limited per client IP and per site, with higher limits on paid plans. Starting a challenge and signing in are also limited per network (IPv4 /24, IPv6 /64), with loose limits so many people behind one mobile or carrier network still get through. Registered agent keys are exempt; an agent sends its address with /api/v1/gate/challenge and still has to sign. Client IPs are counted under a keyed hash, never stored raw. Over a limit you get 429 with "code":"rate_limited" and a Retry-After header in seconds; wait that long before trying again. A sign-in is checked in order (request shape, challenge, expiry, single use, signature) before any holdings are looked up, so bad or replayed requests are turned away early. After repeated failed sign-ins we may ask for a quick check: /api/v1/gate/signin returns valid:false with "code":"captcha_required" and captcha.site_key. Show the check, then send the same request again with captcha_token. gate.js does this for you. Our server SDK and PHP drop-in cache good passes for up to 60 seconds, so normal traffic stays well under the limits. Our own public forms (the free TOKENLOCK request, dashboard sign-up and the enterprise demo start) can also ask for a Cloudflare Turnstile check; your integration and the gate API are not affected by that.
TOKENLOCK is the account side of the gate. Your pages stay on your site; we only do the Token check. Sign in at /tokenlock/dashboard with your wallet, add a site with its addresses (origins), pick the tokens that unlock it (any one is enough; the dashboard choice wins over anything a page sends), and you get:
pk_… for gate.js. It only works from the site's origins.sk_… for your server, shown once and stored only as a hash. Send it as Authorization: Bearer when you call /api/v1/gate/verify. Make a new one anytime in the dashboard.bad_signature, not_holder, expired, already_used, origin_mismatch, holder_changed), signing address, hashed IP, browser and origin. Kept for about 90 days.x-tokenlock-event and x-tokenlock-signature: sha256=<hex>, an HMAC-SHA256 of the raw body with your webhook secret (shown once).// Check a TOKENLOCK webhook (Node)
import { createHmac, timingSafeEqual } from 'node:crypto';
const want = 'sha256=' + createHmac('sha256', process.env.TOKENLOCK_WEBHOOK_SECRET).update(rawBody).digest('hex');
const ok = timingSafeEqual(Buffer.from(want), Buffer.from(req.headers['x-tokenlock-signature'] || ''));
// events: failure_spike { failures_last_10_min, threshold, last_attempt }, signin_failed { attempt }, signin { address, assets_held }
Pay for a plan in BTC from the dashboard. Prices are in USD; the payment step shows the exact amount in sats. The plan starts after 1 confirmation.
For teams, vendors and AI agents, a site can go from "any holder gets in" to a zero-trust rule, checked on every verify:
approved organization, when required by site policy, AND registered signing key AND valid entitlement AND permission for this resource AND not revoked
Organizations are optional. A key without an organization is allowed unless you turn on require_org.
It is off by default. Sites that don't turn it on keep the token-only rule, and existing integrations (gate.js, the PHP drop-in, @proveitonchain/tokenlock 0.1.x, plain REST) keep working unchanged. Registered keys, organizations and scoped permissions are part of Business and Enterprise, and pilot sites we enable on request; the decision log is on every plan. See it end to end in the enterprise demo. This section is also at /docs/enterprise.
org, employee, vendor or agent), an owner name and email, and an optional organization. Owner details stay offchain, in TOKENLOCK only./app/* for a prefix, /reports exact, * for all), methods, environments and an expiry. A key with no routes can sign in but reach nothing.path, method and (optional) environment with /api/v1/gate/verify. The answer says allowed with a reason, echoes the resource it checked (canonical path, method, environment) and carries an access object (key, owner, permissions, expiry). Route matching is case-insensitive on the canonical path.@proveitonchain/tokenlock 0.4.0+ and the PHP drop-in 0.4.0+ in strict mode (the default), registered-key answers are never cached, so an admin revoke is visible on the next request. With strict: false answers may be reused for up to cache_max_s (5 s) per server process; 0.1.x SDKs up to 60 s. If you call the API yourself, don't cache longer than cache_max_s. Details in Security model.pending_approval when holdings are next re-checked (at most recheck_holdings_s, 300 seconds by default — not immediately). A holder whose wallet isn't registered gets pending_approval too, and shows up in your open requests. Timing details: /docs/enterprise.POST /access/keys) is active immediately. pending_approval applies to unregistered holders when registered keys are on (an approval request is queued) and to registered keys that lose the token, not to keys the admin just added. Details: /docs/enterprise.Deny reasons: not_registered, pending_approval, key_revoked, key_expired, org_not_approved, org_required, entitlement_revoked, not_holder, route_not_allowed, method_not_allowed, environment_not_allowed, bad_path, lookup_failed.
# Check a pass for one resource
curl -X POST https://tokenlock.ai/api/v1/gate/verify \
-H 'Authorization: Bearer sk_…' -H 'content-type: application/json' \
-d '{"pass":"pp1…","path":"/api/partner/prices","method":"GET","environment":"production"}'
# Allowed registered-keys answer: hosted revocation is read live; cache_max_s: 5 is a
# client hint (reuse an allowed result for at most 5 seconds). Denied answers use cache_max_s: 0.
# → { "valid": true, "allowed": true, "correlation_id": "…", "cache_max_s": 5,
# "resource": { "path": "/api/partner/prices", "method": "GET", "environment": "production" },
# "access": { "mode": "registered_keys", "allowed": true, "reason": "ok", "key": { "id": "key_…", "label": "…", "owner_type": "agent" }, "permissions": { … } } }
# Denied: { "valid": false, "allowed": false, "code": "route_not_allowed", "reason": "This key is not allowed on this route.", … }
// collapsed; trailing / dropped; matched case-insensitively. Rejected with 400 bad_path: backslashes, control bytes, encoded /, \, NUL, %, . or ;, invalid encoding, any ; and any . or .. segment. Ambiguous forms are refused rather than resolved, because frameworks resolve them differently (/admin/.. is / to a URL parser but an /admin/* route serves it). So /ADMIN, /admin/, //admin and /%61dmin are all /admin; /admin;x, /./admin and /admin/.. are refused./Admin, /ADMIN and /admin are one authorization identity, even if your app routes them to different pages. A rule for /admin/* also covers /ADMIN/x, and a public carve-out for /join also opens /JOIN. Don't rely on case to separate protected and public routes.%2f, strip ;params or resolve .. after the check. Protect whole prefixes (/admin/*).allowed: true for exactly the path, method and environment asked about. Anything else is a denial. Strict together with fail-open, or with resource checks turned off, is a configuration error.Accept: application/json, or under configured API paths, get JSON for every denial: 401 no, invalid or expired pass; 403 signed in but not allowed; 400 rejected path; 503 verification unavailable. Body: { error, code, reason, correlation_id }.Roadmap, not available today: per-request signing for agent APIs; an independent security review of the hosted service and tenant isolation.
| Setup | Key revocation and permission changes | Token transferred away (holdings change) |
|---|---|---|
| SDK / PHP 0.4.0+ (current 0.5.0), strict (always on since 0.4.2), registered keys | 0: every protected request is checked live on the hosted API. Allowed answers still include cache_max_s: 5 as a client hint (reuse a yes for at most 5 s); denied answers use cache_max_s: 0 | Next hosted holdings re-check: up to recheck_holdings_s (300 s by default) |
Any SDK with cache: false, registered keys | 0 | Still up to recheck_holdings_s (300 s by default). cache: false turns off only the SDK's cache. |
SDK / PHP 0.4.0–0.4.1 with strict: false (removed in 0.4.2), or 0.2.0 | up to 5 s per server process | up to recheck_holdings_s plus 5 s |
| SDK 0.1.x | up to 60 s | up to recheck_holdings_s plus 60 s |
| Token-only sites | No keys to revoke | Holdings checked at sign-in; a pass stays good until it expires (default 15 min, max 24 h) |
| Self-verify (signed policy bundle) | Next successful policy refresh (60 s by default); bundle expiry (10 min) if refreshes fail | Holdings read at sign-in; a pass stays good until it expires (pass_ttl_s, 900 s by default) |
Manage access from the dashboard (Enterprise access & decision log on each site) or from your server with the site's secret key: Authorization: Bearer sk_… on https://tokenlock.ai/api/v1/tokenlock/access….
GET /access: settings, organizations, keys, open requests, revoked tokens, recent admin actions.POST /access/settings: registered_keys, require_org, require_fresh_holdings, agent_pass_ttl_s, default_pass_ttl_s, recheck_holdings_s, decision_webhook, alert_on_abandoned, hash_addresses.POST /access/orgs { name } or { id, status: "approved"|"suspended" }.POST /access/keys { address, label, owner_type, owner_name, owner_email, org_id, routes, methods, environments, expires_at, pass_ttl_s } creates an active key immediately; POST /access/keys/:id to edit; /revoke; /approve (paused key becomes active immediately); /rotate { new_address, grace_s }.POST /access/requests/:id/approve or /deny; POST /access/entitlements/revoke or /restore { asset }.The hosted decision log records sign-in outcomes (authorized, denied, abandoned), denied pass checks, and successful (authorized) verifies that reach our API. SDK or PHP cache hits never reach the API, so they are not logged; self-verify decisions are not logged on our side. In strict mode, registered-key checks reach the hosted API on every protected request. The service attempts to log each decision, and a logging failure does not block access. Authorized verifies count toward the monthly cap. The dashboard and decisions API show this month's use and today's use against the caps, and warn at 80% and at the cap. Each entry has a correlation_id when the pass or challenge has one (the sign-in nonce, also returned by challenge, sign-in and verify), the reason, key, owner, resource, wallet, hashed IP and timestamps. Kept 14 days on Free, 180 on Business and 365 on Enterprise. Caps and delivery guarantees: /docs/enterprise. See also Decision records.
GET /access/decisions?outcome=denied&reason=…&key_id=…&correlation_id=…&since=…&until=…GET /access/decisions/export?format=csv or format=jsonl (one JSON event per line).decision_webhook): each logged decision is POSTed once as event: "decision", type: "tokenlock.decision", signed with HMAC-SHA256 in x-tokenlock-signature, with a 3 second timeout and no retries. Delivery is best-effort, not at-least-once. Failed deliveries remain in the Redis export until retention or the cap drops them. Webhook retries are planned, not shipped.Where records live today:
Decision-log retention by plan: 14 days on Free, 180 on Business and 365 on Enterprise. The Redis keys expire one day after that window. If a site goes over its monthly decision cap, the oldest rows for that day are dropped; the daily counts remain.
Deleting a site is a soft delete: the site document is marked deleted with a deleted_at time and is removed from your account list, but the document stays in storage. The site's publishable key, secret key and outstanding passes stop working immediately. Soft deletion does not purge Redis access state, the encrypted Blob backup or journal, or decision-log keys. Decision-log keys expire with their retention TTL. Access state, the backup and the journal have no automatic expiry. To request permanent deletion of owner details, backups, journals and residual site records, email hello@tokenlock.ai.
Who can change or purge these records:
Retention alone is not tamper evidence. Anyone with the credentials above can change or delete stored records. Entries are not hash-chained, and there is no signed or anchored digest, so a later change would not be evident from the log itself.
What you can do today: export the log to your own systems (a read of whatever is still in Redis), and on Business and Enterprise you can opt in to a signed decision webhook (best-effort, one POST, no retries; see above). Decision logs are not backed up. A SIEM sink and webhook retries are planned, not shipped.
Planned, not shipped: hash-chained log entries with a periodic signed or anchored digest, so a change or purge after the fact would be detectable.
POST /access/keys/:id/rotate { "new_address": "bc1q…", "grace_s": 3600 } (or Rotate in the dashboard). The new key gets the same owner, organization, permissions and expiry, and works immediately. Both keys link to each other (rotated_from, rotated_to).key_expired. A pass never outlives its key: pass lifetimes are capped at the key's expiry.agent_pass_ttl_s for the site or pass_ttl_s per key, from 60 seconds). The agent signs a fresh one-time message with its key each time, so a leaked pass is only useful briefly, and a rotated or revoked key stops working on the next check.recheck_holdings_s, default 300 seconds), the key is paused with pending_approval, access is denied, and an approval request is queued. The wallet that received the token is not registered, so it also gets pending_approval and appears in your open requests. Nothing is granted until an admin approves.POST /access/keys/:id/approve, or approve the request with POST /access/requests/:id/approve.Today, checks depend on our API. This is what happens when part of it is down:
| What is down | Token-only sites | Sites with registered keys |
|---|---|---|
| TOKENLOCK API (your server can't reach us) | Passes can't be checked and new sign-ins can't start. With the PHP drop-in 0.2.0+ and @proveitonchain/tokenlock 0.2.0+, locked pages fail closed by default: a 503 "try again" answer, the visitor's cookie is kept, and they are back in as soon as we answer. A good answer already in the local cache is reused for up to 60 seconds (token-only) or 5 seconds (registered keys). Since 0.4.2 there is no fail-open option: failOpen (SDK) and 'fail_open' (PHP) were removed and are configuration errors. SDK 0.1.x sends the visitor to sign in again and clears the cookie. | |
| Blockchain data source (we can't read holdings) | New sign-ins fail closed (lookup_failed). Passes already issued stay valid until they expire, because holdings were checked at sign-in. |
New sign-ins fail closed (lookup_failed). On verify, holdings are cached per wallet for recheck_holdings_s (default 300 seconds). When the cache has lapsed and the lookup fails, passes younger than twice that window stay allowed; older passes are denied with lookup_failed. Revocation, expiry, organization and permission checks don't need the chain and keep working. |
| Access store (our Redis) | Not used for sign-in or verify, so access is unaffected. Decision-log entries during the outage are not recorded. | Fail closed: sign-in and verify answer 503 (kv_unavailable). We never fall back to token-only, so a revoked key never gets through. If stored access settings are lost, they are restored from a durable backup before any access is allowed. |
Revocation is enforced on every verify whenever the access store is reachable, and requests are denied when it isn't.
Self-verify (SDK 0.3.0 and later, current 0.5.0; PHP drop-in current 0.5.0; Enterprise or pilot). Your servers can check signatures, passes and holdings without calling our API, and check registered keys against a signed policy bundle they cache. Self-verify can also ask two holdings sources and fail closed if they disagree. A revocation reaches a self-verify server on its next policy refresh (60 seconds by default), and never later than the bundle expiry (10 minutes by default). After that it fails closed. See /docs/self-verify.
Current npm SDK and PHP drop-in: 0.5.0 (package.json version and TOKENLOCK_PHP in the tokenlock-rc8 tree). 0.5.0 is a security release: it denies some inputs 0.4.4 accepted. Dependents on ^0.4.x do not pick up 0.5.0 automatically.
bad_resource / bad_path).failOpen, checkResource and strict: false are configuration errors. Strict mode is always on.policy_required otherwise). Token-only sites using the middleware set tokenOnly: true.