Overview
Doshi webview authentication uses a secure two-step process:- Generate a custom token by calling the Doshi API with your API key
- Pass the token to the iframe using postMessage or query parameters
1
Get API Key & Whitelist IP
Contact hello@doshi.app to:
- Receive your API key
- Whitelist your server IP address(es)
2
Generate Custom Token
Call the authentication endpoint with your API key from your whitelisted server
3
Embed Webview
Pass the custom token to the Doshi Frontend using postMessage or query parameters
4
User Signs In
Doshi handles the sign-in process, including 2FA if enabled
These examples use the production hosts. To test against sandbox, use
https://sandbox.embed.doshi.app (and https://sandbox.api.doshi.app for the
API) — your client token works in both. See Environments.Authentication Flow
Step 1: Generate Custom Token
Call the authentication endpoint with your API key:API Parameters
Required (at least one):email- User’s email addresspartnerUserId- Your internal user ID
firstName- User’s first namelastName- User’s last namebranchId- Branch or location identifier
You must provide either
email OR partnerUserId (or both). All other fields are optional.Setting the Starting Learning Path
By default, a new user picks their own learning path the first time they open Doshi. To skip that screen and drop them straight into a specific set of lessons, pass apathId when you mint the token.
1
Create the path
In the dashboard, go to Paths → Create, then add the courses and lessons you want the user to see.
2
Copy the path ID
On the path’s card, open the ⋯ menu and choose Copy ID. The ID is also the last segment of the path’s URL (
/paths/<pathId>).3
Pass it when generating the token
Include the ID as
pathId in the token request.Behaviour and limits
- Sets the initial path only. If the user already has a path,
pathIdis ignored — existing users are never moved. It is not a way to switch someone’s path later. - Don’t combine it with
segment. The two write to different places, so sending both leaves the path-selection screen in place. Use one or the other. - The ID isn’t validated. An incorrect ID is accepted without an error and leaves the user without usable content, so confirm the flow on sandbox before going live.
- Must be 2–50 characters.
- Works with the 2FA flow.
pathId decides which lessons the user starts on. segment is different —
it narrows which paths a user is offered when you run several paths under one
organization, and still lets them choose.Step 2: Pass Token to Doshi Frontend
Pass the nonce token to the Doshi Frontend using one of two methods:postMessage (Recommended)
Secure, real-time communication for sensitive data
Query Parameters
Simple URL-based authentication
Frontend Parameters
Required:token- The nonce token from the API
email- User’s email addresssegment- For handling multiple learning pathsbranchId- Branch or location identifier
2FA Parameters (Optional)
When 2FA is enabled, pass these additional parameters:All 2FA fields are required when is2FaEnabled is true:
is2FaEnabled- Set totruedob- Date of birth (YYYY-MM-DD)organizationId- Your organization IDpartnerUserId- Your internal user IDfirstName- User’s first namelastName- User’s last name
string
required
The nonce token received from the API
string
User’s email address (optional)
string
Used for handling multiple learning paths under the same organization (optional)
string
Branch or location identifier (optional)
boolean
Set to
true to enable 2FA flow (optional, but if true, all 2FA fields below are required)string
User’s date of birth - YYYY-MM-DD format (required when is2FaEnabled is true)
string
Your organization ID (required when is2FaEnabled is true)
string
Your internal user ID (required when is2FaEnabled is true)
string
User’s first name (required when is2FaEnabled is true)
string
User’s last name (required when is2FaEnabled is true)
When 2FA is enabled, the Doshi Frontend automatically handles the OTP send and verification flow. You don’t need to call the OTP endpoints separately.
Step 3: Session Management
Once authenticated, the Doshi Frontend automatically manages the session:- ID Token TTL: 1 hour
- Refresh Token TTL: 12 hours
- Auto-refresh: Tokens are refreshed automatically
Quick Example
React with postMessage
React with Query Parameters
With 2FA Enabled
Next Steps
postMessage Method
Detailed postMessage implementation
Query Parameters
URL-based authentication guide
Security
Security best practices
Need Help?
Contact Support
Get your API key or ask questions: hello@doshi.app
