> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CrossmintSDK

> Swift Class

**Class**

Entry point for the Crossmint SDK.

```swift theme={null}
@MainActor final class CrossmintSDK
```

Call `configure(apiKey:logLevel:)` once at app startup before accessing `shared`. Accessing `shared` before configuring causes a `fatalError`.
When using an email OTP signer, observe `isOTPRequired` to know when to display an OTP input, then call `submit(otp:)` with the code the user enters.

```swift theme={null}
@main
struct MyApp: App {
    init() {
        CrossmintSDK.configure(apiKey: "ck_development_...", logLevel: .warn)
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(CrossmintSDK.shared)
        }
    }
}
```

## Instance Properties

### authClient

Standalone auth client for explicit OTP lifecycle management. See `AuthClient`.

```swift theme={null}
@MainActor let authClient: AuthClient
```

### authManager

Authentication manager for the email OTP flow. See `CrossmintAuthManager`.

```swift theme={null}
@MainActor let authManager: CrossmintAuthManager
```

### crossmintService

Low-level Crossmint service for direct API access.

```swift theme={null}
@MainActor let crossmintService: CrossmintService
```

### crossmintWallets

Factory for creating and retrieving smart wallets. See `CrossmintWallets`.

```swift theme={null}
@MainActor let crossmintWallets: CrossmintWallets
```

### isOTPRequired

Emits `true` when a pending transaction is waiting for the user to enter an email OTP.

```swift theme={null}
@MainActor var isOTPRequired: Published<Bool>.Publisher { get }
```

### isProductionEnvironment

Whether the SDK is running against the Crossmint production environment.

```swift theme={null}
@MainActor var isProductionEnvironment: Bool { get }
```

## Instance Methods

### cancelTransaction()

Cancels the pending transaction waiting for an OTP.

```swift theme={null}
@MainActor func cancelTransaction()
```

### logout()

Invalidates the server-side refresh token, clears the local session, and resets OTP state.

```swift theme={null}
@MainActor func logout() async
```

### setJWT(\_:)

Sets a JWT for authentication. Use this when authenticating with an externally obtained token rather than through the built-in OTP flow.

```swift theme={null}
@MainActor func setJWT(_ jwt: String) async
```

> **Note**: Unlike the TypeScript SDK’s synchronous `setJwt`, this is `async` because it updates actor-isolated state on `CrossmintAuthManager`.

### submit(otp:)

Provides the OTP entered by the user to unblock the pending transaction.

```swift theme={null}
@MainActor func submit(otp: String)
```

## Type Properties

### shared

The configured SDK instance. Access after calling `configure(apiKey:logLevel:)`.

```swift theme={null}
@MainActor static var shared: CrossmintSDK { get }
```

## Type Methods

### configure(apiKey:logLevel:)

Configures the SDK. Must be called once before accessing `shared`.

```swift theme={null}
@MainActor static func configure(apiKey: String, logLevel: LogLevel = .error)
```

Subsequent calls are silently ignored — the SDK can only be configured once per process.

#### Parameters

* **apiKey**: A client API key (prefixed `ck_`).

* **logLevel**: Controls SDK log verbosity. Defaults to `.error`.
