# 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

# Events

Reference for custom store events: the endpoint, every event type and field, how retries, ordering and refunds work, and how sandbox and production revenue are counted.

Your server reports every change in your billing system to Superwall as an event. Each accepted event updates the user's entitlements, is delivered to your [webhooks](/docs/integrations/webhooks/v2) and integrations, and counts toward revenue charts.

## Send events

```bash
curl -X POST https://api.superwall.com/v2/custom-stores/$CUSTOM_STORE_ID/events \
  -H "Authorization: Bearer $SUPERWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "event_id": "evt_01J9Y6Q3W0V7",
        "type": "initial_purchase",
        "app_user_id": "user_8812",
        "product_id": "pro_monthly",
        "subscription_id": "sub_4f1c",
        "transaction_id": "inv_9a77",
        "custom_transaction_id": "9f2c1d3e-4b5a-4c6d-8e7f-0a1b2c3d4e5f",
        "environment": "production",
        "occurred_at": "2026-12-01T09:15:02Z",
        "purchased_at": "2026-12-01T09:15:00Z",
        "expires_at": "2027-01-01T09:15:00Z",
        "period_type": "normal",
        "price": { "amount": "9.99", "currency": "USD" }
      }
    ]
  }'
```

* The API key needs the `custom_store_events:write` scope.
* Send 1 to 100 events per request.
* An unknown or misspelled field anywhere in the body fails the whole request with `400`.

