terrastamp documentation
terrastamp determines a visitor’s country, and US state inside the United States, and writes the
result to a signed cookie, terrastamp, on your domain. Integration has two parts: an embed script on
your pages and a verification call on your server.
Quick start
Section titled “Quick start”Add the embed script with your site key:
<script src="https://api.terrastamp.dev/v1/stamp.js" data-site="YOUR_SITE_KEY" async></script>Verify the cookie on your server with the Node SDK and your binding key:
import { verifyStamp, jwksFromUrl } from './terrastamp'
const jwks = jwksFromUrl('https://api.terrastamp.dev/.well-known/jwks.json')
const r = await verifyStamp(req.cookies.terrastamp, { jwks, host: 'www.brand.com', bindingKey: process.env.TERRASTAMP_BINDING_KEY, ip: visitorIp,})if (r.ok && r.stamp.status === 'consensus') route(r.stamp.region) // "US-NY", "GB"The full walkthrough is in Getting started.
Reference
Section titled “Reference”The reference pages cover each part of the integration:
| Page | Covers |
|---|---|
| Stamp | Claims, signal values, inconclusive reasons, verify errors |
| Embed | Script attributes, window.terrastamp, the terrastamp:stamp event, the cookie |
| HTTP API | stamp.js, JWKS, timestamp proofs |
| Other languages | Verifying without the SDK: JWT checks and the IP binding |
| Known limits | Cases with fewer usable signals |