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: 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: Log transactions for consumable product purchases by providing consumable-product-specific fields.
- 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.
Changes Overview
| Change | Required action |
|---|---|
| Base URL and Endpoint | Base URL and all endpoints are changed. Update your configuration as described in the request endpoints |
| Request Headers |
|
| Request and Response Structure | Modify parameters as outlined for each request and update your integration to handle the new response formats. |
| Changed access level management | The old Prolong/grant a subscription for a user request is now split into three:
|
Migration Steps
To simplify using our server-side API, we've prepared a Postman collection and an environment file you can download and import into Postman.
Step 1. Configure request headers
Add new request headers as follows:
| Header | Description |
|---|---|
| adapty-profile-id | (Required, choose one) The user’s Adapty profile ID. Visible in the Adapty ID field in the Adapty Dashboard -> Profiles -> specific profile page. Interchangeable with adapty-customer-user-id, use any of them. |
| adapty-customer-user-id | (Required, choose one) The user’s ID in your system. Visible in the Customer user ID field in the Adapty Dashboard -> Profiles -> specific profile page. Interchangeable with adapty-profile-id, use any of them. ⚠️ Works only if you identify users in your app code using the Adapty SDK. |
| adapty-platform | Specify the app's platform. Possible options: iOS, macOS, iPadOS, visionOS, Android. |
Step 2. Change transaction and access management requests
In version 1, you used to use:
- Prolong/Grant a Subscription for a User request: to record a transaction and grant or shorten access level.
- Revoke access level request: to immediately revoke access.
They are now replaced with three separate requests to distinguish between adding transactions and managing access levels:
- Grant Access Level: Use this request to extend an access level without linking it to a transaction.
- Revoke Access Level: to immediately revoke or shorten access.
- Set Transaction: Use this request to add transaction details to Adapty with access levels.
Step 2.1. How to grant access level
For a detailed description, refer to the Grant access level request.
In version 1, the Prolong/grant a subscription for a user request was used to grant access. Now you can grant access with the Grant access level request without providing transaction details.
- 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.
Step 2.2. How to revoke or shorten access level
For a detailed description, refer to the Revoke access level request.
In version 1, you used the Revoke access level request to immediately revoke access and the Prolong/Grant a Subscription for a User request to shorten it. Now you can use the Revoke access level request for both actions.
- 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.
Step 2.3. How to record a subscription transaction
For a detailed description, refer to the Set transaction request.
In version 1, transactions were recorded using the Prolong/Grant a Subscription for a User request, which was limited to subscription transactions.
In version 2, this functionality has been replaced by the Set Transaction request. This request can handle both subscription transactions and one-time purchases.
- Endpoint:
https://api.adapty.io/api/v2/server-side-api/purchase/set/transaction/ - Details: The parameters required vary based on whether the transaction is a subscription or a one-time purchase. See the guidelines below for recording subscription transactions.
New fields
| Parameter | Change | Type | Required | Nullable | Description |
|---|---|---|---|---|---|
billing_issue_detected_at | Added | ISO 8601 date |