Web Portals
Collect the encrypted browser payload with the JavaScript SDK and forward it to your backend to register the login event with SmartID.
Before integrating, install the SDK in Getting Started → Install the SDK →
personalization_raw
Collects browser and device fingerprint data synchronously and returns the encoded payload as a string. Call this in the onload of the login page.
// call on page load, before the user submits credentials
const smartidData = personalization_raw();
// attach to the hidden input — empty string if the call returned nothing
document.getElementById('smartid-data').value = smartidData || ''; If you use the Web Integrity rule, call personalization_integrity() before personalization_raw() so that site integrity data is captured in the payload.
Include in the login form
Add a hidden input to carry the payload on form submission.
<form action="/api/login" method="POST">
<input type="text" name="username" placeholder="Username" />
<input type="password" name="password" placeholder="Password" />
<input type="hidden" name="smartid_data" id="smartid-data" />
<button type="submit">Login</button>
</form> Complete login flow
The SDK runs in the user's browser. Only your backend calls the SmartID API.
SDK collects data in the browser
When the login page loads, call personalization_raw(). It returns the encoded payload synchronously and writes it into the hidden input.
Form sends credentials + payload to your backend
On submit, the form posts username, password, and the hidden smartid_data field to your server. If the SDK failed, the field is empty.
Your backend calls the SmartID API
Your server POSTs the login event to SmartID with the user attributes and encrypted payload.
/api/v5/analytics/web/login curl -X POST https://<api-url>/api/v5/analytics/web/login \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer <license>" \\
-d '{
"channelId": 1,
"user": "jlopez",
"session": "445613456fa",
"publicIp": "20.201.64.54",
"data": "<smartid_data from the form, empty string on failure>"
}' | Field | Type | Required | Description |
|---|---|---|---|
channelId | integer | Required | Your SmartID channel identifier |
user | string | Required | Username or unique user identifier |
session | string | Optional | Your application session token |
publicIp | string | Required | User's public IP address |
data | string | Required | Payload from getRawData. Empty string if SDK failed. |
SmartID returns 200 OK
SmartID logs the event and responds with 200 OK. Proceed with your normal login logic.
Logout
When the user logs out, notify SmartID from your backend. No SDK call is needed from the browser.
/api/v5/analytics/web/logout curl -X POST https://<api-url>/api/v5/analytics/web/logout \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer <license>" \\
-d '{
"channelId": 1,
"user": "jlopez",
"session": "445613456fa"
}' publicIp and data are optional on logout. channelId, user, and session are sufficient to close the event.