Embed
<script src="https://api.terrastamp.dev/v1/stamp.js" data-site="YOUR_SITE_KEY" async></script>Attributes
Section titled “Attributes”The script tag accepts these attributes:
| Attribute | |
|---|---|
data-site |
Required. Your site key. |
data-cookie-domain |
E.g. ".brand.com": share the cookie across subdomains. Default: the current host only. |
data-reload |
"once": reload the page once after a new stamp. |
Page-code API
Section titled “Page-code API”The script defines window.terrastamp. Values here are for display only: the browser can’t verify
a stamp, so your server must verify the cookie before trusting it.
// Resolves with the first stamp of this page view, or null if none could be obtained.const claims = await terrastamp.ready
// The current stamp's claims, decoded from the cookie (not verified), or null.terrastamp.get()
// Run a check now. force: true checks again even with a valid stamp, e.g. for a "Try again" link.await terrastamp.check({ force: true })terrastamp:stamp fires on document on every page view that has a stamp, whether it came from the
cookie or from a new check. event.detail holds the claims.
document.addEventListener('terrastamp:stamp', (e) => { console.log(e.detail.status, e.detail.region)})Add the listener before the script runs, or use terrastamp.ready, so you don’t miss the first event.
Cookie
Section titled “Cookie”The script stores the stamp in a first-party cookie on your domain:
| Name | terrastamp |
| Path | / |
| SameSite | Lax |
| Max-Age | Until the stamp expires. |