Server-Side API Objects in Adapty | Adapty Docs

API objects

Adapty API has JSON objects so you can understand a response structure and wrap it into your code.

All datetime values are ISO 8601, for example, “2020-01-15T15:10:36.517975+0000”.

Access level

Info about customer’s access level.

Access levels let you control what your app’s users can do in your mobile app without hardcoding specific product IDs. Each product defines how long the user gets a certain access level. So, whenever a user makes a purchase, Adapty grants access to the app for a specific period (for subscriptions) or forever (for lifetime purchases). Alternatively, you can grant specific access for a specified time to a user via server-side API.

You can do the following action via Adapty server-side API:

参数类型必填可为空描述
access_level_idString在 Adapty 看板中设置的付费访问等级 ID。
storeString购买产品的应用商店。可选值:app_storeplay_storestripe,或您的自定义商店名称。
store_product_idString解锁该访问等级的产品在应用商店(如 App Store、Google Play、Stripe)中的 ID。
store_base_plan_idStringGoogle Play 中的基础方案 ID 或 Stripe 中的价格 ID
store_transaction_idString应用商店(App Store、Google Play、Stripe 等)中的交易 ID。
store_original_transaction_idString

对于订阅,此 ID 关联续订链中的原始交易。后续交易以续订形式关联。

如果没有续订,store_original_transaction_id 与 store_transaction_id 相同。

offerObjectOffer 对象。如果用户没有任何访问等级,可为 null
environmentString授予访问权限的交易所在环境。可选值:SandboxProduction
starts_atISO 8601 date访问等级生效的日期时间,可能是未来的时间。
purchased_atISO 8601 date该访问等级最近一次购买的日期时间。
originally_purchased_atISO 8601 date对于订阅,这是续订链中第一次(原始)购买的日期时间,与 store_original_transaction_id 关联。
expires_atISO 8601 date访问等级到期的日期时间,可能是过去的时间,对于永久授权则为 null
renewal_cancelled_atISO 8601 date订阅关闭自动续订的日期时间。订阅仍可处于有效状态,只是不会自动续订。如果用户重新激活订阅,则设为 null
billing_issue_detected_atISO 8601 date发现账单问题(如扣款失败)的日期时间。订阅可能仍处于有效状态。如果后续付款成功,此字段将被清除。
is_in_grace_periodBoolean表示订阅是否处于宽限期(仅适用于自动续订订阅)。
cancellation_reasonString取消原因,可选值包括:voluntarily_cancelledbilling_errorprice_increaseproduct_was_not_availablerefundupgradedunknown

Although the SDK includes the is_active parameter to check if a subscription is active, the server-side API does not provide this parameter. However, you can determine subscription status at any time by checking whether the current date falls between the starts_at and expires_at parameters.


Installation Meta

Information about installation of the app on a specific device.

You can do the following action via Adapty server-side API:

ParameterTypeRequiredNullableDescription
device_idStringYesNoThe device identifier is generated on the client side.
deviceStringNoYesThe end-user-visible device model name.
localeStringNoYesThe locale used by the end user.
osStringNoYesThe operating system used by the end user.
platformStringNoYesThe device platform used by the end user.
timezoneStringNoYesThe timezone of the end user.
user_agentStringNoYesDetails about the end user environment: device, operating system, and browser information of the end user interacting with your application.
idfaStringNoYesThe Identifier for Advertisers, assigned by Apple to a user’s device.
idfvStringNoYesThe Identifier for Vendors (IDFV) is a code assigned to all apps by one developer and is shared across all apps by that developer on your device.
advertising_idStringNoYesThe Advertising ID is a unique identifier offered by the Android Operating System that advertisers might use to uniquely identify you.
android_idStringNoYesOn Android 8.0 (API level 26) and higher versions of the platform, a 64-bit number (expressed as a hexadecimal string), unique to each combination of app-signing key, user, and device. For more details, see Android developer documentation.
android_app_set_idStringNoYesAn AppSetId - unique, per-device, per developer-account user-resettable ID for non-monetizing advertising use cases.

Non Subscription

