Grant access level with server-side API
Provides access level to your end-user without providing info on the transaction. This comes in handy if you have bonuses for referrals or other events related to your products.
The access level provided by this method will not be reflected in your analytics. It will be sent to only webhook integration, and only in this case will appear in the Event Feed. If webhook integration is not enabled, granting access level will not be shown in the Event Feed.
To grant access and simultaneously provide the transaction details, please use the Set Transaction request which is recommended.
Method and endpoint
POST https://api.adapty.io/api/v2/server-side-api/purchase/profile/grant/access-level/
Parameters
Parameter | Type | Required in request | Nullable in request | Description |
---|---|---|---|---|
access_level_id | String | ➕ | ➖ | Paid access level ID configured by you in the Access Levels page of the Adapty Dashboard |
starts_at | ISO 8601 date | ➖ | ➕ | The datetime when the access level will be active. Maybe in the future |
expires_at | ISO 8601 date | ➖ | ➕ | The datetime when the access level will expire. It may be in the past and may be null for lifetime access |
Example request
{
"access_level_id": "premium",
"starts_at": "2022-10-12T09:42:50.000000+0000",
"expires_at": "2024-10-12T09:42:50.000000+0000"
}
Successful response
Header:
Name | Type | Description |
---|---|---|
Request-Id | String | The Request ID, which is included in all backend logs. Example: 758f01dfd9e74ccfbabb4934241c4966 . |
Body:
Successful response example
{
"data": {
"app_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"profile_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"customer_user_id": "8612ED7C-3477-466D-93AE-1854B8E5FDD5",
"total_revenue_usd": 109.88999999999999,
"segment_hash": "string",
"timestamp": 0,
"custom_attributes": [
{
"key": "string",
"value": "string"
}
],
"access_levels": [
{
"access_level_id": "premium",
"store": "app_store",
"store_product_id": "weekly_8.99",
"store_base_plan_id": "",
"store_transaction_id": "530001802720333",
"store_original_transaction_id": "530001724306018",
"offer": {
"category": "introductory",
"type": "free_trial",
"id": "offer12"
},
"environment": "Production",
"starts_at": "2022-10-12T09:42:50.000000+0000",
"purchased_at": "2022-10-12T09:42:50.000000+0000",
"originally_purchased_at": "2021-10-12T09:42:50.000000+0000",
"expires_at": "2022-10-12T09:42:50.000000+0000",
"renewal_cancelled_at": "2022-10-12T09:42:50.000000+0000",
"billing_issue_detected_at": "2022-10-12T09:42:50.000000+0000",
"is_in_grace_period": true,
"cancellation_reason": "voluntarily_cancelled"
}
],
"subscriptions": [
{
"store": "app_store",
"store_product_id": "weekly_8.99",
"store_base_plan_id": "",
"store_transaction_id": "530001802720333",
"store_original_transaction_id": "530001724306018",
"offer": {
"offer_category": "introductory",
"offer_type": "free_trial",
"offer_id": "offer12"
},
"environment": "Production",
"purchased_at": "2022-10-12T09:42:50.000000+0000",
"originally_purchased_at": "2021-10-12T09:42:50.000000+0000",
"expires_at": "2022-10-12T09:42:50.000000+0000",
"renewal_cancelled_at": "2022-10-12T09:42:50.000000+0000",
"billing_issue_detected_at": "2022-10-12T09:42:50.000000+0000",
"is_in_grace_period": true,
"cancellation_reason": "voluntarily_cancelled"
}
],
"non_subscriptions": [
{
"purchase_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"store": "app_store",
"store_product_id": "weekly_8.99",
"store_base_plan_id": "",
"store_transaction_id": "530001724306018",
"store_original_transaction_id": "530001724306018",
"purchased_at": "2022-10-12T09:42:50.000000+0000",
"environment": "Production",
"is_refund": true,
"is_consumable": true
}
]
}
}
Errors
400 - Bad request
paid_access_level_does_not_exist
The request failed because the access level in the request couldn’t be found. Double-check that there are no typos in the access_level_id
and that it matches the correct app.
Parameters
Parameter | Type | Description |
---|---|---|
errors | Object |
|
error_code | String | Short error name. Possible value: paid_access_level_does_not_exist . |
status_code | Integer | HTTP status. Always 404 . |
Response example
The access level was not found.
{
"errors": [
{
"source": "non_field_errors",
"errors": [
"Paid access level `premium` does not exist"
]
}
],
"error_code": "paid_access_level_does_not_exist",
"status_code": 400
}
profile_does_not_exist
The request failed because the profile in the request header wasn’t found. Double-check that there are no typos in the profile_id
or customer_user_id
you entered in the request header, and make sure it’s for the correct app.
Parameters
Parameter | Type | Description |
---|---|---|
errors | Object |
|
error_code | String | Short error name. Possible value: profile_does_not_exist . |
status_code | Integer | HTTP status. Always 400 . |
Response example
The profile is not found
{
"errors": [
{
"source": "non_field_errors",
"errors": [
"Profile not found"
]
}
],
"error_code": "profile_does_not_exist",
"status_code": 400
}
401 - Unauthorized
The request failed due to missing or incorrect authorization. Check the Authorization page, paying close attention to the Authorization header.
The request also failed because the specified profile wasn’t found.
Body:
Parameter | Type | Description |
---|---|---|
errors | Object |
|
error_code | String | Short error name. Always not_authenticated . |
status_code | Integer | HTTP status. Always 401. |
Response example:
{
"errors": [
{
"source": "non_field_errors",
"errors": [
"Authentication credentials were not provided."
]
}
],
"error_code": "not_authenticated",
"status_code": 401
}
404 - Not found
The request failed because the specified profile wasn’t found.
Body
Parameter | Type | Description |
---|---|---|
errors | Object |
|
error_code | String | Short error name. Always not_found . |
status_code | Integer | HTTP status. Always 404 . |
Response example
{
"errors": [
{
"source": "non_field_errors",
"errors": [
"Not found."
]
}
],
"error_code": "not_found",
"status_code": 404
}
See also: