Skip to main content

Get started with Ithbat IAM

Add authentication to your app in minutes.


Step 1 — Install

npm install @ithbatiam/sdk

Step 2 — Initialize

import { IthbatSDK } from "@ithbatiam/sdk"

const ithbat = new IthbatSDK({
basePath: "https://api.ithbat.io/api/v1",
tenantId: "YOUR_TENANT_ID"
})

Step 3 — Login

const result = await ithbat.auth.login({
email: "[email protected]",
password: "your-password"
})

if (result.mfaRequired) {
const mfaResult = await ithbat.auth.verifyMfa({
mfaToken: result.mfaToken,
code: "123456"
})
ithbat.setAccessToken(mfaResult.accessToken)
} else {
ithbat.setAccessToken(result.accessToken)
}

When MFA is enabled, result.accessToken is undefined and the response contains mfaRequired: true and mfaToken. Pass the mfaToken plus the user's TOTP code to auth.verifyMfa() to complete login.


Step 4 — Use the API

const result = await ithbat.users.listUsers()
console.log(result.items) // User[]
console.log(result.totalItems) // total count

listUsers() returns a PagedResult<User> with .items (the array of users) and .totalItems (total count across all pages).


Done

You now have working authentication in your app.


What to build next


When to use each integration

IntegrationBest for
SDKFrontend and Node.js apps
REST APIBackend services, any language

API base URL

https://api.ithbat.io/api/v1

Headers required on every protected request:

HeaderValue
AuthorizationBearer <access_token>
X-Tenant-ID<tenant_id>

Need help?