Info about non-subscription purchases. These can be one-time (consumable) products, unlocks (like new map unlock in the game), etc.

You can do the following action via Adapty server-side API:

ParameterTypeRequiredNullableDescription
purchase_idStringYesNoIdentifier of the purchase in Adapty. You can use it to ensure that you’ve already processed this purchase, for example tracking one-time products.
storeStringYesNoStore where the product was purchased. Possible values are: app_store, play_store, stripe, name of your custom store.
store_product_idStringYesNoIdentifier of the product in the app store (App Store/Google Play/Stripe, etc.) that unlocked this access level.
store_base_plan_idStringYesYesBase plan ID in the Google Play Store or price ID in Stripe.
store_transaction_idStringYesNoThe ID of the transaction in the app store (App Store/Google Play/Stripe, etc.).
store_original_transaction_idStringYesNo

In case of prolonged subscriptions, a chain of subscriptions is generated. The original transaction i the very first transaction in this chain and the chain is linked by it. Other transactions in the chain are prolongations.

If no prolongation, store_original_transaction_id will coincide with store_transaction_id.

purchased_atISO 8601 dateYesNoThe datetime when the access level was purchased the latest time.
environmentStringNoNoEnvironment of the transaction that provided the access level. Possible values: Sandbox, Production.
is_refundBooleanYesNoIndicates if the product has been refunded.
is_consumableBooleanYesNoIndicates whether the product is consumable.

One-Time Purchase

ParameterTypeRequiredNullableDescription
purchase_typeString购买的产品类型。可选值:one_time_purchase
storeString购买产品的商店。可选值:app_storeplay_storestripe,或您的自定义商店的 Store ID。
environmentString提供访问等级的交易环境。可选值:SandboxProduction。默认使用 Production
store_product_idString解锁该访问等级的产品在应用商店(App Store、Google Play、Stripe 等)中的产品 ID。
store_transaction_idString应用商店(App Store、Google Play、Stripe 等)中的交易 ID。
store_original_transaction_idString

对于自动续订订阅,这是关联一系列续订记录的原始交易 ID。原始交易是链中的第一笔;后续交易为续订。

如果没有续订,store_original_transaction_idstore_transaction_id 相同。

offerObject购买时使用的优惠,以 Offer 对象表示。
is_family_sharedBoolean布尔值,表示该产品是否在 App Store Connect 中支持家庭共享。仅限 iOS。iOS 14.0 以下及 macOS 11.0 以下始终为 false。默认值为 false
priceObject一次性购买的价格,以 Price 对象表示。初始订阅价格为零时为免费试用;续订价格为零时为免费续订。
purchased_atISO 8601 date最近一次购买访问等级的日期时间。
refunded_atISO 8601 date如已退款,显示退款的日期时间。
cancellation_reasonString取消原因可选值:voluntarily_cancelledbilling_errorprice_increaseproduct_was_not_availablerefundcancelled_by_developernew_subscriptionunknown
variation_idString用于追踪购买来源的具体付费墙的实验变体 ID。

Offer

Information on the applied offer. The Offer object is a part of the Subscription, and Access level objects.

You can do the following actions with offers via Adapty server-side API:

ParameterTypeRequiredNullableDescription
categoryStringYesNoThe category of the applied offer. Options are: introductory, promotional, offer_code, win_back.
typeStringYesNoThe type of active offer. Options are: free_trial, pay_as_you_go, pay_up_front, and unknown. If this isn’t null, it means the offer was applied in the current subscription period.
idStringNoYesThe ID of the applied offer.

Price

Information about the cost of your product in local currency. The Price object is a part of the SubscriSption and Purchase objects.

You can do the following actions with product price via Adapty server-side API:

ParameterTypeRequiredNullableDescription
countryStringYesNoThe country where the price applies.
currencyStringYesNoThe currency used for the price.
valueFloatYesNoThe product’s cost in the local currency.

Profile

Info about the customer and their subscription

You can do the following actions with user profiles via Adapty server-side API:

