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

# Quick start

> Launch the verification flow from SwiftUI or UIKit.

Both entry points do the same thing: fetch a token from your backend, build a
`ChmodKycRequest`, present the flow, and handle the outcome.

## SwiftUI

```swift lines theme={null}
import SwiftUI
import ChmodKyc

struct VerificationScreen: View {

    @State private var request: ChmodKycRequest?
    @State private var message: String?

    private let backend = BackendApiClient()

    var body: some View {
        VStack(spacing: 16) {
            Button("Verify my identity") {
                Task { await startVerification() }
            }

            if let message {
                Text(message)
            }
        }
        // While `request` is non-nil the flow is presented full screen.
        // It is cleared for you when the flow ends.
        .chmodKycVerification(request: $request) { result in
            handleVerificationResult(result)
        }
    }

    private func startVerification() async {
        do {
            let token = try await backend.createKycTransaction()
            request = ChmodKycRequest(
                baseURL:  URL(string: "https://api.chmod.com")!,
                sdkToken: token
            )
        } catch {
            message = "We couldn't start the verification. Please try again."
        }
    }

    private func handleVerificationResult(_ result: ChmodKycResult) {
        switch result {
        case .completed:  message = "We're reviewing your document"
        case .cancelled:  message = nil
        case .failed(_, _, let detail): message = detail
        }
    }
}
```

There is also an `isPresented:` variant when you already hold the request:

```swift lines theme={null}
.chmodKycVerification(isPresented: $isVerifying, request: request) { result in
    handle(result)
}
```

## UIKit

```swift lines theme={null}
import UIKit
import ChmodKyc

final class VerificationViewController: UIViewController {

    private let backend = BackendApiClient()

    @objc private func verifyTapped() {
        Task {
            let token = try await backend.createKycTransaction()

            let request = ChmodKycRequest(
                baseURL:  URL(string: "https://api.chmod.com")!,
                sdkToken: token
            )

            // Presents modally, dismisses itself, and returns the outcome
            let result = await ChmodKyc.verify(from: self, request: request)
            handle(result)
        }
    }
}
```

`verify` suspends until the user finishes the flow and the dismissal completes, so the
code after it reads top to bottom.

<Info>
  Cancelling the surrounding task does not dismiss the flow. A verification in progress
  belongs to the user, not to your task tree.
</Info>

If you prefer a completion closure, the same flow is available as:

```swift lines theme={null}
ChmodKyc.present(from: self, request: request) { [weak self] result in
    self?.handle(result)
}
```

Both are `@MainActor`, so you can touch UI directly in either.

## Fetching the token

The token comes from **your** backend, over your own authenticated endpoint. Your app
never talks to chmod to get one:

```swift lines theme={null}
final class BackendApiClient {

    func createKycTransaction() async throws -> String {
        var request = URLRequest(url: URL(string: "https://api.example.com/kyc/start")!)
        request.httpMethod = "POST"
        request.setValue("Bearer \(session.accessToken)", forHTTPHeaderField: "Authorization")

        let (data, response) = try await URLSession.shared.data(for: request)

        guard (response as? HTTPURLResponse)?.statusCode == 200 else {
            throw BackendError.tokenRequestFailed
        }

        return try JSONDecoder().decode(StartResponse.self, from: data).sdkToken
    }
}
```

<Warning>
  Never embed your chmod client id and secret in the app. See [Create transaction](/api-reference/transactions/create-transaction) for the endpoint your backend should expose.
</Warning>

## Adding configuration

Pass a `ChmodKycConfiguration` to control appearance, copy and capture behaviour. Every
field has a default, so `ChmodKycConfiguration()` is valid:

```swift lines theme={null}
let request = ChmodKycRequest(
    baseURL:       url,
    sdkToken:      token,
    configuration: ChmodKycConfiguration(
        appearance:         appearance,
        showsWelcomeScreen: true,
        showsResultScreen:  false
    )
)
```

Full reference in [SDK configuration](/sdk/configuration/overview).

## Next

<Card title="Handling the result" icon="code-branch" href="/sdk/ios/handling-results">
  Every outcome, every error code, and navigating with the result.
</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.