Aduki API Reference
Aduki is the entry point of the SDK (pro.aduki.sdk.Aduki).
1. Class Signature & Properties
package pro.aduki.sdk
class Aduki internal constructor(
val apiKey: String = "",
val token: String = "",
val options: Options,
val session: Session = Session(),
val lifecycle: Lifecycle = Lifecycle(),
private val httpClient: OkHttpClient? = null,
manager: Manager? = null,
worker: Worker? = null,
mailRepo: MailRepo? = null,
contactRepo: ContactRepo? = null,
appointmentRepo: AppointmentRepo? = null,
mailboxEngine: MailboxEngine? = null,
contactEngine: ContactEngine? = null,
scheduleEngine: ScheduleEngine? = null,
private val scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO),
private val dpop: Dpop? = null
)
Public Member Properties
| Property | Type | Access | Description |
|---|---|---|---|
apiKey | String | val | Static API key string (if initialized via API key). |
token | String | val | Initial JWT access token string (if initialized via token). |
options | Options | val | Immutable client network and endpoint options. |
session | Session | val | Reactive state repository for active tokens and resolved user identity. |
lifecycle | Lifecycle | val | Application foreground/background lifecycle coordinator. |
mail | Mail | val | Sub-service for message sending, flag updates, moves, and mailbox observations. |
contacts | Contacts | val | Sub-service for address book synchronization, contact retrieval, and substring search. |
sync | Sync | val | Sub-service for CONDSTORE/MODSEQ folder delta sync and outbox flushing. |
scheduling | Scheduling | val | Appointments, services, slots and booking (Scheduling). |
mailApi | Mail (net) | val | Typed REST mail client on the authenticated connection. |
2. Factory & Builder Methods
Aduki.Companion.login
Signs in at Aduki ID for a mail token. See Sign-in.
suspend fun Aduki.Companion.login(
handle: String,
password: String,
code: String? = null,
endpoint: String = Endpoints.REST,
identity: String = Endpoints.ID,
backup: String? = null,
dpop: Key? = null
): Aduki
- Parameters:
handle: Full address, e.g.ada@aduki.me.password: Account password.code/backup: Authenticator code or backup code.dpop: optional device key to bind the session to (DPoP).endpoint: Mail REST base (defaults tohttps://mail.aduki.pro/v1).identity: Aduki ID base (defaults tohttps://id.aduki.pro/v1).
- Return Type:
Aduki— holding the access token, refresh token and session, withIdentityresolved. - Throws:
AdukiException.Unauthorizedon a wrong password or second factor;AdukiException.Networkotherwise.
Aduki.Companion.builder
Creates a fluent Builder instance for custom client configuration.
fun Aduki.Companion.builder(): Aduki.Builder
Builder Methods
class Builder {
fun key(key: String): Builder
fun token(token: String): Builder
fun endpoint(endpoint: String): Builder
fun identity(identity: String): Builder
fun dpop(key: Key): Builder
fun secure(enabled: Boolean): Builder
fun pins(vararg pins: Pin): Builder
fun timeout(seconds: Long): Builder
fun http(client: OkHttpClient): Builder
fun manager(manager: Manager): Builder
fun worker(worker: Worker): Builder
fun mail(repo: MailRepo): Builder
fun contacts(repo: ContactRepo): Builder
fun scheduling(repo: AppointmentRepo, engine: ScheduleEngine? = null): Builder
fun engines(mailbox: MailboxEngine, contact: ContactEngine): Builder
fun build(): Aduki
}
- Validation in
build(): Enforces that at least one ofapiKeyortokenis non-blank (require(apiKey.isNotBlank() || token.isNotBlank())).
3. Session & Lifecycle Methods
me
Resolves and returns the authenticated user and tenant identity profile.
suspend fun me(): Identity?
- Return Type:
Identity?— User ID hex, tenant hex, owner status, scopes, and tier. Returns cached instance fromsession.identity.valueif already resolved; otherwise queriesGET /v1/user. Scopes and tier are not part of that response and stay empty.
totp
Deprecated. Second factors are managed in Aduki ID’s Account Center; mail’s /v1/user/totp is going away.
suspend fun totp(code: String): Boolean
- Parameters:
code: String— the 6-digit code. - Return Type:
Boolean—trueif the server confirms it.
refresh
Renews the access token at Aduki ID (POST /v1/tokens) ahead of time. The SDK also does this by itself on a 401.
suspend fun refresh(): Boolean
- Return Type:
Boolean—trueif tokens were successfully rotated and updated in session state.
logout
Terminates the session remotely and wipes local credentials.
suspend fun logout(): Boolean
- Return Type:
Boolean—trueif Aduki ID revoked the session (DELETE /v1/sessions/{hex}); the local session is then cleared. When revocation fails the session is kept with the rotated refresh token sologout()can be retried (or callsession.clear()). Also stopswatchRights.
rights, watchRights, unwatchRights
Renew the access token on a rights push, or subscribe to the mail event stream that sends them. See Token lifecycle.
suspend fun rights(payload: String): Boolean
fun watchRights(host: String = <REST endpoint without /v1>)
fun unwatchRights()
pause
Notifies the SDK that the host application entered the background (see Lifecycle).
fun pause()
resume
Notifies the SDK that the host application entered the foreground and flushes pending outbox mutations.
fun resume()
4. Complete Sub-Services Index
client.mail (Mail)
suspend fun send(to: List<String>, subject: String, body: String, mailbox: String = "outbox"): Messagesuspend fun flag(hex: String, flag: Int)suspend fun move(hex: String, dest: String)suspend fun remove(hex: String)fun observe(mailboxHex: String): StateFlow<List<Message>>?fun mailboxes(): StateFlow<List<Mailbox>>?fun unread(mailboxHex: String): StateFlow<Int>?
client.contacts (Contacts)
suspend fun sync(tenant: String = ""): Booleanfun observe(): StateFlow<List<Contact>>?fun search(query: String): StateFlow<List<Contact>>?fun get(hex: String): Contact?
client.sync (Sync)
suspend fun all(mailboxes: List<String> = listOf("inbox")): Booleansuspend fun flush(): Intfun pending(): Int