Deciding whether you need a token
An app’s visibility decides whether it asks people to sign in, and so whether you need a token at all. Set it withpublic_settings when you create the app.
Without sign-in, the app can’t tell who’s looking at it, so anything that belongs to one person, such as their own saved data, doesn’t work. Learn more about app visibility.
Signing the end user in
1
Provision the end user
Send This gives them access to the app. It’s idempotent, so you can call it before every mint. The response’s
POST /api/apps/{app_id}/users/provisions with the end user’s email and one of the app’s roles:status is created the first time and exists after that.Use the email your platform signed the end user in with. Never take it from the browser, or anyone could open an app as anyone else.2
Mint a sign-in token
Send
POST /api/apps/{app_id}/embed-tokens with the same email, and the version of the app you want to show:The response carries
embed_url, the address of that version with the token already on it, and expires_in, which is 60 seconds.3
Load the URL in your iframe
Set the iframe’s
src to embed_url, and the app opens signed in as the end user. A token works only once, so mint a new one each time you load the frame.Choosing which version to show
Matchtarget to what the end user should see:
- An app you’ve published: Use
live_site. - An app you haven’t published: Use
latest_preview, which also shows builders their changes as soon as a build finishes. - The builder’s preview while a build runs: Use
live_preview.
Errors
Minting returns errors as{"error": {"code", "message", "details"}}.
The reference integration does all of this in
embedSession.ts.
See also
- The build turn: Create, preview, and publish the app you’re embedding
- Tenancy and credentials: The account that owns your builders’ apps, and the token that creates them
- Workspace secrets: Create and manage the workspace API key this page uses