Shop API
Browse your game's shop catalog from within your H5 game. The catalog is defined in your game's server config and uploaded via the existing server config pipeline.
Overview
The shop system uses your game's server config as the source of truth:
Define your shop catalog in
rundot/shop.config.jsonUpload it with
rundot game upload-server-config. This prints the new config'sId— note it for the next step.Point a release at that config so the storefront can resolve it:
rundot game update-release public --server-config-id <id>. Uploading alone is not enough — the storefront reads thepublicrelease, so a config that no release references returns404.The SDK reads the catalog at runtime via
RundotGameAPI.shop
Each config upload creates a new immutable version. The storefront response includes a configId that pins the catalog to a specific version.
In Playground the shop resolves the private release that the dev server's config upload repoints, so your local rundot/shop.config.json is what you see — and purchases are real on the target environment (persistent orders, wallet debits, entitlement grants).
Publishing a live game? Use the
rundot deployflow instead of pointingpublicby hand.deployuploads your server config and lands it on a staging/in-review release; it's promoted to thepublicrelease through the normal review/approval step.rundot game update-releaseis the manual override, handy while developing and testing.
Config Structure
Recommended: rundot/shop.config.json
Place your shop config at rundot/shop.config.json. The file contains the shop configuration directly (no shop wrapping key):
{
"items": [
{
"itemId": "speed_boost",
"name": "Speed Boost",
"description": "Double movement speed for 60 seconds",
"category": "consumable",
"price": { "type": "bucks", "value": "100" },
"entitlements": [
{ "entitlementId": "speed_boost_effect", "quantity": 1, "consumable": true }
],
"assets": { "icon": "speed_icon.png" },
"unique": false,
"active": true,
"regions": [],
"refundEligible": true,
"refundWindowHours": 24,
"tags": ["boost"],
"sortOrder": 1,
"releasedAt": null,
"expiresAt": null
}
],
"sales": [
{
"saleId": "launch_sale",
"targetId": "speed_boost",
"discountType": "percentage",
"discountValue": 25,
"regions": [],
"startsAt": 0,
"endsAt": 4102444800000,
"active": true
},
{
"saleId": "episode_sale",
"targetId": "episodes",
"targetType": "collection",
"discountType": "percentage",
"discountValue": 20,
"regions": [],
"startsAt": 0,
"endsAt": 4102444800000,
"active": true,
"itemFilter": { "tags": ["premium"] }
}
],
"collections": [
{
"collectionId": "episodes",
"price": { "type": "bucks", "value": "50" },
"entitlement": { "consumable": false },
"refundEligible": true,
"refundWindowHours": 24,
"items": [
{
"itemId": "ep-premium-1",
"tags": ["premium"],
"priceOverride": { "type": "bucks", "value": "100" }
}
]
}
]
}Commit
rundot/to your repo: it's project config likepackage.json, not a build artifact. It's env-agnostic and takes priority over legacyconfig.{local,staging}.jsonfor any system it defines.game.config.prod.jsonis a separate file for local CLI metadata (gameId,relativePathToDistFolder); shop config does not go there.
Also supported: legacy config.json
Add a shop key to your project's config.json (alongside simulation, etc.). Legacy layouts keep working indefinitely; run rundot migrate-config (with --dry-run to preview) to move them into rundot/ automatically.
Item Fields
itemId
string
Yes
-
Unique identifier within the game
name
string
Yes
-
Display name
description
string
Yes
-
Display description
category
enum
Yes
-
consumable, non_consumable, or time_bound
price
object
Yes
-
{ type, value }: see Price Structure
entitlements
array
Yes
-
What the player receives: see Entitlements
assets
object
No
{}
{ thumbnail?, banner?, icon? }: image identifiers
unique
boolean
No
false
If true, player can only own one
active
boolean
No
false
Whether the item is visible/purchasable
regions
string[]
No
[]
Region codes; empty = all regions
refundEligible
boolean
No
true
Whether refunds are allowed
refundWindowHours
number
No
24
Hours after purchase to allow refund
tags
string[]
No
[]
Arbitrary tags for filtering
sortOrder
number
No
0
Display sort order
releasedAt
number
No
null
Release timestamp (ms since epoch)
expiresAt
number
No
null
Expiry timestamp (ms since epoch)
Sale Fields
Sales are separate objects that reference items or collections by ID. Items don't need modification to go on sale, and multiple sales can be scheduled in advance.
saleId
string
Yes
Unique identifier for the sale
targetId
string
Yes
itemId (when targeting items) or collectionId (when targeting collections)
targetType
enum
No
item (default) or collection
discountType
enum
Yes
percentage or fixed_price
discountValue
number
Yes
Percentage (0–100) when discountType is percentage
discountPrice
object
No
Override price { type, value } when discountType is fixed_price
regions
string[]
No
Region codes; empty = all regions
startsAt
number
Yes
Start timestamp (ms since epoch)
endsAt
number
Yes
End timestamp (ms since epoch)
active
boolean
Yes
Whether the sale is active
itemFilter
object
No
Only for collection sales. Narrows which items the sale applies to: { tags?: string[], itemIds?: string[] }
When targetType is collection, the sale applies to all items in the collection by default. Use itemFilter to narrow it, for example, { "tags": ["premium"] } only discounts items whose override entry has the "premium" tag. Items without overrides (or without matching tags) are unaffected by filtered sales.
Price Structure
bucks
RUN Bits (platform hard currency). value is the amount.
direct_purchase
Real money, charged through the player's app store. value is a platform price-tier id.
Selling for real money
Pin the item to a platform price tier. value is a tier id — not a dollar amount, and not a store product id:
Then deploy it the same way as any other shop item:
…and point a tag at that config. That is the whole setup. The entitlements array is the grant, exactly as it is for a bucks item — there is no second record to create and no admin call to make.
RUN owns the price ladder. Each rung (tier_099, tier_499, …) carries the App Store, Play, Stripe, and Steam products for that price, and those products are shared across games. Games cannot invent a price, because a game cannot create an App Store product. Pin ids are listed in these docs; the full ladder (GET /v1/direct-purchase/tiers) is admin-only because it contains every store product id.
File-Only Configuration (Zero Dashboard Setup)
No Store Dashboards: Developers do not configure products or SKUs on platforms like Google Play or the App Store. File configuration in
rundot/shop.config.jsonis all that is necessary. RUN operates a universal platform price ladder where all store products are pre-provisioned and shared across all games.Supported Storefronts: Every standard price tier is live across Web, iOS, and Android, plus Steam. Web checkout is live out of the box with zero extra setup.
Sandbox Testing: In Playground and preview environments, direct purchases operate in sandbox mode, allowing you to test checkout, order completion, and entitlement grants end-to-end without real charges.
Standard Platform Price Ladder
tier_099
$0.99
Web, iOS, Android, Steam
tier_199
$1.99
Web, iOS, Android, Steam
tier_299
$2.99
Web, iOS, Android, Steam
tier_399
$3.99
Web, iOS, Android, Steam
tier_499
$4.99
Web, iOS, Android, Steam
tier_599
$5.99
Web, iOS, Android, Steam
tier_699
$6.99
Web, iOS, Android, Steam
tier_799
$7.99
Web, iOS, Android, Steam
tier_899
$8.99
Web, iOS, Android, Steam
tier_999
$9.99
Web, iOS, Android, Steam
tier_1099
$10.99
Web, iOS, Android, Steam
tier_1199
$11.99
Web, iOS, Android, Steam
tier_1299
$12.99
Web, iOS, Android, Steam
tier_1399
$13.99
Web, iOS, Android, Steam
tier_1499
$14.99
Web, iOS, Android, Steam
tier_1599
$15.99
Web, iOS, Android, Steam
tier_1699
$16.99
Web, iOS, Android, Steam
tier_1799
$17.99
Web, iOS, Android, Steam
tier_1899
$18.99
Web, iOS, Android, Steam
tier_1999
$19.99
Web, iOS, Android, Steam
tier_2099
$20.99
Web, iOS, Android, Steam
tier_2199
$21.99
Web, iOS, Android, Steam
tier_2299
$22.99
Web, iOS, Android, Steam
tier_2399
$23.99
Web, iOS, Android, Steam
tier_2499
$24.99
Web, iOS, Android, Steam
tier_2599
$25.99
Web, iOS, Android, Steam
tier_2699
$26.99
Web, iOS, Android, Steam
tier_2799
$27.99
Web, iOS, Android, Steam
tier_2899
$28.99
Web, iOS, Android, Steam
tier_2999
$29.99
Web, iOS, Android, Steam
tier_3499
$34.99
Web, iOS, Android, Steam
tier_3999
$39.99
Web, iOS, Android, Steam
tier_4499
$44.99
Web, iOS, Android, Steam
tier_4999
$49.99
Web, iOS, Android, Steam
tier_5499
$54.99
Web, iOS, Android, Steam
tier_5999
$59.99
Web, iOS, Android, Steam
tier_6499
$64.99
Web, iOS, Android, Steam
tier_6999
$69.99
Web, iOS, Android, Steam
tier_7499
$74.99
Web, iOS, Android, Steam
tier_7999
$79.99
Web, iOS, Android, Steam
tier_8499
$84.99
Web, iOS, Android, Steam
tier_8999
$89.99
Web, iOS, Android, Steam
tier_9499
$94.99
Web, iOS, Android, Steam
tier_9999
$99.99
Web, iOS, Android, Steam
Real-World Example: In-Game Currency Packs
To sell in-game currency packs directly for real money (as done in Teahouse for Leaves packs), configure consumable items pinned to the ladder rungs:
The game client calls RundotGameAPI.shop.getCatalog() to display the packs and RundotGameAPI.shop.purchase(itemId, idempotencyKey) to trigger checkout. Once completed, the player receives the granted entitlements.
The checkout lease is per player per tier, across games. Because the store products are shared, two games must not run parallel $4.99 checkouts for one player. Two items in your own game on the same tier share it too. An abandoned lease expires after 10 minutes, and a cancelled checkout releases it at once.
The order's directPurchase block
For a direct_purchase item the order does not complete in one call. purchase() returns an order carrying a directPurchase block, the host runs store checkout, and the order reaches fulfilled only after the charge is verified server-side:
sku
string
The price-tier id the order is pinned to
provider
string | null
revenuecat or steam; null until checkout binds one
transactionId
string | null
Provider transaction id; null until checkout binds one
storePrices
array
The tier's store products, snapshotted at order create so a ladder edit mid-checkout cannot strand a paid player
storePrices is written by every order created since the price-tier pin shipped. An older order that lacks it cannot be resolved safely — the ladder may have moved since it was created — so confirm and recover both reject it with direct-purchase-legacy-order rather than guess. That is a support case, not a client retry.
Direct purchases are unavailable on channels without purchase support, where purchase() rejects with direct-purchase-unavailable. A player dismissing the store sheet surfaces as USER_CANCELLED.
If a previous attempt reached the store and the host cannot yet tell whether the charge landed, purchase() rejects with direct-purchase-pending rather than opening a second checkout. Treat it as retryable: surface "your purchase is still being confirmed" and let the player try again shortly. It resolves itself once the charge becomes visible (the order then completes without charging again) or once enough time has passed to prove no charge happened.
Reuse the same
idempotencyKeywhen you retry a direct purchase. This is a correctness requirement, not an optimisation. Real money is charged against the order, and the host's protection against charging twice — the stored receipt, the bound Steam order, the reclaim of a charge that landed during a crash — is all keyed to theorderIdthe key produced. A fresh key on retry is a different order with none of that history, so the player is charged again. Generate the key once per intended purchase and hold it until the call resolves or definitively fails:A unique (non-consumable) item is partly self-protecting: the server resumes its existing pending order, and the app stores reject a second purchase of something already owned. Consumable direct-purchase items have neither safeguard — a stable key is the only thing standing between a retry and a second charge.
Entitlements
Each item must specify what the player receives on purchase:
entitlementId
string
Yes
ID of the entitlement to grant
quantity
number
Yes
How many to grant (must be > 0)
consumable
boolean
Yes
Whether this is consumed on use
durationDays
number
No
For time-bound items, how long it lasts
Categories
consumable
Used up on use (e.g., potions, boosts)
non_consumable
Permanent ownership (e.g., skins, characters)
time_bound
Expires after a duration (e.g., subscriptions, passes)
Collections
Collections let you sell large catalogs (episodes, chapters, level packs) without listing every item in the config. A collection defines shared defaults (price, entitlement shape, refund policy) and the server trusts the client to know what items exist.
Any (collectionId, itemId) pair is valid. Items without an override entry use the collection's defaults. Only items that deviate from defaults need to be listed.
Collection Fields
collectionId
string
Yes
Unique identifier for the collection
price
object
Yes
Default price { type, value } for all items
entitlement
object
Yes
{ consumable: boolean, durationDays?: number }
refundEligible
boolean
Yes
Default refund policy
refundWindowHours
number
Yes
Default refund window
items
array
No
Item overrides: only items that deviate from defaults
Item Override Fields
itemId
string
Yes
The item being overridden
tags
string[]
No
Tags for sale targeting
priceOverride
object
No
Override price { type, value }
refundEligibleOverride
boolean
No
Override refund eligibility
refundWindowHoursOverride
number
No
Override refund window
Entitlement Mapping
Collection entitlements are derived automatically: the entitlement ID is ${collectionId}_${itemId}, quantity is 1, and consumable/durationDays come from the collection config. No per-item entitlement configuration is needed.
Non-consumable collection items are treated as unique: a player cannot purchase the same item twice.
SDK Usage
Get Catalog
Fetch the full storefront. Returns all items with sale-resolved prices and a configId for version pinning.
By default the catalog excludes inactive, expired, and unreleased items. Pass the optional boolean flags to include them, for example when building an admin or preview view:
includeInactive
boolean
false
Include items where active is false
includeExpired
boolean
false
Include items past their expiresAt
includeUnreleased
boolean
false
Include items whose releasedAt is in the future
Get Item Detail
Fetch a single item by ID with its resolved price.
StorefrontResponse
Resolve Collection Item Price
The storefront includes collection info with pre-resolved pricing. Use resolveCollectionItemPrice to look up the price for any item in a collection locally, with no server round-trip needed.
This is a pure helper function, not a method on RundotGameAPI.shop. Import it directly from the package:
It takes the storefront response plus a (collectionId, itemId) pair and returns the item's resolved price (the override's resolvedPrice if the item has one, otherwise the collection's resolvedDefaults). It returns null if the collection is not in the storefront.
storefront
StorefrontResponse
The response from getCatalog()
collectionId
string
The collection to look in
itemId
string
The item within the collection
Returns StorefrontCollection['resolvedDefaults'] | null.
Purchase Collection Item
Buy an item from a collection. Like regular purchases, pass an idempotencyKey to prevent duplicates.
Purchase
Buy an item. Pass an idempotencyKey (for example crypto.randomUUID()) to prevent duplicate charges on retry — generate it once per intended purchase and reuse that same value on every retry. For direct_purchase items this is a hard requirement.
Always check success before granting. purchase() resolves with one of two shapes:
success
cancelled
order
Meaning
true
absent
ShopOrder
Purchase completed. Grant the item.
false
true
null
The player dismissed the top-up paywall. Nothing charged, no order.
On RUN app web and native hosts, insufficient funds automatically opens the currency purchase flow. After a completed top-up, the host retries the original Shop order once with the same idempotency key. Dismissing the top-up resolves with { success: false, cancelled: true, order: null } — a closed paywall is a player choice, not a failure, so it does not reject and should not surface error copy. A completed top-up that still does not cover the order rejects with insufficient_funds. The Playground HTTP host instead surfaces insufficient_funds directly so you can fund the test wallet with RundotGameAPI.iap.openStore().
Rejections are reserved for genuine failures: stale catalog, still-insufficient funds after a top-up, and network/transport errors. If you are on an SDK older than the version that introduced the resolved cancel result, a dismissed paywall instead rejects with a RundotApiError whose code is USER_CANCELLED — rebuild your game against the current SDK to get the resolved shape.
If the catalog has been updated since the player last fetched it, the SDK throws a stale catalog error: re-fetch the catalog and retry.
Get Order
Retrieve a specific order by ID.
Get Order History
Retrieve recent orders for the current game.
Request Refund
Refund a recent purchase. The player gets their currency back and the entitlements are removed.
Refund reason codes: changed_mind, accidental_purchase, not_as_expected, technical_issue, other
Refund constraints:
The item must have
refundEligible: truein the configThe request must be within
refundWindowHoursof the purchaseConsumable entitlements must not have been used (quantity must equal what was originally granted)
Non-refundable items (e.g.,
refundEligible: false) are always rejected
Client-Side Analytics Events
The platform automatically tracks server-side analytics for purchases (shop_purchase), failed purchases (shop_purchase_failed), and refunds (shop_refund).
For client-side shop analytics, send the following events via RundotGameAPI.analytics.logEvent():
shop_item_viewed
Player views an item detail page
item_id, item_name, item_category, price
shop_item_click_purchase
Player taps the purchase button
item_id, item_name, price
shop_item_cancel_purchase
Player cancels/dismisses the purchase confirmation
item_id, item_name, price
shop_item_view_duration
Player leaves an item detail page
item_id, duration_ms
Type Reference
StorefrontItem
directPurchase: usedisplayPricewhen the store supplies a localized string, andnominalUsdas the fallback. An item whose pin names no tier is omitted from the storefront entirely, so anything you receive is buyable.Percentage sales cannot apply to a
direct_purchaseprice — there is no number to discount. Use afixed_pricesale whosediscountPricenames a cheapertierId.
StorefrontCollection
resolvedDefaults: the collection's default price with any collection-wide sales applied. Use this for items without overrides.items: only items with overrides are listed, each with its ownresolvedPrice. The element type is the named, importableStorefrontCollectionItem({ itemId, resolvedPrice }).
ShopOrder
ShopPurchaseResponse
The return type of getOrder() and requestRefund(), and the success arm of ShopPurchaseResult. The order is always present.
ShopPurchaseResult
What purchase() and purchaseCollectionItem() resolve to. Narrow on success (or cancelled) before touching order — TypeScript will not let you read order.orderId until you do.
ShopOrderHistoryResponse
The return type of getOrderHistory(). The orders live under orders; success reports whether the lookup succeeded.
Last updated