Set user consent and refund settings with API
Adapty Refund Saver helps you handle refund requests from Apple’s App Store automatically and more efficiently.
By default, Refund Saver always asks Apple to decline a user’s refund request. You can change this default behavior for all users in the Adapty Dashboard, or adjust it for a specific user using the Dashboard, the Adapty SDK, or the server-side API, as explained below.
To use Refund Saver, you need to get the user’s consent to share their data with Apple. You can record user’s consent through the Adapty SDK or the server-side API, as shown below.
Method and endpoint
POST https://api.adapty.io/api/v2/server-side-api/purchase/profile/refund-saver/settings/
Example request
Placeholders:
<YOUR_CUSTOMER_USER_ID>: The unique ID of the customer in your system.<YOUR_SECRET_API_KEY>: Your secret API key for authorization.
Parameters
| Parameter | Type | Required | Nullable | Description |
|---|---|---|---|---|
| custom_preference | String | No | Yes | Set the refund preference individually for the user. Possible values are: – grant: approve each refund request – no_preference: do not provide any recommendations |
| consent | Boolean | No | Yes | Record if the user gave their consent to share their data. – True means that if you receive an in-app refund request, you may provide Apple with information about the user |
Successful response: 200: OK
| Parameter | Type | Description |
|---|---|---|
| profile_id | String | Customer profile ID. |
| consent | Boolean | Defines whether the user consented to share their data. |
| custom preference | String | The refund preference. |
Successful response example
{
"profile_id": "e5aab402-b1bd-4039-b632-57a91ebc0779",
"settings": {
"consent": true,
"custom_preference": "no_preference"
}
}
Errors
400: Bad request
profile_does_not_exist
请求失败,因为在请求头中未找到对应的用户画像。请仔细检查请求头中输入的 profile_id 或 customer_user_id 是否存在拼写错误,并确认其对应的应用是否正确。
Body
| 参数 | 类型 | 描述 |
|---|---|---|
| errors | Object |
|
| error_code | String | 简短的错误名称。可能的值:profile_does_not_exist。 |
| status_code | Integer | HTTP 状态码。始终为 400。 |
响应示例
未找到用户画像
{
"errors": [
{
"source": "non_field_errors",
"errors": [
"Profile not found"
]
}
],
"error_code": "profile_does_not_exist",
"status_code": 400
}
401: Unauthorized
由于授权信息缺失或不正确,请求失败。请查看授权页面,并仔细检查 Authorization header。
该请求也因未找到指定的用户画像而失败。
请求体
| 参数 | 类型 | 描述 |
|---|---|---|
| errors | Object |
|
| error_code | String | 简短错误名称。始终为 not_authenticated。 |
| status_code | Integer | HTTP 状态码。始终为 401。 |
响应示例
{
"errors": [
{
"source": "non_field_errors",
"errors": [
"Authentication credentials were not provided."
]
}
],
"error_code": "not_authenticated",
"status_code": 401
}
See also: