Skip to main content
Version: v1.0

Widget Guide

Embed the hosted consent widget in your site. API details: API Reference (Widget).


Overview​

The hosted widget is served at /widget/hosted and loaded in an iframe. Your backend creates a short-lived widget session; the user grants, updates, or revokes; your page listens for postMessage events.

Your backend → createWidgetSession → sessionId + token
Your frontend → iframe /widget/hosted?... → user action → submit
Your frontend ← postMessage (consent.submitted, widget.ready, …)
Sammati → (live) webhook consent.recorded → proof pipeline

On the test ledger, sessions and consent persist but automatic webhooks are not enqueued — verify with Send Test Event.


Hosted widget​

  1. Publish a policy — Policies.
  2. Register allowed origins in the Company Portal under Allowed origins.

Allowed origins

  1. Create a session with client.widget.createSession(body).
  2. Embed the iframe with the hosted URL and session parameters.
MethodPurpose
client.widget.createSessionCreate session
client.widget.getSessionRead session status
client.widget.submitSessionSubmit (server-side path)
client.widget.getHostedHtmlHosted HTML
client.widget.bootstrapRuntimeRuntime config for advanced embeds

Browser helper (@sammati/widget-sdk)​

For browser apps, use @sammati/widget-sdk to create the iframe and handle typed postMessage events.

→ SDK Guide


Customization​

Policy artifacts control copy, purposes, and presentation. Edit them in Policies — the editor includes a widget preview.


Events​

postMessage events on the parent page:

EventMeaning
widget.readyIframe loaded and interactive
consent.submittedUser completed an action

Server webhooks (automatic on live): widget.session.created, widget.session.consumed, consent.recorded — Webhooks. On test keys, use Send Test Event.


Sandbox​

Test the full widget flow without deploying embed code:

  1. In the Company Portal, open Developer → Sandbox (or Integration Center → Widget Sandbox).
  2. Use your test API key and a published policy.

Widget sandbox

→ Sandbox guide


Testing​

CheckHow
Origin allowedAllowed origins in the portal; send X-Sammati-Embed-Origin on session create
Session not expiredgetWidgetSession status
End-to-endPortal sandbox or your staging site

Next steps​