Skip to content

UI events from the embedded admin portal

Listen to the browser events emitted from the embedded admin portal to perform actions on your app. For example, showing a notification when the Single sign-on connection is enabled.

Event TypeDescription
ORGANIZATION_SSO_ENABLEDTriggered when the Single sign-on connection is enabled
ORGANIZATION_SSO_DISABLEDTriggered when the Single sign-on connection is disabled
PORTAL_SESSION_EXPIRYTriggered when the admin portal session expires
ORGANIZATION_DIRECTORY_ENABLEDTriggered when the SCIM Provisioning is enabled
ORGANIZATION_DIRECTORY_DISABLEDTriggered when the SCIM Provisioning is disabled

To listen to these events:

  1. Add a listener to the parent window.
  2. Check the event origin and type to determine the action to take.
  3. Handle the event data as needed.
Listening to events from the embedded admin portal
window.onmessage = event => {
if (
event.origin === '<SCALEKIT_ENVIRONMENT_URL>' &&
event.data &&
event.data.event_type === '<EVENT_TYPE>'
) {
console.log(event.data); // Handle the event data
}
};

The domain of your parent window must be listed in the Scalekit Dashboard > API Config > Redirect URIs for security purpose. Always validate the event.origin to ensure events are coming from a trusted source.

Event types

The following event types are emitted by the embedded admin portal. Each event includes specific data that you can use to update your application’s UI or trigger other actions.

ORGANIZATION_SSO_ENABLED

{
"event_type":"ORGANIZATION_SSO_ENABLED",
"object":"connection",
"organization_id":"org_4010340X34236531",
"message": "Single sign-on connection enabled successfully",
"data":{
"connection_type":"SSO",
"id":"conn_4256075523X312",
"type":"OIDC",
"provider":"OKTA",
"enabled":true
}
}

ORGANIZATION_SSO_DISABLED

{
"event_type":"ORGANIZATION_SSO_DISABLED",
"object":"connection",
"organization_id":"org_4010340X34236531",
"message": "Single sign-on connection disabled successfully",
"data":{
"connection_type":"SSO",
"id":"conn_4256075523X312",
"type":"OIDC",
"provider":"OKTA",
"enabled": false
}
}

PORTAL_SESSION_WARNING

{
"event_type": "PORTAL_SESSION_WARNING",
"object": "session",
"message": "The admin portal session will expire in 5 minutes",
"organization_id": "org_43982563588440584",
"data": {
"expiry": "2025-02-28T12:40:35.911Z"
}
}

PORTAL_SESSION_EXPIRY

{
"event_type": "PORTAL_SESSION_EXPIRY",
"object": "session",
"message": "The admin portal session has expired",
"organization_id": "org_43982563588440584",
"data": {
"expiry": "2025-02-28T12:40:35.911Z"
}
}

ORGANIZATION_DIRECTORY_ENABLED

{
"event_type": "ORGANIZATION_DIRECTORY_ENABLED",
"object": "directory",
"organization_id": "org_45716217859670289",
"message": "SCIM Provisioning enabled successfully",
"data": {
"directory_type": "SCIM",
"id": "dir_45716228982964495",
"provider": "MICROSOFT_AD",
"enabled": true
}
}

ORGANIZATION_DIRECTORY_DISABLED

{
"event_type": "ORGANIZATION_DIRECTORY_DISABLED",
"object": "directory",
"organization_id": "org_45716217859670289",
"message": "SCIM Provisioning disabled successfully",
"data": {
"directory_type": "SCIM",
"id": "dir_45716228982964495",
"provider": "MICROSOFT_AD",
"enabled": false
}
}