Custom Stores

Quickstart

Create a custom store and a product, then grant a test user access by sending one sandbox purchase event with curl.

This page sets up a custom store and proves it works with a single request. You don't need a server or a billing system yet. At the end, a test user holds an entitlement that your app can see.

1. Create a store

In the dashboard, go to Integrations › Custom stores and click Create custom store. Name it after your billing system, such as Paddle.

Or use the Superwall API with a key that has the custom_stores:write scope:

curl -X POST https://api.superwall.com/v2/projects/$PROJECT_ID/custom-stores \
  -H "Authorization: Bearer $SUPERWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Paddle"}'

The response's id is the custom store ID. You need it to send events.

2. Add a product

On the store's page, click Add product. Add one product for each plan you sell, and attach each to an entitlement, such as pro.

  • The identifier is what your server sends as product_id. Pick one you can map from your billing system, such as pro_monthly. It must be unique across all of the project's custom stores.
  • The price, period and trial are what the paywall shows. Match them to the plan in your billing system.

Through the API, this needs a key with the products:write scope. The price is in the smallest currency unit, so 999 is $9.99:

curl -X POST https://api.superwall.com/v2/products \
  -H "Authorization: Bearer $SUPERWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "'"$PROJECT_ID"'",
    "store": "custom",
    "application_id": "'"$CUSTOM_STORE_ID"'",
    "identifier": "pro_monthly",
    "name": "Pro Monthly",
    "price": { "amount": 999, "currency": "USD" },
    "subscription": { "period": "month", "trial_period_days": 7 },
    "entitlements": ["'"$ENTITLEMENT_ID"'"]
  }'

3. Create an API key for your server

On the store's page, under Connect your server, click Create API key. It opens Settings › API Keys with only the custom_store_events:write scope selected. Restrict the key to this project.

This key can only send events, so keep it separate from keys that manage your project. Store it on your server as SUPERWALL_API_KEY.

4. Send a test purchase

The store's page shows this request under Send a test purchase, filled in with your store ID, a product and the current time. Copy it from there, or run this:

NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)

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_test_1",
        "type": "initial_purchase",
        "app_user_id": "user_123",
        "product_id": "pro_monthly",
        "subscription_id": "sub_test_1",
        "transaction_id": "txn_test_1",
        "environment": "sandbox",
        "occurred_at": "'"$NOW"'",
        "purchased_at": "'"$NOW"'",
        "expires_at": "2030-01-01T00:00:00Z",
        "period_type": "normal",
        "price": { "amount": "9.99", "currency": "USD" }
      }
    ]
  }'

A 200 response lists one result per event:

{
  "object": "custom_store_event_batch",
  "custom_store_id": "4821",
  "accepted": 1,
  "rejected": 0,
  "results": [{ "event_id": "evt_test_1", "status": "accepted" }]
}

If the result says rejected, its error.code and error.param name the problem. See error codes.

The event's price is a decimal string in major units ("9.99"). The product's price in step 2 is an integer in the smallest unit (999). They're two different APIs.

5. See the entitlement

user_123 now holds the product's entitlement. Check it in either place:

  • In your app: identify as the same user. The SDK fetches the user's entitlements from Superwall, and a paywall gated on that entitlement no longer shows.

    Superwall.shared.identify(userId: "user_123")
  • With the Superwall CLI:

    superwall users entitlements user_123 --app <app>

    Once the user has opened your app, their page under Users in the dashboard lists the same entitlements.

Sandbox events grant access like production events. Revenue charts show them only when you filter to the Sandbox environment.

6. End the test subscription

Send an expiration for the same subscription_id, with a new event_id. It carries no price:

NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)

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_test_2",
        "type": "expiration",
        "app_user_id": "user_123",
        "product_id": "pro_monthly",
        "subscription_id": "sub_test_1",
        "transaction_id": "txn_test_1",
        "environment": "sandbox",
        "occurred_at": "'"$NOW"'",
        "purchased_at": "'"$NOW"'",
        "expires_at": null,
        "period_type": "normal"
      }
    ]
  }'

The user loses the entitlement. The app picks that up the next time it refreshes entitlements, such as when it comes to the foreground.

Next steps

You've done by hand what your server will do for every purchase. Now automate it:

  1. Build the server that creates checkouts and forwards your billing system's webhooks.
  2. Add the product to a paywall, like any other product.
  3. Set up your app: iOS or Android.

How is this guide?

On this page