Embedded session JWTs expire after one hour. WisdomAI provides a built-inDocumentation Index
Fetch the complete documentation index at: https://docs.wisdom.ai/llms.txt
Use this file to discover all available pages before exploring further.
postMessage mechanism that lets your application refresh the token before expiry without interrupting the user’s session.
Token lifetime
| Property | Value |
|---|---|
| Lifetime | 1 hour |
| Storage | localStorage as wisdom.jwt |
| Override | ?token= URL param always takes priority over any cached token |
Built-in refresh via postMessage
WisdomAI sends aREQUEST_JWT_TOKEN event to the parent window approximately 10 seconds before the embedded token expires. It is your responsibility to listen for this event, generate a fresh token by calling impersonateUser from your backend, and post it back. WisdomAI picks up the new token and continues the session without interruption.
Flow
- WisdomAI iframe detects the token is about to expire.
- WisdomAI sends
window.parent.postMessage({ type: 'REQUEST_JWT_TOKEN' }, '*')to the host. - Your host receives the event and validates
event.originmatches the WisdomAI domain. - Your host calls
impersonateUservia your own backend to get a fresh JWT. - Your host posts back
iframe.contentWindow.postMessage({ type: 'JWT_TOKEN_RESPONSE', token }, WISDOM_ORIGIN). - WisdomAI receives the new token and refreshes the session.
Implementation example
Replace
{ACCOUNT}.wisdom.ai with the base URL of your WisdomAI tenant — the same domain you use to log in. Both wisdom.ai and askwisdom.ai are valid depending on your deployment.Implementation notes
- WisdomAI sends the request with
'*'as the target origin. You must validateevent.originon your side before handling the message. - If your host does not respond within 10 seconds, the request times out and retries on the next render cycle.
- Only one refresh request is in-flight at a time. Duplicate requests are suppressed automatically.
- The
?token=URL param always takes priority over any cached token inlocalStorage.
Switching users
The WisdomAI frontend stores the active session token inlocalStorage as wisdom.jwt. To switch the impersonated user in the same iframe, reload the iframe with a new JWT in the ?token= URL param rather than attempting to swap the token in place.
Expired or invalid tokens
When an expired or invalid JWT is passed in the embed URL, users may be redirected to the login page instead of seeing a clear error. To prevent this, implement thepostMessage refresh listener described above so that tokens are refreshed before expiry.
Related articles
Impersonate User
Generate a session JWT for an embedded user
Embedding Overview
Full server-side embedding flow
User Lifecycle
Create, update, and remove embedded users