参数类型可为空描述
app_idString:heavy_minus_sign:您应用的内部 ID。可在 Adapty 看板中查看:App Settings -> General tab
profile_idUUID:heavy_minus_sign:Adapty 用户画像 ID。可在 Adapty 看板 -> Profiles -> 具体用户画像页面的 Adapty ID 字段中查看。
customer_user_idString:heavy_plus_sign:您的用户在您系统中的 ID。可在 Adapty 看板 -> Profiles -> 具体用户画像页面的 Customer user ID 字段中查看。仅当您通过 Adapty SDK 在移动应用代码中识别用户时才会生效。
total_revenue_usdFloat:heavy_minus_sign:浮点数,表示该用户画像累计获得的 USD 总收入。
segment_hashString:heavy_minus_sign:内部参数。
timestampInteger:heavy_minus_sign:响应时间(毫秒),用于解决竞态条件。
custom_attributesArray:heavy_minus_sign:

每个用户画像最多可设置 30 个自定义属性。如果提供 custom_attributes 数组,则必须至少包含一个属性键。

Key: 键必须为字符串,且不超过 30 个字符。只允许使用字母、数字、短横线、点和下划线。

Value: 属性值不超过 30 个字符。只允许使用字符串和浮点数作为值,布尔值将被转换为浮点数。发送空值或 null 可删除该属性。

access_levelsArray:heavy_plus_sign:访问等级对象数组。如果用户没有访问等级,可为 null。
subscriptionsArray:heavy_plus_sign:订阅对象数组。如果用户没有订阅,可为 null。
non_subscriptionsArray:heavy_plus_sign:非订阅对象数组。如果用户没有购买记录,可为 null。

Product

This object contains details about a product in Adapty.

NameTypeRequiredDescription
titleStringNoProduct name from the Products section in the Adapty Dashboard.
is_consumableBooleanYesIndicates whether the product is consumable.
adapty_product_idUUIDNoInternal product ID as used in Adapty.
vendor_product_idStringYes

The product ID in app stores.

If access was granted without a real store transaction, vendor_product_id will be one of:

  • adapty_server_side_product — granted via the server-side API.
  • adapty_dashboard_productgranted manually in the Adapty Dashboard.
  • adapty_promotion — legacy.
introductory_offer_eligibilityBooleanNoSpecifies if the user is eligible for an iOS introductory offer.
promotional_offer_eligibilityBooleanNoSpecifies if the user is eligible for a promotional offer.
base_plan_idStringNoBase plan ID for Google Play or price ID for Stripe.
offerJSONNoAn Offer object as a JSON.
{
  "title": "Monthly Subscription w/o Trial",
  "is_consumable": true,
  "adapty_product_id": "InternalProductId",
  "vendor_product_id": "onemonth_no_trial",
  "introductory_offer_eligibility": false,
  "promotional_offer_eligibility": true,
  "base_plan_id": "B1",
  "offer": {
    "category": "promotional",
    "type": "pay_up_front",
    "id": "StoreOfferId"
  }
}

RemoteConfig

This object contains information about a remote config for a paywall.

