AnyBio
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
}
PropertyTypeDescription
idStringBackend user ID
organizationIdIntOrganization the user belongs to
identifierStringYour application's user identifier
nameStringDisplay name
activeBoolWhether the user is active
projectIds[Int]Projects the user is enrolled in
totalSessionsIntTotal recording sessions
numDevicesIntNumber of registered devices
dataSentMbDoubleTotal 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 size

Nested 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)
}

On this page