Skip to main content

SpendOwlConfiguration

Configuration struct for customizing SDK behavior.
public struct SpendOwlConfiguration: Sendable

Initializer

public init(
    apiKey: String,
    baseURL: URL = URL(string: "https://spendowl.io/api")!,
    timeoutInterval: TimeInterval = 10,
    maxRetries: Int = 3
)

Parameters

apiKey
String
required
Your SpendOwl API key from the dashboard.
baseURL
URL
default:"https://spendowl.io/api"
The API base URL. Only change for testing or if instructed by support.
timeoutInterval
TimeInterval
default:"10"
Network request timeout in seconds.
maxRetries
Int
default:"3"
Maximum retry attempts for failed requests. Client errors (4xx) are not retried.

Properties

apiKey

public let apiKey: String
Your SpendOwl API key.

baseURL

public let baseURL: URL
The base URL for API requests. Default: https://spendowl.io/api

timeoutInterval

public let timeoutInterval: TimeInterval
Network request timeout in seconds. Default: 10
Increase this value if users experience timeout issues on slow networks.

maxRetries

public let maxRetries: Int
Maximum retry attempts for transient failures. Default: 3 Retry Behavior:
  • Network errors are retried with exponential backoff
  • Server errors (5xx) are retried
  • Client errors (4xx) are not retried

Usage Examples

Basic Configuration

For most apps, use the simple API key initializer:
SpendOwl.configure(apiKey: "spendowl_live_xxx")

Custom Timeout

For apps used on slower networks:
let config = SpendOwlConfiguration(
    apiKey: "spendowl_live_xxx",
    timeoutInterval: 30
)
SpendOwl.configure(config)

Aggressive Retries

For critical attribution tracking:
let config = SpendOwlConfiguration(
    apiKey: "spendowl_live_xxx",
    maxRetries: 5
)
SpendOwl.configure(config)

Testing Configuration

For integration tests:
let config = SpendOwlConfiguration(
    apiKey: "spendowl_test_xxx",
    baseURL: URL(string: "https://staging.spendowl.io/api")!,
    timeoutInterval: 5,
    maxRetries: 1
)
SpendOwl.configure(config)

Sendable Conformance

SpendOwlConfiguration conforms to Sendable, making it safe to pass across concurrency boundaries:
Task {
    let config = SpendOwlConfiguration(apiKey: "xxx")
    await MainActor.run {
        SpendOwl.configure(config)
    }
}