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

ItemUsed byWhere to find it
SDK keyYour app (Android, iOS or web)The Application Dashboard
Application ID (client_id)Your backendThe Application Dashboard
Client secretYour backend onlyThe 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 backend

Your 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 withEnvironment
lean_device_ae_sandbox_Sandbox
lean_device_ae_Production

Your backend uses the hosts of the same environment:

EnvironmentAuth hostAPI host
Sandboxhttps://auth.sandbox.leantech.mehttps://sandbox.leantech.me
Productionhttps://auth.leantech.mehttps://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.

  1. Add the Sanad SDK to your app: Android, iOS or web.
  2. 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.
  3. Send the session_id with the login request. On your backend, get an access token with scope=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.
  4. 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.
  5. 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 the session_id from earlier, so it only needs to read the session's new assessment before it lets the action through.

Check that it works

  1. Run a debug build of your app on a real device with a sandbox key.
  2. After the SDK starts, log its diagnostics(). You should see the state ACTIVE (active on iOS and web), a session id and no error.
  3. Send that session id to your backend and get its assessment. It reads PENDING for a moment, then COMPLETED.
📘

Testing on an emulator or simulator

On an emulator or simulator, the emulator_detected label fires, as it should. Use a real device to see a clean assessment.


Did this page help you?