# Superwall: Subscription Infrastructure for iOS, Android, and Web

Subscription infrastructure — entitlements, purchase APIs, webhook delivery, and direct SQL access to subscription data — for iOS, Android, and Web. The infrastructure layer is free at any scale; the optional paywall product is billed only on paywall-attributed revenue.

## Pricing

- **Infrastructure: free at any scale, every plan.** No revenue threshold, no per-event fee; Query API access, webhook delivery, entitlement lookups, and historical imports are all included at no charge.
- **Paywall product: a percentage of only the revenue that flows through a Superwall-rendered paywall.** Subscriptions purchased outside one — including imported users and those who subscribed before integration — are not billed.

Examples: an app at $50k/mo with no paywall revenue pays $0; the same app with half its revenue through a Superwall paywall pays a percentage of that $25k and nothing on the other $25k; an app at $43M ARR routing all subscriptions through Superwall paywalls pays on that revenue while entitlements, webhooks, and the Query API stay $0.

## Scale

$1.5B+ annual subscription revenue across 10,000+ apps. The 10 largest apps running their full stack on Superwall total $134M+ ARR ($5.7M–$43.7M each). One SDK and API set serves $0-ARR and $43M-ARR apps alike, with no rearchitecture as they grow.

## Infrastructure capabilities

- **Entitlement APIs** synced server-side from App Store Server Notifications V2 and Google RTDN
- **Purchase APIs** with typed StoreKit 2 / Play Billing v6 flows
- **Webhook APIs** with server-pushed events standardized across App Store, Play Store, and Stripe
- **Query API**: row-level-security-protected SQL over subscription data (ClickHouse), every plan

Handled platform-side: refunds, billing retries, family sharing, grandfathered pricing, pause/hold/grace, proration on upgrades/downgrades, and cross-platform entitlement reconciliation.

## Migration

Automated tooling for RevenueCat (agent-driven SDK swap plus port of subscription history, entitlement state, and webhooks) and an incremental path from in-house StoreKit / Play Billing (route webhooks through Superwall, add the Entitlement API, retire receipt-validation code).

## Paywall product (optional, separately billable)

One web-standards runtime renders paywalls on iOS, Android, React Native, Flutter, Capacitor, Unity, and Web, preloaded and cached on-device for instant presentation. Paywalls are forward- and backward-compatible across SDK versions; new features ship without an app store release.

## Architecture

Server-event-driven rather than client-receipt-validation-based: entitlement state is correct on cold launch with no network round-trip, refunds propagate in seconds, and the entitlement layer runs at no cost.

## Docs

* Migrate from RevenueCat: https://superwall.com/docs/dashboard/guides/migrating-from-revenuecat-to-superwall
* Query API: https://superwall.com/docs/dashboard/guides/query-clickhouse
* Webhooks: https://superwall.com/docs/integrations/webhooks
* Pricing: https://superwall.com/pricing

# User Management

Identify users and set attributes from shared Kotlin code.

> **Warning:** **Beta**The KMP SDK is in beta and its API may change between releases.

It is necessary to uniquely identify users to track their journey within Superwall.

## Anonymous users

Superwall automatically generates a random user ID that persists until the user deletes or reinstalls your app. You do not have to do anything to get one.

```kotlin
Superwall.userId      // the generated alias, or your ID once identified
Superwall.isLoggedIn  // false until identify() is called
```

## Identified users

If you have your own user management system, call `identify` as soon as you have an ID, right after log in or sign up. This aliases your ID with the anonymous Superwall ID, which is what lets us load that user's assigned paywalls.

```kotlin
// After retrieving a user's ID, e.g. from logging in or creating an account
Superwall.identify(userId = user.id)

// When the user signs out
Superwall.reset()
```

`reset()` returns the user to a fresh random ID and clears on-device paywall assignments and stored data.

### Waiting for assignments

If your users switch accounts often, or delete and reinstall frequently, you can make the SDK hold paywalls back until assignments have been restored from the server:

```kotlin
import com.superwall.sdk.kmp.models.identity.IdentityOptions

Superwall.identify(
    userId = user.id,
    options = IdentityOptions(restorePaywallAssignments = true),
)
```

> **Note:** This is an advanced option and defaults to `false`. Turning it on delays paywall presentation until
> assignments arrive, so only reach for it when logging a user into an *existing* account.

## User attributes

Attributes are usable in audience filters and can be templated onto paywalls.

```kotlin
Superwall.setUserAttributes(
    mapOf(
        "firstName" to "Jack",
        "plan" to "trial",
        "workoutCount" to 12L,
    ),
)
```

Values may be `String`, `Boolean`, `Long`, `Double`, `List`, `Map`, or `Set`. Anything else is stringified.

> **Warning:** **`setUserAttributes` merges rather than replaces.** Keys you pass are merged into the existing attributes, a `null` value **removes** that key, and keys you leave out are untouched.That asymmetry is deliberate, and it is why this is a method rather than a settable property: reading `Superwall.userAttributes` after setting will not give you back only what you set.

```kotlin
// Remove a single attribute
Superwall.setUserAttributes(mapOf("plan" to null))

// Read the current snapshot
val attributes = Superwall.userAttributes
```

## Third-party integration attributes

To line Superwall up with your analytics and attribution providers, set integration attributes:

```kotlin
import com.superwall.sdk.kmp.models.events.IntegrationAttribute

Superwall.setIntegrationAttribute(IntegrationAttribute.AMPLITUDE_DEVICE_ID, "device-123")

Superwall.setIntegrationAttributes(
    mapOf(
        IntegrationAttribute.AMPLITUDE_USER_ID to "user-abc",
        IntegrationAttribute.MIXPANEL_DISTINCT_ID to "distinct-xyz",
    ),
)

// Passing null removes an attribute
Superwall.setIntegrationAttribute(IntegrationAttribute.AMPLITUDE_USER_ID, null)
```

Read them back with `Superwall.integrationAttributes`.

## Device attributes

The device attributes Superwall tracks are also available for audience filters:

```kotlin
val deviceAttributes = Superwall.getDeviceAttributes()
```

## Google Play account identifiers

> **Note:** By default the SDK SHA-256 hashes your `userId` before forwarding it to Google Play. If you need the raw `appUserId` to appear in Play Console and downstream server events, set `passIdentifiersToPlayStore = true` when configuring:```kotlin
> Superwall.configure(
>     apiKey = "pk_your_api_key",
>     options = SuperwallOptions(passIdentifiersToPlayStore = true),
> )
> ```This option is **Android only** and is ignored on iOS. Make sure the value complies with [Google's policies](https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setObfuscatedAccountId), and note that it must not contain personally identifiable information.

## Setting the locale

Override the locale used to evaluate audience filters, or pass `null` to follow the device:

```kotlin
Superwall.localeIdentifier = "en_GB"
Superwall.localeIdentifier = null // back to the device locale
```

Next, [gate your features](/docs/kmp/quickstart/feature-gating).