Skip to main content

Migration guide to server-side API v2

Adapty's Server-Side API v2 introduces new capabilities and improvements to help you manage access levels, transactions, and user profiles more effectively.

Why Migrate?

The second version of the Server-Side API gives you more flexibility and features when working with Adapty:

  • Separate access level management and transaction recording:
    • Grant access without transactions: Assign access levels to users without requiring transaction details, making it easier to handle compensations, bonuses, or other non-transactional scenarios.
    • Record one-time purchases without granting access: Log transactions for consumable product purchases without affecting the user's access level.
  • Enhanced transaction details: Include more data with transactions, like refunds, billing issues, cancellation reasons, renewals, and more.
  • Profile updates: Instead of just adding attributes, you can update a user’s profile. For instance, you can add installation metadata or disable external analytics if needed.

Although v1 is still supported, we recommend moving to v2 for expanded functionality and ongoing updates.

Migration Steps

General Changes

  1. Base URL Update:
    • Change from https://api.adapty.io/api/v1/sdk/ to https://api.adapty.io/api/v2/server-side-api/.
  2. Endpoint Changes: Refer to the updated endpoints for each specific request.
  3. Authorization Updates:
    • Move {profile_id_or_customer_user_id} from the endpoint to a header.
    • Remove {access_level} from the endpoint and include it as a parameter where needed.
    • Add a new adapty-platform header with options like iOS, macOS, iPadOS, visionOS, or Android.
  4. Unified Access Revocation: In v1, you used separate requests to revoke or shorten access. Now, use the Revoke access level request for both.
  5. **New Access Management Requests:**The old Prolong/grant a subscription for a user request is now split into three:
  6. Parameter Updates: Modify parameters as outlined for each request.
  7. Response Handling: Update your integration to handle the new response formats.

Prolong/grant a subscription for a user

  1. This request is now replaced with three separate requests to distinguish between adding transactions and managing access levels:
    1. Grant Access Level: Use this request to extend an access level without linking it to a transaction.
    2. Revoke Access Level:
    3. Set Transaction: Use this request to add transaction details to Adapty without managing access levels.

Grant Access Level

info

For a detailed description, refer to the Grant access level request.

Grant or extend access for a user without tying it to a transaction.

  • Endpoint: https://api.adapty.io/api/v2/server-side-api/grant/access-level/
  • Parameters to keep:
    • access_level_id: Previously in the endpoint. Required.
    • starts_at: Now nullable.
    • expires_at: Optional for lifetime access and nullable.

Revoke access level

info

For a detailed description, refer to the Revoke access level request.

Revoke or shorten a user’s access.

  • Endpoint: https://api.adapty.io/api/v2/server-side-api/purchase/profile/revoke/access-level/
  • Parameters to keep:
    • access_level_id: Required.
    • expires_at: Nullable unless access is revoked immediately.

Set transaction

info

For a detailed description, refer to the Set transaction request.

Submit a transaction to Adapty, separate from granting or revoking access.

  • Endpoint: https://api.adapty.io/api/v2/server-side-api/purchase/set/transaction/
  • Details: Parameters depend on whether the purchase is a subscription or one-time product. See specific guidelines for each.
For Subscription
ParameterChangeTypeRequiredNullableDescription Change
base_plan_idRemoved
billing_issue_detected_atAddedISO 8601 dateThe datetime when a billing issue was detected (e.g., a failed card charge). Subscription might still be active. This is cleared if the payment goes through.
cancellation_reasonAddedStringPossible reasons for cancellation include: voluntarily_cancelled, billing_error, price_increase, product_was_not_available, refund, upgraded, or unknown.
duration_daysRemoved
environmentAddedString

Environment where the transaction took place. Options are Sandbox or Production.

Replaces the is_sandbox parameter.

expires_atChangedISO 8601 dateThe datetime when the access level expires. It may be in the past and may be null for lifetime access.
grace_period_expires_atAddedISO 8601 dateThe datetime when the grace period will end, if the subscription is currently in one.
introductory_offer_typeRemoved
is_family_sharedAddedBooleanA Boolean value indicating whether the product supports family sharing in App Store Connect. iOS only. Always false for iOS below 14.0 and macOS below 11.0.
is_lifetimeRemoved
is_sandboxRemovedReplaced with the environment parameter.
offerAddedObjectRepresents the purchase offer as an object. See the Offer object.
originally_purchased_atAddedISO 8601 dateFor subscription chains, this is the purchase date of the original transaction, linked by store_original_transaction_id.
priceChangedFloat -> Object -> Now represented as a Price object.
price_localeRemoved
proceedsRemoved
purchase_typeAddedStringSpecifies product type, here set to subscription.
purchased_atAddedISO 8601 dateIndicates most recent purchase date.
refunded_atAddedISO 8601 dateIndicates subscription refund datetime if applicable.
renew_statusAddedBooleanIndicates if subscription auto-renewal is enabled.
renew_status_changed_atAddedISO 8601 dateIndicates when auto-renewal status changed.
starts_atRemoved
storeChangedString -> -> Store where the product was bought. Options include app_store, play_store, stripe, or the name of your custom store.
vendor_original_transaction_id -> store_original_transaction_idRenamed, changedString ->

