Getting started with Sanad
The keys and credentials you need, and the environments to use them in.
A Sanad integration has two halves: the SDK in your app, and one or two API calls from your backend. Each half uses its own credentials.
Sanad must be enabled for your application before you start. Reach out to your Lean representative to enable it.
What you need
| Item | Used by | Where to find it |
|---|---|---|
| SDK key | Your app (Android, iOS or web) | The Application Dashboard |
Application ID (client_id) | Your backend | The Application Dashboard |
| Client secret | Your backend only | The Application Dashboard. See Authentication |
An SDK key can only open sessions and send device signals. It can't read assessments or customer data, so it's safe to ship inside your app. If a key leaks, issue a new one in the Application Dashboard and release your app with it.
Keep the client secret on your backendYour app holds only the SDK key. The client secret can read the assessments of all your sessions, so it must never ship in an app or a web page.
Environments
Every SDK key names its environment, and the SDK picks Lean's host from the key on its own. You don't configure any URL in your app.
| SDK key starts with | Environment |
|---|---|
lean_device_ae_sandbox_ | Sandbox |
lean_device_ae_ | Production |
Your backend uses the hosts of the same environment:
| Environment | Auth host | API host |
|---|---|---|
| Sandbox | https://auth.sandbox.leantech.me | https://sandbox.leantech.me |
| Production | https://auth.leantech.me | https://api2.leantech.me |
Start with a sandbox key and sandbox credentials, then switch both to production for release. A session opened with a sandbox key can only be read with sandbox credentials, and a production session only with production credentials.
The integration, step by step
Sanad works best when it sees the device early, before your user logs in. That way your backend already has an assessment when the login request arrives, and can add friction to a risky login rather than discover the risk afterwards.
- Add the Sanad SDK to your app: Android, iOS or web.
- Start the SDK as early as you can, for example on your splash screen or when your app launches, and at the latest before the login screen. Starting it opens a session and sends the device's first signals to Lean straight away, so the first assessment is ready by the time your user logs in.
- Send the
session_idwith the login request. On your backend, get an access token withscope=api, as described in Authentication, then get the session's assessment before you decide on the login. If it shows red flags, add friction, such as an OTP, or block the login. - Once the login succeeds, link the session to your customer. This tells Lean who the user is and turns on the labels that compare the device with the customer's other devices and locations. See Linking customers.
- Before each later sensitive action, such as a payment or a change of payout details, call the SDK's
collect(), so Lean assesses the device as it is at that moment. Your backend already holds thesession_idfrom earlier, so it only needs to read the session's new assessment before it lets the action through.
Check that it works
- Run a debug build of your app on a real device with a sandbox key.
- After the SDK starts, log its
diagnostics(). You should see the stateACTIVE(activeon iOS and web), a session id and no error. - Send that session id to your backend and get its assessment. It reads
PENDINGfor a moment, thenCOMPLETED.
Testing on an emulator or simulatorOn an emulator or simulator, the
emulator_detectedlabel fires, as it should. Use a real device to see a clean assessment.
Updated about 21 hours ago
