API Specs

Base URL: https://api.adapty.io/api/v1/sdk

Authorization

Each API request must be sent with a secret token.

When calling API:

  • You must set Authorization header with value "Api-Key {secret_token}" (without quotes) to each request

  • Use JSON payload in request body for POST and PATCH requests

  • All request must set header Content-Type: application/json

Requests

Prolong/grant a subscription for a user

POST: /profiles/{profile_id}/paid-access-levels/{paid_access_level}/grant/

Path params

Param

Type

Required

Nullable

Description

profile_id

str

Adapty profile ID or developer's internal ID

paid_access_level

str

ID (slug) of a paid access level. Find it in Adapty dashboard

Request params

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, than 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

Vendor product ID which initiate subscription prolongation. Default value is adapty_promotion

vendor_transaction_id

str

Transaction ID in a vendor environment

store

str

A store where user purchased a product. Available values are app_store and play_store. Default is adapty

introductory_offer_type

str

A type of introduction offer. Available values are free_trial, pay_as_you_go, and pay_up_front. Default is null and offer is not applied

There are three ways to grant user a subscription. So, at least of one is_lifetime, expires_at, duration_days, must be set. If more than one param is sent, then is_lifetime=true has a maximum priority, then expires_at and lastly duration_days.

As all payments processing is done by Apple/Google, Adapty can not control or affect in anyway on it. So, when using duration_days to a current subscription, remember that a user still will be charged on a needed day. For example, user has a monthly subscription and the next charge date will be 5th or April. You grant a user additional 7 days, but user still be charged on 5th of April!. It's best using duration_days with never subscribed users or churned. In that case reference day is a day of granting.

Example request

{
"starts_at": "2020-01-15T15:10:36.517975+0000",
"expires_at": "2020-02-15T15:10:36.517975+0000",
"vendor_product_id": "basic_subscription_1_month",
"vendor_transaction_id": "123456789",
"store": "app_store",
"introductory_offer_type": null
}

Response example

{
"data": {
"app_id": "ff90dd2e-e7f2-454b-9d86-071036a284fe",
"profile_id": "77112400-89f1-4465-b9c9-5437e58c6688",
"customer_user_id": "iwitaly@adapty.io",
"paid_access_levels": {
"standard": {
"id": "standard",
"is_active": true,
"is_lifetime": false,
"expires_at": "2023-03-29T15:30:34.000000+0000",
"starts_at": null,
"will_renew": false,
"vendor_product_id": "adapty_promotion",
"store": "adapty",
"activated_at": "2020-03-26T16:24:19.497674+0000",
"renewed_at": "2020-03-26T16:24:19.497674+0000",
"unsubscribed_at": null,
"billing_issue_detected_at": null,
"is_in_grace_period": false,
"active_introductory_offer_type": "free_trial",
"active_promotional_offer_type": null,
"active_promotional_offer_id": null,
"cancellation_reason": null
},
"premium": {
"id": "premium",
"is_active": true,
"is_lifetime": true,
"expires_at": null,
"starts_at": null,
"will_renew": false,
"vendor_product_id": "com.adapty.premium.forever2",
"store": "app_store",
"activated_at": "2020-02-25T07:00:18.000000+0000",
"renewed_at": null,
"unsubscribed_at": null,
"billing_issue_detected_at": null,
"is_in_grace_period": false,
"active_introductory_offer_type": null,
"active_promotional_offer_type": null,
"active_promotional_offer_id": null,
"cancellation_reason": null
}
},
"subscriptions": {
"com.adapty.premium.monthly": {
"is_active": false,
"is_lifetime": false,
"expires_at": "2020-02-21T16:30:34.000000+0000",
"starts_at": null,
"will_renew": false,
"vendor_product_id": "com.adapty.premium.monthly",
"vendor_transaction_id": "1000000630116569",
"vendor_original_transaction_id": "1000000625263604",
"store": "app_store",
"activated_at": "2020-02-10T19:14:02.000000+0000",
"renewed_at": "2020-02-21T16:25:34.000000+0000",
"unsubscribed_at": "2020-02-21T16:30:34.000000+0000",
"billing_issue_detected_at": "2020-02-21T16:30:34.000000+0000",
"is_in_grace_period": false,
"active_introductory_offer_type": null,
"active_promotional_offer_type": null,
"active_promotional_offer_id": null,
"cancellation_reason": "voluntarily_cancelled",
"is_sandbox": true
},
"com.adapty.premium.weekly": {
"is_active": false,
"is_lifetime": false,
"expires_at": "2020-02-10T19:32:00.000000+0000",
"starts_at": null,
"will_renew": true,
"vendor_product_id": "com.adapty.premium.weekly",
"vendor_transaction_id": "1000000625265713",
"vendor_original_transaction_id": "1000000625263604",
"store": "app_store",
"activated_at": "2020-02-10T19:14:02.000000+0000",
"renewed_at": "2020-02-10T19:29:00.000000+0000",
"unsubscribed_at": null,
"billing_issue_detected_at": null,
"is_in_grace_period": false,
"active_introductory_offer_type": null,
"active_promotional_offer_type": null,
"active_promotional_offer_id": null,
"cancellation_reason": null,
"is_sandbox": true
},
"basic_subscription_unlimited": {
"is_active": true,
"is_lifetime": false,
"expires_at": "2021-02-27T11:00:30.000000+0000",
"starts_at": null,
"will_renew": false,
"vendor_product_id": "basic_subscription_unlimited",
"vendor_transaction_id": "1000000632277988",
"vendor_original_transaction_id": "1000000632277988",
"store": "app_store",
"activated_at": "2020-02-27T11:00:30.000000+0000",
"renewed_at": null,
"unsubscribed_at": null,
"billing_issue_detected_at": null,
"is_in_grace_period": false,
"active_introductory_offer_type": null,
"active_promotional_offer_type": null,
"active_promotional_offer_id": null,
"cancellation_reason": null,
"is_sandbox": true
}
},
"non_subscriptions": null
}
}

Learn more about responses in Objects

Get info about a user

GET: /profiles/{profile_id}/

Path params

Param

Type

Required

Nullable

Description

profile_id

str

Adapty profile ID or developer's internal ID

Response example is the same as for Prolong/grant a subscription for a user.

Create a user

POST: /profiles/

Request params

Param

Type

Required

Nullable

Description

customer_user_id

str

?????

Set the user's attribute

Maximum of 10 attributes for the profile allowed to be set.

POST: /profiles/{profile_id}/attributes/

Path params

Param

Type

Required

Nullable

Description

profile_id

str

Adapty profile ID or developer's internal ID

Request params

Param

Type

Required

Nullable

Description

attribute_key

str

Only letters, numbers, dashes, points, and underscores allowed. The attribute key must be no more than 30 characters.

attribute_value

str

The attribute value must be no more than 30 characters. Send empty value or null to delete the attribute.