{
  "lang": "en",
  "data": "{\"bodyItems\":[{\"spacerValue\":{\"height\":20,\"style\":{\"type\":\"emptySpace\"}},\"type\":\"spacer\"},{\"mediaValue\":{\"ratio\":\"1:1\",\"source\":{\"fileType\":\"image\",\"reference\":{\"en\":\"bundle/images/new1.png\"}},\"widthStyle\":\"full\"},\"type\":\"media\"},{\"titleValue\":{\"alignment\":\"center\",\"subtitleConfig\":{\"fontSize\":17,\"text\":\"\",\"color\":\"#FFFFFF\"},\"titleConfig\":{\"fontSize\":22,\"text\":\"\"}},\"type\":\"title\"},{\"productListValue\":{\"items\":[{\"productId\":\"exampleapp.oneWeek\",\"promoText\":\"paywall.promo-1.title\",\"backgroundColor\":\"#0B867D\"},{\"discountRate\":80,\"productId\":\"exampleapp.oneYear\",\"promoText\":\"paywall.promo-2.title\",\"backgroundColor\":\"#0B867D\"}],\"layout\":\"vertical\"},\"type\":\"productList\"}],\"defaultProductId\":\"exampleapp.oneWeek\",\"footer\":{\"singleProductValue\":{\"customTitles\":{\"exampleapp.oneWeek\":\"Subscribe\",\"exampleapp.oneYear\":\"Subscribe\"},\"productId\":\"exampleapp.oneWeek\"},\"type\":\"singleProduct\"},\"id\":\"exampleapp\",\"isFullScreen\":true,\"settings\":{\"backgroundColor\":\"#000000\",\"closeButtonAlignment\":\"left\",\"closeButtonIconStyle\":\"light\",\"colorScheme\":{\"accent\":\"#007566\",\"background\":\"#001B0D\",\"label\":\"#FFFFFF\",\"primary\":\"#10C6B6\",\"secondaryLabel\":\"#FFFFFF\",\"seperator\":\"#FFFFFF\"},\"isFullScreen\":true,\"shouldShowAlertOnClose\":false,\"showCloseButtonAfter\":1,\"triggerPurchaseWithAlert\":false,\"triggerPurchaseWithProductChange\":false}}"
}
NameTypeRequiredDescription
langStringYes

Locale code for the paywall localization. It uses language and region subtags separated by a hyphen (-).

Examples: en for English, pt-br for Brazilian Portuguese.

Refer to Localizations and locale codes for more details.

dataStringYesSerialized JSON string representing the remote config of your paywall. You can find it in the Remote Config tab of a specific paywall in the Adapty Dashboard.

Subscription

Info about your end user subscription. You can do the following action via Adapty server-side API:

参数类型必填可为空描述
purchase_typeString已购买产品的类型。可选值:subscription
storeString购买产品的商店。选项包括 app_storeplay_storestripe,或您的自定义商店的 Store ID。
environmentString交易发生的环境。选项为 SandboxProduction,默认使用 Production
store_product_idString解锁此访问等级的应用商店(App Store、Google Play、Stripe 等)中的产品 ID。
store_transaction_idString应用商店(App Store、Google Play、Stripe 等)中的交易 ID。
store_original_transaction_idString

对于订阅,此 ID 关联续期链中的首笔交易,每次续期均与该原始交易相关联。

如果没有续期,store_original_transaction_idstore_transaction_id 相同。

offerObject购买时使用的优惠,以 Offer 对象的形式提供。
is_family_sharedBoolean布尔值,表示该产品是否在 App Store Connect 中支持家庭共享。仅限 iOS。iOS 14.0 以下及 macOS 11.0 以下始终为 false,默认值为 false
priceObject订阅或购买的价格,以 Price 对象的形式表示。初始购买价格为零表示免费试用;续期价格为零表示免费续期。
purchased_atISO 8601 date最近一次购买访问等级的日期时间。
refunded_atISO 8601 date订阅退款的日期时间(如适用)。
cancellation_reasonString可能的取消原因包括:voluntarily_cancelledbilling_errorprice_increaseproduct_was_not_availablerefundupgradedunknown
variation_idString用于追踪购买来源付费墙的实验变体 ID。
originally_purchased_atISO 8601 date对于订阅链,这是通过 store_original_transaction_id 关联的原始交易的购买日期。
expires_atISO 8601 date访问等级到期的日期时间。该值可能已过期,永久授权时为 null
renew_statusBoolean表示订阅是否已开启自动续期。
renew_status_changed_atISO 8601 date自动续期被启用或禁用的日期时间。
billing_issue_detected_atISO 8601 date检测到账单问题的日期时间(例如银行卡扣款失败)。此时订阅可能仍处于有效状态,若付款成功则此字段将被清除。
grace_period_expires_atISO 8601 date若订阅当前处于宽限期,此字段为宽限期结束的日期时间。

Although the SDK includes the is_active parameter to check if a subscription is active, the server-side API does not provide this parameter. However, you can determine subscription status at any time by checking whether the current date falls between the starts_at and expires_at parameters of the Access Level object.