API Reference
Users API
External user (XUser) management — create, query, and the BioXUser model.
The SDK manages external users ("XUsers") that represent the end users of your application. XUsers are created in the AnyBio backend and referenced when starting sessions.
Managing Users via BioSDKClient
// Create a new user
let user = try await sdk.createXUser(
identifier: "user-123",
name: "Jane Doe"
)
// Get or create (idempotent)
let user = try await sdk.getOrCreateXUser(
identifier: "user-123",
name: "Jane Doe"
)
// Look up an existing user
let user = try await sdk.getXUser(identifier: "user-123")XUserHTTPClient
Low-level HTTP client for user operations.
public final class XUserHTTPClient {
public typealias XUserResponse = BioXUser
public func createXUser(_ payload: CreateXUserPayload) async throws -> XUserResponse
public func getOrCreateXUser(_ payload: CreateXUserPayload) async throws -> XUserResponse
public func getXUser(identifier: String, projectKey: String) async throws -> XUserResponse
}CreateXUserPayload
public struct CreateXUserPayload: Codable {
public let identifier: String
public let name: String
public let project_key: String
public init(identifier: String, name: String, project_key: String)
}XUserHTTPClientError
public enum XUserHTTPClientError: Error {
case invalidHTTPResponse
case badStatus(Int)
case decodingFailed
case forbidden
case serverError(Int)
case conflict
case missingApiKey
}BioXUser
The user model returned from the backend.
public struct BioXUser: Codable, Identifiable, Sendable, Equatable, Hashable {
public let id: String
public let organizationId: Int
public let identifier: String
public let name: String
public let genderTypeId: Int?
public let contactPoints: [ContactPoint]
public let birthDate: Date?
public let address: Address?
public let telecom: Telecom?
public let active: Bool
public let projectIds: [Int]
public let totalSessions: Int
public let numDevices: Int
public let dataSentMb: Double
}| Property | Type | Description |
|---|---|---|
id | String | Backend user ID |
organizationId | Int | Organization the user belongs to |
identifier | String | Your application's user identifier |
name | String | Display name |
active | Bool | Whether the user is active |
projectIds | [Int] | Projects the user is enrolled in |
totalSessions | Int | Total recording sessions |
numDevices | Int | Number of registered devices |
dataSentMb | Double | Total data uploaded in MB |
Convenience Properties
public var hasSessions: Bool { get } // totalSessions > 0
public var hasDevices: Bool { get } // numDevices > 0
public var dataSentFormatted: String { get } // Human-readable data sizeNested Types
ContactPoint
public struct ContactPoint: Codable, Sendable {
public let system: String? // e.g., "email", "phone"
public let value: String? // e.g., "jane@example.com"
public let use: String? // e.g., "home", "work"
}Address
public struct Address: Codable, Sendable {
public let line: [String]?
public let city: String?
public let state: String?
public let postalCode: String?
public let country: String?
}Telecom
public struct Telecom: Codable, Sendable {
public let system: String?
public let value: String?
}Content Library
The SDK also provides access to content library entries associated with your project.
ContentLibraryClient
public final class ContentLibraryClient {
public func list(projectId: Int? = nil) async throws -> [BioContentLibraryEntry]
public func get(id: Int) async throws -> BioContentLibraryEntry
}BioContentLibraryEntry
public struct BioContentLibraryEntry: Codable, Identifiable, Equatable, Sendable {
public let id: Int
public let organizationId: Int
public let projectId: Int
public let title: String
public let content: String?
public let author: String?
public let createdAt: Date
public let updatedAt: Date
}ContentLibraryError
public enum ContentLibraryError: Error, LocalizedError {
case invalidHTTPResponse
case badStatus(Int)
case decodingFailed(String)
case forbidden
case notFound
case serverError(Int)
}