API specs
Base URL: https://api.adapty.io/api/v1/sdk
Authorization
Each API request must be signed with the Secret Key.
When calling API:
- You must set Authorization header with value "Api-Key {secret_token}" (without quotes) to each request, for example
Api-Key secret_live_BEHrYLTr.ce5zuDEWz06lFRNiaJC8mrLtL8fUwswD
- Use JSON payload in the request body for POST and PATCH requests
- All request must set header Content-Type: application/json
Working with customer user ID
Most server-side API requests allow passing customer_user_id
as a URL parameter. This makes it easy for you to query/update data in Adapty, without having to store Adapty's profile_id
. In most cases, you should pass customer_user_id
as is, without any modifications.
However, if your customer_user_id
contains reserved URI characters, for example /
, ?
, +
you should pass it encoded. Use the Base64URL encoding (not the regular Base64). This way, all special characters will be encoded and Adapty will decode it upon receiving. To tell Adapty the customer_user_id
is encoded, pass the is_user_id_base64url_encoded=1
get parameter. Note, that passing the is_user_id_base64url_encoded=1
get parameter without actual encoding, will end up with 400 validation error.
You should only encode the customer_user_id
if you pass it as a URL path. When sending customer_user_id
inside the JSON payload (for example, when creating the profile), you should not encode it.
## Don't encode
customer_user_id = '123' # GET: /profiles/123/
customer_user_id = 'abc' # GET: /profiles/abc/
customer_user_id = '3c410419-9959-447a-84b5-be7cb6a308d9' # GET: /profiles/3c410419-9959-447a-84b5-be7cb6a308d9/
## Base64URL encode
customer_user_id = '123+456' # GET: /profiles/MTIzKzQ1Ng==/?is_user_id_base64url_encoded=1
customer_user_id = 'abc/def' # GET: /profiles/YWJjL2RlZg==/?is_user_id_base64url_encoded=1
customer_user_id = '012?012' # GET: /profiles/MDEyPzAxMg==/?is_user_id_base64url_encoded=1
Requests
Prolong/grant a subscription for a user
POST: /profiles/{profile_id_or_customer_user_id}/paid-access-levels/{access_level}/grant/
Path parameters:
Param | Type | Required | Nullable | Description |
---|---|---|---|---|
profile_id_or_customer_user_id | str | ✅ | ❌ | Adapty profile ID or developer's internal ID |
access_level | str | ✅ | ❌ | ID (slug) of a paid access level. Find it in Adapty Dashboard |
Request parameters:
Param | Type | Required | Nullable | Description |
---|---|---|---|---|
expires_at | ISO 8601 date | ✅* see below | ❌ | Subscription deadline |
duration_days | int | ✅* see below | ❌ | Additional days to a current subscription** |
is_lifetime | bool | ✅* see below | ❌ | If set true, then a user will forever have a paid access level forever |
starts_at | ISO 8601 date | ❌ | ❌ | If the start time of the action is in the future, then you can transfer it. If the start time and the period are indicated, the period will be counted from the indicated time |
vendor_product_id | str | ❌ | ❌ | When posting a transaction, include the product ID that triggers the subscription renewal. If you're granting an access level without a transaction, skip this parameter, and adapty_server_side_product will be used by default. |
base_plan_id | str | ❌ | ❌ | Base plan ID in the Google Play Store or price ID in Stripe. |
vendor_original_transaction_id | str | ❌ | ❌ | ID of the original transaction in the subscription renewal chain in a vendor environment. |
vendor_transaction_id | str | ❌ | ❌ | Transaction ID in a vendor environment. If it is the same as vendor_original_transaction_id or if vendor_original_transaction_id is absent, Adapty considers it the first subscription purchase. If it differs from vendor_original_transaction_id, Adapty considers the purchase the subscription renewal. |
store | str | ❌ | ❌ | A store where users purchased a product, such as app_store and play_store, can be custom. Default is adapty |
introductory_offer_type | str |