The full schema is at [api.superwall.com/docs](https://api.superwall.com/docs) under **Custom Store Events**.

## Event types

| Type                    | When to send it                                                                              | Effect on access                                                | `price`                           |
| ----------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------- |
| `initial_purchase`      | A subscription starts, including a free trial.                                               | Granted until `expires_at`                                      | Required. `"0"` for a free trial. |
| `renewal`               | A new paid period starts. Also a plan change that charges the customer.                      | Extended to `expires_at`                                        | Required                          |
| `product_change`        | The subscription moves to another product without a charge. `product_id` is the new product. | Unchanged                                                       | Not allowed                       |
| `cancellation`          | Auto-renew is turned off.                                                                    | Continues until `expires_at`                                    | Not allowed                       |
| `uncancellation`        | Auto-renew is turned back on before expiry.                                                  | Unchanged                                                       | Not allowed                       |
| `billing_issue`         | A renewal payment failed and is being retried.                                               | Continues until `expires_at`                                    | Not allowed                       |
| `expiration`            | The subscription ended.                                                                      | Ends                                                            | Not allowed                       |
| `refund`                | The current period was refunded in full.                                                     | Ends at once, for good                                          | Required: the refunded amount     |
| `non_renewing_purchase` | A one-time purchase.                                                                         | Granted until `expires_at`, or for life with `expires_at: null` | Required                          |

## Event fields

| Field                   | Required | Description                                                                                                                                                                                                                                              |
| ----------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `event_id`              | Yes      | Your unique ID for this event: 1 to 128 letters, digits, `_`, `-`, `.` or `:`. Superwall never applies the same `event_id` twice. Derive it from your billing system's event ID.                                                                         |
| `type`                  | Yes      | One of the [event types](#event-types).                                                                                                                                                                                                                  |
| `app_user_id`           | Yes      | The user who owns the subscription: the ID your app passes to `Superwall.shared.identify(userId:)`, or the `app_user_id` from the [checkout request](/docs/integrations/custom-stores/checkout-endpoint#the-request). No leading or trailing whitespace. |
| `product_id`            | Yes      | The product's identifier, exactly as you created it on the custom store.                                                                                                                                                                                 |
| `subscription_id`       | Yes      | Your stable ID for the subscription, the same on every renewal. For a `non_renewing_purchase`, the purchase's ID.                                                                                                                                        |
| `transaction_id`        | Yes      | Your ID for this period's charge or invoice.                                                                                                                                                                                                             |
| `environment`           | Yes      | `production`, or `sandbox` for test purchases.                                                                                                                                                                                                           |
| `occurred_at`           | Yes      | When the change happened in your billing system. Decides which event is newest.                                                                                                                                                                          |
| `purchased_at`          | Yes      | Start of the current period.                                                                                                                                                                                                                             |
| `expires_at`            | Yes      | End of the current period. `null` is allowed only on a lifetime `non_renewing_purchase`, an `expiration` and a `refund`.                                                                                                                                 |
| `period_type`           | Yes      | `trial` for a free trial, `intro` for an introductory price, otherwise `normal`.                                                                                                                                                                         |
| `price`                 | By type  | What the customer paid for this period. See [price](#price).                                                                                                                                                                                             |
| `custom_transaction_id` | No       | Links the subscription's revenue to the paywall that sold it. See [paywall attribution](#paywall-attribution).                                                                                                                                           |
| `cancel_reason`         | No       | On `cancellation`, `expiration` and `refund` only: `unsubscribe`, `billing_error`, `developer_initiated`, `price_increase`, `customer_support` or `unknown`.                                                                                             |
| `is_trial_conversion`   | No       | `true` on the `renewal` that turns a free trial into a paid period.                                                                                                                                                                                      |

Timestamps are ISO 8601 with a time zone, such as `2026-12-01T09:15:02Z`. `occurred_at` and `purchased_at` can't be more than five minutes ahead of Superwall's clock, and `expires_at` can't be before `purchased_at`.

### Price

```json
{ "amount": "9.99", "currency": "USD" }
```

* `amount` is a decimal **string** in major units: `"9.99"`, not `999`. It allows up to 9 digits before the point and 6 after.
* `currency` is an uppercase ISO 4217 code. Superwall converts the amount to USD at the exchange rate when the event arrives.
* Report what the customer paid, after discounts and before tax.
* On a `refund`, send the refunded amount as a positive number.

## The response

A `200` has one result per event, in the order you sent them:

```json
{
  "object": "custom_store_event_batch",
  "custom_store_id": "4821",
  "accepted": 1,
  "rejected": 1,
  "results": [
    { "event_id": "evt_01J9Y6Q3W0V7", "status": "accepted" },
    {
      "event_id": "evt_01J9Y6Q3W0V8",
      "status": "rejected",
      "error": {
        "code": "unknown_product",
        "message": "...",
        "param": "events[1].product_id"
      }
    }
  ]
}
```

> **Warning:** A `200` doesn't mean every event was recorded. Check each result's `status`.

### Rejected events

A rejection is always a problem with that event. Fix it before you send it again.

| Code                                              | Meaning                                                                                                  |
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `unknown_product`                                 | No product on this store has that `product_id`.                                                          |
| `product_archived`                                | A new purchase names an archived product. Renewals and other events for existing subscribers still work. |
| `price_required`                                  | The event type needs a `price`.                                                                          |
| `price_not_applicable`                            | The event type doesn't take a `price`.                                                                   |
| `expires_at_required`                             | `expires_at` is `null` on a type that needs a date.                                                      |
| `expires_before_purchase`                         | `expires_at` is before `purchased_at`.                                                                   |
| `occurred_at_in_future`, `purchased_at_in_future` | The timestamp is more than five minutes ahead.                                                           |
| `cancel_reason_not_applicable`                    | The event type doesn't take a `cancel_reason`.                                                           |
| `unsupported_currency`                            | Superwall has no exchange rate for the currency.                                                         |
| `invalid_app_user_id`                             | `app_user_id` is a placeholder such as `null` or `undefined`.                                            |
| `duplicate_event_id`                              | The same `event_id` appears twice in one request.                                                        |

### Request errors

| Status                     | Meaning                                                                                                                | What to do                                |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| `400`                      | The body is malformed: an unknown field, an unknown `type`, a bad timestamp, or an amount that isn't a decimal string. | Fix the request.                          |
| `401`, `403`               | The key is missing, wrong, or lacks the `custom_store_events:write` scope.                                             | Fix the key, then send again.             |
| `404`                      | The key can't see a custom store with that ID.                                                                         | Check the store ID and the key's project. |
| `409`                      | The store is fed by RevenueCat Billing, which reports its subscriptions.                                               | Don't send events to this store.          |
| `429`                      | Rate limited, per custom store.                                                                                        | Wait for `Retry-After`, then send again.  |
| `500`, `503`, or a timeout | Nothing was recorded.                                                                                                  | Send the same batch again, unchanged.     |

Superwall answers within 20 seconds.

## Rules

### Retries are safe

`event_id` is an idempotency key, scoped to the store. When a request fails or times out, send the same batch again with the same body.

Never send an `event_id` again with a different body. It isn't refused, but analytics may keep either version and can count it twice. To correct a mistake, send a new event.

### Order doesn't matter

Events can arrive in any order. Superwall orders them by `occurred_at`, so a late `renewal` never overwrites a newer `cancellation`. This only works if `occurred_at` is when the change happened, not when you sent the request.

### A refund is final

A `refund` ends the subscription at once, and no later event restores that `subscription_id`.

* Cancel the subscription in your billing system too, so the customer isn't billed again.
* A customer who subscribes again needs a new `subscription_id`.
* Partial refunds aren't supported. Don't report them.

### Access ends at `expires_at`

Superwall has no grace period for custom stores. When `expires_at` passes without a `renewal`, access ends, even during a `billing_issue`. If you give customers extra time while a payment retries, send that later date as `expires_at`.

### One reporter per subscription

Report only purchases that no other integration reports. A subscription that the App Store, Google Play, Stripe or RevenueCat integration also reports counts its revenue twice.

## Sandbox and production

Send test purchases with `environment: "sandbox"`. They grant access like production events. Revenue charts show them only when you filter to the **Sandbox** environment.

The store's first accepted `production` event sets its `reporting_since` to the time that request arrived. From then on, revenue charts count this store's purchases from your server's events only, and ignore what the SDK reported about them, so nothing is counted twice.

If you later send events from before that time, such as a backfill of existing subscribers, move `reporting_since` back to the start of the backfill. Click **Edit** next to the store's status in the dashboard, or use the API:

```bash
curl -X PATCH https://api.superwall.com/v2/projects/$PROJECT_ID/custom-stores/$CUSTOM_STORE_ID \
  -H "Authorization: Bearer $SUPERWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reporting_since": "2026-06-01T00:00:00Z"}'
```

Once `reporting_since` is set, it can be moved but not cleared, and the store can't be deleted. This keeps its revenue history intact.

## Paywall attribution

`custom_transaction_id` credits a subscription's revenue, renewals included, to the paywall, campaign and experiment that sold it. Without it, the revenue still counts but isn't attributed to a paywall.

Where the value comes from:

* With a [checkout endpoint](/docs/integrations/custom-stores/checkout-endpoint), Superwall sends it in the `checkout.create` request.
* With a `PurchaseController`, read `StoreProduct.customTransactionId` from the product the SDK passes to your purchase method. It's available in the iOS SDK 4.19.0 and later and the Android SDK 2.8.0 and later.

Store it in your checkout's metadata, and send it back on the `initial_purchase` or `non_renewing_purchase`. Once is enough, within 14 days of the purchase on the paywall. With a checkout endpoint, the paywall also waits for this value before it closes as purchased.