Getting started
Before you start. Solibo issues app and machine clients: write to solibohome@solibo.no as described in Getting credentials. Solibo sets up your client, and the board of each housing community (API: company) approves its access to that community. A service or integration uses a machine client (JVM or Node); an app where people sign in uses an app session (Android, iOS, desktop, CLI). There is no public sandbox: try read-only calls with your own Solibo Home account in Swagger first. Machine clients start with read scopes.
| Session | TypeScript auth.kind | React authMode | Kotlin factory |
|---|---|---|---|
| Machine client: services and integrations | m2m | AuthMode.M2M | SoliboSDK.createM2M |
| App session: Android, iOS, desktop, CLI | mobile | AuthMode.TOKEN | SoliboSDK.createMobile |
| Cookie session: pages Solibo hosts | browser | AuthMode.COOKIE | SoliboSDK.createBrowser |
Kotlin users pick a factory; it sets AuthMode for you. The developer portal shows what each session sends over the wire. The SDK connects to https://api.home.solibo.no by default.
Install
Kotlin (Android, iOS, JVM)
Add the dependency to your module’s build.gradle.kts. In a KMP project, add it to commonMain.dependencies.
repositories {
mavenCentral()
}
dependencies {
implementation("no.solibo.oss:sdk:1.58.0")
}
sdk pulls in no.solibo.oss:sdk-core and every no.solibo.oss:sdk-api-<name> module. Most consumers never name those; a Kotlin service that only needs a few API areas can, see Depending on single API modules.
iOS: the SDK reaches iOS through Kotlin Multiplatform. Add the dependency to a KMP module and call it from Swift through that module’s framework; there is no separate Swift package or CocoaPod.
TypeScript
npm install @solibo/solibo-sdk
The TypeScript package runs in browsers and on Node. createSoliboClient from the package root gives a client with every API domain. A bundle that should carry only the domains it uses builds the client from @solibo/solibo-sdk/core instead and imports each domain it calls from @solibo/solibo-sdk/<domain> (companies, invoicing, …), which registers the domain on the client and exports that domain’s models and enums; see Bundling only the domains you use.
Services and integrations
A service or integration uses a machine client with a client id and secret. Keep the secret on the server. List the housing communities your client can reach, then read one:
import no.solibo.oss.sdk.SoliboSDK
val sdk = SoliboSDK.createM2M(
clientId = "YOUR_CLIENT_ID",
clientSecret = System.getenv("SOLIBO_CLIENT_SECRET"),
)
// Inside a coroutine. The client fetches its token on the first call.
// Needs the read, company:list and company:show scopes. .body() decodes the response;
// the wrapper also carries status and headers.
val page = sdk.api.companies.indexCompany().body()
val first = page.items.firstOrNull() ?: error("No housing community has approved this client yet")
val company = sdk.api.companies.showCompany(companyId = first.id).body()
println(company.name)
import { createSoliboClient } from '@solibo/solibo-sdk'
const sdk = createSoliboClient({
auth: {
kind: 'm2m',
clientId: 'YOUR_CLIENT_ID',
clientSecret: process.env.SOLIBO_CLIENT_SECRET!,
},
})
// In an async function. The client fetches its token on the first call.
// Needs the read, company:list and company:show scopes. Returns the body; throws SoliboApiError.
const page = await sdk.api.companies.indexCompany({})
if (page.items.length === 0) throw new Error('No housing community has approved this client yet')
const company = await sdk.api.companies.showCompany({ companyId: page.items[0].id })
console.log(company.name)
In Kotlin, leave out fields here: a plain string selects the full model, and decoding fails when required fields are missing. Use ProjectionFields instead (see Field projections). Use orgNr to match housing communities to your own records. sdk.api.users.me() (TypeScript: me({})) returns the identity the API sees, a quick check that your credentials work.
Leave scopes out to get everything your client was granted. Passing scopes (for example listOf("read") or ['read']; the solibo-home/ prefix is optional) limits only the scopes in the token itself; scopes Solibo grants your client directly still apply.
A machine client acts as your integration, with the housing communities and scopes granted to it, not as the person using your product. Web products on other domains call the API from their own server this way; browsers on other domains cannot call it directly.
Apps where people sign in
An app session signs a person in and refreshes their tokens for you. Create one SDK instance for your app:
import no.solibo.oss.sdk.SoliboSDK
val sdk = SoliboSDK.createMobile(
userPoolId = "YOUR_USER_POOL_ID",
clientId = "YOUR_CLIENT_ID",
)
See Advanced setup to connect device fingerprinting and push notifications.
import { createSoliboClient } from '@solibo/solibo-sdk'
const sdk = createSoliboClient({
auth: {
kind: 'mobile',
userPoolId: 'YOUR_USER_POOL_ID',
clientId: 'YOUR_CLIENT_ID',
},
})
The user pool id comes with your app client credentials. Complete the authentication flow, including any required password or MFA challenge, then make the same calls as in Services and integrations. See Calling conventions for how parameters and request bodies are passed.
Pages Solibo hosts on solibo.no
A cookie session (kind: 'browser') uses the Solibo Home session cookies. They reach only https://home.solibo.no/api, and only from Solibo-hosted pages whose origin the API allows (home, developers, swagger and async.solibo.no). Set baseUrl: 'https://home.solibo.no' and credentials: 'include' (React: domain: 'home.solibo.no', credentials: 'include'). Pages on other origins cannot call the API at all; call it from your server with a machine client. The client renews the session when the access cookie runs out and sends the request again, so it needs clientId. Tabs share the cookies, so the renewal is taken in turn across the page’s origin: a Web Lock named solibo-session-refresh and a localStorage timestamp (soliboSessionRefreshedAt) let the tabs whose requests run out together send one refresh between them.
import { createSoliboClient } from '@solibo/solibo-sdk'
const sdk = createSoliboClient({
baseUrl: 'https://home.solibo.no', // the client adds /api
auth: {
kind: 'browser',
userPoolId: 'YOUR_USER_POOL_ID',
clientId: 'YOUR_CLIENT_ID',
credentials: 'include',
},
})
React
npm install @solibo/solibo-sdk @solibo/solibo-react @tanstack/react-query
Requires React 19 and TanStack Query 5. Wrap your app once. Import models and client APIs from @solibo/solibo-sdk, and hooks from @solibo/solibo-react.
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AuthMode } from '@solibo/solibo-sdk'
import { SoliboProvider, type CreateSdkArgs } from '@solibo/solibo-react'
const queryClient = new QueryClient()
const config: CreateSdkArgs = {
authMode: AuthMode.COOKIE,
cognitoUserPoolId: 'YOUR_USER_POOL_ID',
clientId: 'YOUR_CLIENT_ID',
domain: 'home.solibo.no',
credentials: 'include',
}
function App() {
return (
<QueryClientProvider client={queryClient}>
<SoliboProvider config={config}>
<YourAppContent />
</SoliboProvider>
</QueryClientProvider>
)
}
SoliboProvider takes the builder options (authMode, cognitoUserPoolId, domain, credentials), which mean the same as auth.kind, userPoolId, baseUrl and credentials in createSoliboClient. The provider rebuilds the client when one of its tracked options changes identity, for example an inline refreshFailureHandler, fingerprinter or scopes array, so define those at module scope or with useMemo. A change to credentials alone is not picked up. Inside a component, useSoliboApi() gives you the configured client (useSdk and SdkProvider are aliases). That client’s api has the domains the bundle imported, which the hooks do for themselves; see Bundling only the domains you use before calling client.api.<domain> directly.
For TanStack Query with another framework, install @solibo/solibo-query and @tanstack/query-core alongside the SDK. See query options.
Next steps
- Usage examples: Read data, make changes, and upload files.
- Documents and attachments: Reuse files and add them to posts.
- Advanced setup: What the client does for you, platform services, and networking.
Depending on single API modules (Kotlin)
The Kotlin client is one Gradle module per API area, so a service that only reads companies and invoices can depend on those modules and leave the rest out of its classpath:
dependencies {
implementation("no.solibo.oss:sdk-api-company:1.40.0")
implementation("no.solibo.oss:sdk-api-invoicing:1.40.0")
}
Each module brings no.solibo.oss:sdk-core with it: HomeApiBase (the client, authentication, devices, the event bus) and the models shared across areas. A module adds its API as an extension property on HomeApiBase, created on first use and shared afterwards:
import no.solibo.oss.sdk.api.HomeApiBase
import no.solibo.oss.sdk.api.companies
import no.solibo.oss.sdk.api.invoicing
suspend fun overview(api: HomeApiBase) {
val company = api.companies.showCompany(companyId = 42)
val plans = api.invoicing.indexInvoicePlans(companyId = 42)
}
no.solibo.oss:sdk is the same client with every area: its HomeApi extends HomeApiBase and has every accessor as a member, so sdk.api.companies needs no import. The modules and the areas they cover are listed in sdk/api/modules.json of the SDK repository; the Auth, app-store, language and unsubscribe operations live in the core, and a few small areas share a module (bank accounts with economy, HMS with routines). All modules carry the SDK’s version, so pin the same version everywhere.
Bundling only the domains you use (TypeScript)
@solibo/solibo-sdk is one package, but its Kotlin/JS output is one ES module per Kotlin file, and the package declares those files free of side effects. A bundler such as webpack or Vite then ships only what a page imports, provided the client itself does not pull every domain in:
import { createSoliboClient } from '@solibo/solibo-sdk/core';
import '@solibo/solibo-sdk/companies';
import { InvoicePlanType } from '@solibo/solibo-sdk/invoicing';
const client = createSoliboClient({ auth: { kind: 'browser', userPoolId, clientId } });
const company = await client.api.companies.showCompany({ companyId: 42 });
const plans = await client.api.invoicing.indexInvoicePlans({ companyId: 42, type: InvoicePlanType.FIXED });
Importing @solibo/solibo-sdk/<domain> registers that domain on every client built from the core entry; a domain nobody imported is undefined on client.api. @solibo/solibo-query and @solibo/solibo-react import the domain each query, mutation or hook uses, and SoliboProvider builds the client it gets as config from the core entry, so an app that goes through them ships only the domains its pages use. Code that calls client.api.<domain> directly imports the domain first, or passes a client from the root createSoliboClient to SoliboProvider as client: the root entry imports and registers every domain. Types come from the package root either way, and a domain’s own models and enums also come from its subpath. Which subpath holds a model follows the backend contract: a model that a second API area starts to use moves to @solibo/solibo-sdk/core in the next release, and the type check tells you where it went.
A domain’s API class carries every operation of the domain, so client.api.invoicing loads all of them and every model they name. Every domain except the core’s (auth, language, appStores, unsubscribe) and accounting also comes one function per operation, from @solibo/solibo-sdk/<domain>/operations. Each function takes the client and the same parameters as the facade method, and a page that imports one loads that operation and the models it names:
import { createSoliboClient } from '@solibo/solibo-sdk/core';
import { indexInvoicingAccounts, InvoicePlanType } from '@solibo/solibo-sdk/invoicing/operations';
const client = createSoliboClient({ auth: { kind: 'browser', userPoolId, clientId } });
const accounts = await indexInvoicingAccounts(client, { companyId: 42 });
The operations entry also carries the domain’s models and enums, and it registers nothing on client.api, so import models from it rather than from @solibo/solibo-sdk/<domain>, which registers the whole API. A test double shaped like a client ({ api: { invoicing: { indexInvoicingAccounts } } }) has its own method called. @solibo/solibo-query uses these functions throughout.
Uploads and integrated documents have functions of their own that take the raw API (client.raw.api), so they work on clients from the core entry, whose raw API has no documents or integratedDocuments member; see Documents.
A client from the core entry reaches the event bus once the bundle imports @solibo/solibo-sdk/events; see Event bus.