Reading assessments
Get a session's assessment on your backend, and use it to allow, step up or block.
Once your app has sent you a session_id, your backend gets the session's assessment from Lean. It's a single authenticated GET, made whenever your backend reaches a decision, such as a login or a payment.
1. Get an access token
Use your application's client credentials with scope=api, as described in Authentication:
curl -X POST 'https://auth.sandbox.leantech.me/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=<LEAN_APPLICATION_ID>' \
--data-urlencode 'client_secret=<LEAN_CLIENT_SECRET>' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=api'The token is valid for expires_in seconds, about an hour. Cache it and reuse it until it expires, rather than getting a new one for every call.
2. Get the session's assessment
curl -X GET 'https://sandbox.leantech.me/device-intelligence/v1/sessions/<session_id>/assessment' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'Accept: application/json'
The session must belong to your applicationThe SDK key that opened the session and the credentials that read it must belong to the same Lean application and the same environment. Otherwise the answer is
404 Session not found.
3. Check the assessment status
Lean assesses each set of signals a few moments after it arrives, so your first call may come before the assessment is ready. Check assessment.assessment_status first:
assessment_status | Meaning | What to do |
|---|---|---|
COMPLETED | An assessment is ready | Read device and modules |
PENDING | Signals arrived and are being assessed | Ask again in about 2 seconds |
NO_OBSERVATIONS | No signals have reached Lean for this session yet | Normal for the first few seconds after the SDK starts. Ask again every 2 seconds, for up to about 15 seconds after the session started. After that, decide without Sanad, and check the SDK's diagnostics in your app |
FAILED | The session's signals couldn't be processed | Don't retry. Decide without Sanad |
{
"status": "OK",
"message": "Assessment pending",
"timestamp": "2026-10-26T09:14:59.010Z",
"assessment": {
"session_id": "6f0b5f8e-1f0a-4f53-9c11-4d6a0c3f2b7e",
"assessment_status": "PENDING"
}
}{
"status": "OK",
"message": "Assessment retrieved",
"timestamp": "2026-10-26T09:15:02.481Z",
"assessment": {
"assessment_id": "0c6f1d0e-6a53-4c43-9d0b-2f7a4f8a4d11",
"session_id": "6f0b5f8e-1f0a-4f53-9c11-4d6a0c3f2b7e",
"customer_id": null,
"assessment_status": "COMPLETED",
"assessed_at": "2026-10-26T09:15:01.902Z",
"device": {
"id": "dvc_3f9a1c0b7e…",
"first_seen": "2026-09-30T18:02:11Z",
"days_active": 27,
"match_confidence": "MATCHED"
},
"modules": {
"device_integrity": { "status": "FLAGGED", "labels": ["root_access_detected"] },
"network_analysis": { "status": "CLEAR", "labels": [] },
"location_analysis": { "status": "INSUFFICIENT_DATA", "labels": [] },
"device_relationships": { "status": "CLEAR", "labels": [] }
}
}
}4. Make sure the assessment is fresh
Each new set of signals produces a new assessment, and Lean always returns the newest one that's ready. When your app calls collect() right before a sensitive action, your backend may ask for the assessment before the new signals have been assessed. To make sure you act on the device as it is now:
- In your app, call
collect(), then send your request with thesession_id. - On your backend, keep the
assessment_idyou last read for each session. If you get the sameassessment_idback, the new signals are still on their way: ask again every 2 seconds, within your own time budget, until it changes. - If you have no earlier
assessment_idfor the session, compareassessed_atwith the time your request arrived, allowing a few seconds for clock differences. - If no new assessment arrives in time, decide on the newest one you have.
5. Read the result
The device
Lean's identity for the physical device. It stays the same across sessions, and across app reinstalls where the platform allows, so you can store it against your customer and notice a new or shared device.
| Field | Description |
|---|---|
id | Lean's device id, such as dvc_3f9a… |
first_seen | When Lean first saw this device |
days_active | Days from first_seen to now, counting the first day |
match_confidence | How Lean recognised the device: MATCHED (a known device), PROBABLE (it closely resembles a known device) or NEW (seen for the first time) |
device is null in the rare case where Lean couldn't recognise the device at all.
The modules
Each module has a status and the labels that fired. See Modules and labels for every label.
Module status | Meaning |
|---|---|
FLAGGED | At least one label fired: see labels |
CLEAR | Every check that could run found nothing |
INSUFFICIENT_DATA | No check could be decided, for example without location permission, or with too little history yet |
NOT_APPLICABLE | The module has no checks for this platform. reason says why |
customer_id is the customer linked to the session, or null. See Linking customers.
Expect new valuesLean adds labels, modules and status values over time. Ignore any value your integration doesn't recognise rather than failing.
6. Act on it
How you use the assessment depends on your risk appetite and on what's at stake. A good starting policy:
| When | Do |
|---|---|
device_integrity is FLAGGED with emulator_detected, root_access_detected, hooking_detected or automation_detected | Step up or block |
high_risk_ip fires on a payment or a change of payout details | Step up or block |
A high-value action from a device first seen within the hour (device_first_seen_under_1h), or from a device shared by several customers (multiple_customers_same_device) | Step up |
| Anything else | Allow, and log the assessment for review |
Stepping up means asking for another check, such as an OTP or a selfie.
Some labels also fire for honest users
boot_unverified,browser_tamperedandtimezone_spoofedcan be triggered by privacy tools or a phone the user modified themselves. Consider them alongside other labels rather than blocking on them alone.INSUFFICIENT_DATAisn't a risk signal by itself either.
Errors
| Response | Cause |
|---|---|
400 invalid_request from /oauth2/token | Wrong client_id or client_secret |
401 or 403 | The token is missing or expired, or wasn't requested with scope=api |
404 Session not found | No session with this id for your application, or it belongs to the other environment |
Updated about 21 hours ago
