How it works
- Your frontend asks your own backend to start a domain session (never call Dotlet directly from the browser, that would expose your API key).
- Your backend calls
POST /api/v1/hosted/sessionswith your Dotlet API key and gets back anembed_url. - Your frontend renders that
embed_urlin an iframe. - The iframe posts
window.postMessageevents back to your page as the customer moves through the flow, so you know when to resize, close, or show a success state.
Step 1: Create a backend endpoint
Add one route to your backend that calls Dotlet’s session endpoint. Your Dotlet API key stays server-side and is never sent to the browser.This example is Next.js, matching the reference repo. The pattern is the same in any backend, one server-side route that calls
POST /api/v1/hosted/sessions with your API key and forwards the JSON response to your frontend.external_user_id and external_account_id are optional but recommended, they let you correlate anything the customer does in the session (a purchase, a DNS change) back to your own user and account records. allowed_actions scopes what the session can do; see the table below.
The response looks like:
Step 2: Embed the iframe on your frontend
Call your backend route, then render the returnedembed_url in an iframe.
Step 3: Listen for events from the iframe
The hosted UI communicates back to your page withwindow.postMessage. Listen for these events to resize the iframe, close it, or show your own success state:
Theming
theme_config on the session request controls how the hosted UI is branded:
All three fields are optional. You can also pass a
metadata object (any JSON) on the session request if you want to attach your own data to the session; it isn’t used by Dotlet, only stored against the session.
Session expiry
Sessions expire afterexpires_in_minutes (5–1440, default 60). Create a new session each time a customer opens the checkout flow rather than reusing one across visits.
Next steps
Direct integration
Build your own UI on top of the raw domain and DNS endpoints instead.
Hosted Sessions API reference
Full request and response schema for the session endpoint.