# 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

# Query ClickHouse

Use the Superwall API to query your organization's ClickHouse-backed analytics data.

The ClickHouse query API gives you direct SQL access to the same analytics data Superwall uses for charts and campaign results. Use it when you need flexible reporting, internal dashboards, or ad hoc analysis without maintaining a separate data warehouse.

Requests are scoped to your organization and require an organization API key with the `data:read` scope. Superwall provisions a read-only ClickHouse user for your organization on first use, then applies row-level policies so queries only return data for your organization's applications.

> **Warning:** Treat `data:read` keys as sensitive. They can query analytics data for your organization, so create dedicated keys, store them in a secret manager, and revoke them when they are no longer needed.

## Endpoint

Use either `POST` or `GET`:

| Method | Path                                                                 | SQL location          |
| ------ | -------------------------------------------------------------------- | --------------------- |
| `POST` | `https://api.superwall.com/v2/organizations/{organization_id}/query` | Request body          |
| `GET`  | `https://api.superwall.com/v2/organizations/{organization_id}/query` | `query` URL parameter |

`POST` is recommended for most queries because SQL can be long and multiline.

## Authentication

1. Open **Settings > API Keys** in the Superwall dashboard.
2. Create an organization API key.
3. Give the key the `data:read` scope.
4. Copy the token when Superwall shows it.

Pass the token as a bearer token:

```bash
Authorization: Bearer YOUR_SECRET_TOKEN
```

The token must belong to the organization in the path. A key from another organization cannot query this endpoint.

## Send a query

Set your organization ID and API key:

```bash
export SUPERWALL_ORG_ID="123"
export SUPERWALL_API_KEY="sk_..."
```

Run a query with `POST`:

```bash
curl "https://api.superwall.com/v2/organizations/$SUPERWALL_ORG_ID/query" \
  --request POST \
  --header "Authorization: Bearer $SUPERWALL_API_KEY" \
  --data-binary "SELECT count() FROM sw.events_rep"
```

Run a query with `GET`:

```bash
curl --get "https://api.superwall.com/v2/organizations/$SUPERWALL_ORG_ID/query" \
  --header "Authorization: Bearer $SUPERWALL_API_KEY" \
  --data-urlencode "query=SELECT count() FROM sw.events_rep"
```

The response is the raw ClickHouse HTTP response. If you do not specify a format, ClickHouse returns its default text format. Add a `FORMAT` clause when you need JSON:

```bash
curl "https://api.superwall.com/v2/organizations/$SUPERWALL_ORG_ID/query" \
  --request POST \
  --header "Authorization: Bearer $SUPERWALL_API_KEY" \
  --data-binary "
    SELECT
      name,
      count() AS events
    FROM sw.events_rep
    WHERE ts >= now() - INTERVAL 7 DAY
    GROUP BY name
    ORDER BY events DESC
    LIMIT 20
    FORMAT JSONEachRow
  "
```

## Use ClickHouse HTTP options

The endpoint proxies ClickHouse HTTP requests after Superwall authenticates your organization API key. You can pass standard ClickHouse URL parameters, such as `query`, `database`, or `default_format`, through the query string:

```bash
curl --get "https://api.superwall.com/v2/organizations/$SUPERWALL_ORG_ID/query" \
  --header "Authorization: Bearer $SUPERWALL_API_KEY" \
  --data-urlencode "query=SELECT name, count() FROM events_rep GROUP BY name LIMIT 20" \
  --data-urlencode "database=sw" \
  --data-urlencode "default_format=JSONEachRow"
```

Superwall does not expose the generated ClickHouse username and password. Authenticate to the Superwall endpoint with your bearer token instead of connecting directly to the ClickHouse cluster.

## Available tables

Your read-only user can query the analytics tables Superwall exposes for customer reporting:

| Table                                      | Use it for                                                                                                     |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| `sw.events_rep`                            | Raw Superwall events, including event name, metadata, properties, sandbox flag, application ID, and timestamp. |
| `sw.events_hr_agg`                         | Hourly event aggregates.                                                                                       |
| `sw.demand_score_events_rep`               | Demand Score event data.                                                                                       |
| `open_revenue.attributed_events_by_ts_rep` | Revenue and attribution events ordered by event time.                                                          |
| `open_revenue.paywall_open_events_agg`     | Aggregated paywall open events.                                                                                |
| `sw.subscription_status_rep`               | Subscription status records.                                                                                   |
| `sw.user_attributes_rep`                   | User attributes set through the SDK or paywall flows.                                                          |
| `sw.applications_rep`                      | Application metadata available in ClickHouse.                                                                  |

Use ClickHouse introspection queries to inspect columns before writing a production query:

```sql
SHOW TABLES FROM sw;
SHOW TABLES FROM open_revenue;
DESCRIBE TABLE sw.events_rep;
DESCRIBE TABLE open_revenue.attributed_events_by_ts_rep;
```

## Query JSON properties

Some event details are stored in JSON strings such as `props` and `meta`. Use ClickHouse JSON functions to extract them:

```sql
SELECT
  JSONExtractString(props, '$placement_name') AS placement,
  count() AS opens
FROM sw.events_rep
WHERE name = 'paywall_open'
  AND ts >= now() - INTERVAL 30 DAY
GROUP BY placement
ORDER BY opens DESC
LIMIT 20
FORMAT JSONEachRow;
```

## Limits

Queries run as a read-only organization user with ClickHouse settings applied:

| Limit                  | Value       |
| ---------------------- | ----------- |
| Maximum execution time | 300 seconds |
| Maximum threads        | 4           |
| Maximum memory         | 8 GB        |
| Maximum bytes read     | 20 GB       |

If a query times out or uses too much memory, narrow the date range, add filters on `applicationId`, `isSandbox`, or event `name`, and avoid selecting large JSON columns unless you need them.

## Troubleshooting

| Status | What to check                                                                                                            |
| ------ | ------------------------------------------------------------------------------------------------------------------------ |
| `401`  | The request is missing a bearer token, or the token is invalid or revoked.                                               |
| `403`  | The API key does not include the `data:read` scope.                                                                      |
| `404`  | The requested organization resource could not be found.                                                                  |
| `429`  | Too many requests were sent in a short period. Retry later.                                                              |
| `500`  | ClickHouse returned an unexpected error or Superwall could not proxy the request. Check the SQL and try a smaller query. |

## Related

* [Access Controls](/docs/dashboard/dashboard-settings/overview-settings-access-controls)
* [Charts](/docs/dashboard/charts)
* [Superwall Skill](/docs/dashboard/guides/superwall-skill)