Custom Stores

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 and integrations, and counts toward revenue charts.

Send events

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 under Custom Store Events.

Event types

TypeWhen to send itEffect on accessprice
initial_purchaseA subscription starts, including a free trial.Granted until expires_atRequired. "0" for a free trial.
renewalA new paid period starts. Also a plan change that charges the customer.Extended to expires_atRequired
product_changeThe subscription moves to another product without a charge. product_id is the new product.UnchangedNot allowed
cancellationAuto-renew is turned off.Continues until expires_atNot allowed
uncancellationAuto-renew is turned back on before expiry.UnchangedNot allowed
billing_issueA renewal payment failed and is being retried.Continues until expires_atNot allowed
expirationThe subscription ended.EndsNot allowed
refundThe current period was refunded in full.Ends at once, for goodRequired: the refunded amount
non_renewing_purchaseA one-time purchase.Granted until expires_at, or for life with expires_at: nullRequired

Event fields

FieldRequiredDescription
event_idYesYour 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.
typeYesOne of the event types.
app_user_idYesThe user who owns the subscription: the ID your app passes to Superwall.shared.identify(userId:), or the app_user_id from the checkout request. No leading or trailing whitespace.
product_idYesThe product's identifier, exactly as you created it on the custom store.
subscription_idYesYour stable ID for the subscription, the same on every renewal. For a non_renewing_purchase, the purchase's ID.
transaction_idYesYour ID for this period's charge or invoice.
environmentYesproduction, or sandbox for test purchases.
occurred_atYesWhen the change happened in your billing system. Decides which event is newest.
purchased_atYesStart of the current period.
expires_atYesEnd of the current period. null is allowed only on a lifetime non_renewing_purchase, an expiration and a refund.
period_typeYestrial for a free trial, intro for an introductory price, otherwise normal.
priceBy typeWhat the customer paid for this period. See price.
custom_transaction_idNoLinks the subscription's revenue to the paywall that sold it. See paywall attribution.
cancel_reasonNoOn cancellation, expiration and refund only: unsubscribe, billing_error, developer_initiated, price_increase, customer_support or unknown.
is_trial_conversionNotrue 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

{ "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:

{
  "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"
      }
    }
  ]
}

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.

CodeMeaning
unknown_productNo product on this store has that product_id.
product_archivedA new purchase names an archived product. Renewals and other events for existing subscribers still work.
price_requiredThe event type needs a price.
price_not_applicableThe event type doesn't take a price.
expires_at_requiredexpires_at is null on a type that needs a date.
expires_before_purchaseexpires_at is before purchased_at.
occurred_at_in_future, purchased_at_in_futureThe timestamp is more than five minutes ahead.
cancel_reason_not_applicableThe event type doesn't take a cancel_reason.
unsupported_currencySuperwall has no exchange rate for the currency.
invalid_app_user_idapp_user_id is a placeholder such as null or undefined.
duplicate_event_idThe same event_id appears twice in one request.

Request errors

StatusMeaningWhat to do
400The 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, 403The key is missing, wrong, or lacks the custom_store_events:write scope.Fix the key, then send again.
404The key can't see a custom store with that ID.Check the store ID and the key's project.
409The store is fed by RevenueCat Billing, which reports its subscriptions.Don't send events to this store.
429Rate limited, per custom store.Wait for Retry-After, then send again.
500, 503, or a timeoutNothing 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:

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, 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.

How is this guide?

On this page