For subscriptions, this ID links to the first transaction in a renewal chain. Each renewal is connected to this original transaction.


If there’s no renewal, store_original_transaction_id matches store_transaction_id.

vendor_product_id -> store_product_idRenamed, changedString -> Represents product ID in app stores.
vendor_transaction_id -> store_transaction_idRenamed, changedString -> Represents transaction ID in app stores.
variation_idAddedStringThe variation ID used to trace purchases to the specific paywall they were made from.
For One-time purchase
ParameterChangeTypeRequiredNullableDescription Change
base_plan_idRemoved
cancellation_reasonAddedStringPossible reasons for cancellation: voluntarily_cancelled, billing_error, price_increase, product_was_not_available, refund, cancelled_by_developer, new_subscription_replace, upgraded, unknown, adapty_revoked.
duration_daysRemoved
environmentAddedString

Environment where the transaction took place. Options are Sandbox or Production.

Replaces the is_sandbox parameter.

expires_atRemoved
introductory_offer_typeRemoved
is_family_sharedAddedBooleanIndicates whether the product supports family sharing in App Store Connect. iOS only. Always false for iOS below 14.0 and macOS below 11.0.
is_lifetimeRemoved
is_sandboxRemovedReplaced with the environmentparameter.
offerAddedObjectRepresents the purchase offer as an object. See the Offer object.
priceChangedFloat -> Object -> Now represented as a Price object.
price_localeRemoved
proceedsRemoved
purchase_typeAddedStringSpecifies the type of product purchased. Here set to one_time_purchase.
purchased_atAddedISO 8601 dateThe datetime when the access level was last purchased.
refunded_atAddedISO 8601 dateIf refunded, shows the datetime of the refund.
starts_atRemoved
storeChangedString -> Store where the product was bought. Options include app_store, play_store, stripe, or the name of your custom store.
vendor_original_transaction_id -> store_original_transaction_idRenamed, changedString ->

For subscriptions, this ID links to the first transaction in a renewal chain. Each renewal is connected to this original transaction.


If there’s no renewal, store_original_transaction_id matches store_transaction_id.

vendor_product_id -> store_product_idRenamed, changedString -> Represents product ID in app stores.
vendor_transaction_id -> store_transaction_idRenamed, changedString -> Represents transaction ID in app stores.
variation_idAddedStringThe variation ID used to trace purchases to the specific paywall they were made from.

Revoke subscription from a user

info

For a detailed description, refer to the Revoke access level request.

In version 1, you used the Revoke subscription from a user request to immediately remove access. Now, use the Revoke access level request to either immediately remove access or shorten it.

  • Endpoint: https://api.adapty.io/api/v2/server-side-api/purchase/profile/revoke/access-level/
  • New Option: Specify a future revoke date (revoke_at) if immediate revocation isn’t needed.

Validate a purchase from Stripe, provide access level to a customer, and import his transaction history from Stripe

No changes

Get info about a user

info

For a detailed description, refer to the Retrieve profile request.

Retrieve complete user profile data without additional parameters.

  • Endpoint: https://api.adapty.io/api/v2/server-side-api/profile/
  • Change: The User Profile ID or Customer User ID is now passed via headers, and no additional parameters are needed. The extended parameter is no longer needed as the complete profile data is always returned.

Set the user's attribute

info

For a detailed description, refer to the Update profile request.

In version 1, you could only update user attributes. With v2, you can modify a wider range of profile fields, such as installation metadata or analytics settings.

  • Endpoint: https://api.adapty.io/api/v2/server-side-api/profile/.
ParameterChangeTypeRequiredNullableDescription Change
analytics_disabledAddedBooleanOption to opt out of external analytics. When disabled, events won’t be sent to integrations, and idfa, idfv, and advertising_id become nullable.
birthdayChangedDate -> ISO 8601 date -> Your end user's birthday.
installation_metaAddedDictionaryContains app-specific device details as a dictionary of Installation Meta objects.
ip_countryChangedString -> Country of the end user in ISO 3166-2 format. Must be passed if the request is made from the server. Otherwise, determined by request IP.
storeAddedStringStore where the product was bought. Options include app_store, play_store, stripe, or the name of your custom store.
store_countryAddedStringCountry of the end user app store.

Delete user's data

info

For a detailed description, refer to the Delete profile request.

  • Endpoint: https://api.adapty.io/api/v2/server-side-api/profile/
  • Change: The User Profile ID or Customer User ID is now passed via headers, and no additional parameters are needed.