Getting started with server-side API
With API you can:
- Get user's subscription status.
- Activate a subscription for a user with an access level.
- Get user's attributes.
- Set user's attributes.
You can't get subscription events via API, but you can use Webhook or direct integration with a service that you're using.
To correctly work with API you need to use a unique ID for your users. This may be an email, a phone number, your internal ID. Without such an ID it's impossible to identify the same user on multiple platforms.
Case 1: Syncing subscribers between web and mobile
Whenever Web payment providers you use such as Stripe, ChargeBee, or any other, you can sync subscribers. For that:
- Use a unique ID for your users. For example, email or phone number.
- Check subscription status via API.
- If a user is freemium, show him a paywall on the Web.
- After successful payment, update subscription status in Adapty via API.
- Your subscribers will be automatically in sync with mobile.
Case 2: Grant a subscription
Due to security reasons, you can't grant a subscription via mobile SDK.
Imagine a case, when you run a promotional campaign with offers 7 days of a trial and you want to sync in with mobile experience. To do that:
- Get a unique ID for a user.
- Set premium access via paid access level with API with a duration of 7 days.
After 7 days users who won't subscribe will be downgraded to the free tier.
Case 3: Syncing users' attributes and custom properties
You may have custom attributes for your users, other than defaults such as IDFA, device model, etc. For example, in a language learning service, you may want to save the number of words a student has learned. To do that:
- Get a unique ID for a user.
- Update attribute with API or SDK.
With such attributes you can, for example, create a segment and run an A/B test.
To learn more about S2S API go to API Specs.