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 application

The 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_statusMeaningWhat to do
COMPLETEDAn assessment is readyRead device and modules
PENDINGSignals arrived and are being assessedAsk again in about 2 seconds
NO_OBSERVATIONSNo signals have reached Lean for this session yetNormal 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
FAILEDThe session's signals couldn't be processedDon'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:

  1. In your app, call collect(), then send your request with the session_id.
  2. On your backend, keep the assessment_id you last read for each session. If you get the same assessment_id back, the new signals are still on their way: ask again every 2 seconds, within your own time budget, until it changes.
  3. If you have no earlier assessment_id for the session, compare assessed_at with the time your request arrived, allowing a few seconds for clock differences.
  4. 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.

FieldDescription
idLean's device id, such as dvc_3f9a…
first_seenWhen Lean first saw this device
days_activeDays from first_seen to now, counting the first day
match_confidenceHow 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 statusMeaning
FLAGGEDAt least one label fired: see labels
CLEAREvery check that could run found nothing
INSUFFICIENT_DATANo check could be decided, for example without location permission, or with too little history yet
NOT_APPLICABLEThe 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 values

Lean 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:

WhenDo
device_integrity is FLAGGED with emulator_detected, root_access_detected, hooking_detected or automation_detectedStep up or block
high_risk_ip fires on a payment or a change of payout detailsStep 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 elseAllow, 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_tampered and timezone_spoofed can be triggered by privacy tools or a phone the user modified themselves. Consider them alongside other labels rather than blocking on them alone. INSUFFICIENT_DATA isn't a risk signal by itself either.

Errors

ResponseCause
400 invalid_request from /oauth2/tokenWrong client_id or client_secret
401 or 403The token is missing or expired, or wasn't requested with scope=api
404 Session not foundNo session with this id for your application, or it belongs to the other environment

Did this page help you?