---
title: "Set user consent and refund settings with API"
description: ""
---

[Adapty Refund Saver](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](refund-saver#set-a-default-refund-behavior) for all users in the Adapty Dashboard, or adjust it for a specific user [using the Dashboard](refund-saver#set-refund-behavior-for-a-specific-user-in-the-dashboard), the [Adapty SDK](refund-saver#set-refund-behavior-for-a-specific-user-in-the-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](refund-saver#update-user-consent-in-the-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

<Tabs groupId="api-lang" queryString>  
<TabItem value="curl" label="cURL" default>  

```bash showLineNumbers
curl --location 'https://api.adapty.io/api/v2/server-side-api/purchase/profile/refund-saver/settings/' \
--header 'adapty-customer-user-id: <YOUR_CUSTOMER_USER_ID>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Api-Key <YOUR_SECRET_API_KEY>' \
--data '{ 
    "custom_preference": "grant",
    "consent": true
}'
```

</TabItem>  
<TabItem value="python" label="Python" default>  

```python showLineNumbers

url = "https://api.adapty.io/api/v2/server-side-api/purchase/profile/refund-saver/settings/"

payload = json.dumps({
    "custom_preference": "grant",
    "consent": True
})
headers = {
 "adapty-customer-user-id": "<YOUR_CUSTOMER_USER_ID>",
  "Content-Type": "application/json",
  "Authorization": "Api-Key <YOUR_SECRET_API_KEY>"
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

</TabItem>  
<TabItem value="js" label="JavaScript" default>  

```javascript showLineNumbers
const myHeaders = new Headers();
myHeaders.append("adapty-customer-user-id", "<YOUR_CUSTOMER_USER_ID>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Api-Key <YOUR_SECRET_API_KEY>");

const raw = JSON.stringify({
    "custom_preference": "grant",
    "consent": true
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://api.adapty.io/api/v2/server-side-api/purchase/profile/refund-saver/settings/", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
```

</TabItem>  
</Tabs>

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.  <br/> Possible values are: <br/>– `grant`: approve each refund request <br/>– `no_preference`: do not provide any recommendations |
| consent           | Boolean | No       | Yes      | Record if the user gave their consent to share their data. <br/>– `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

``` json showLineNumbers
{
    "profile_id": "e5aab402-b1bd-4039-b632-57a91ebc0779",
    "settings": {
        "consent": true,
        "custom_preference": "no_preference"
    }
}
```

## Errors

### 400: Bad request

#### profile_does_not_exist

<p> </p>

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.

#### Body

| Parameter   | Type    | Description                                                  |
| ----------- | ------- | ------------------------------------------------------------ |
| errors      | Object  | <ul><li> **source**: (string) Always `non_field_errors`</li><li> **errors**: A description of the error. </li></ul> |
| 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

```json showLineNumbers
{
  "errors": [
    {
      "source": "non_field_errors",
      "errors": [
        "Profile not found"
      ]
    }
  ],
  "error_code": "profile_does_not_exist",
  "status_code": 400
}
```  

---

### 401: Unauthorized

<p> </p>

The request failed due to missing or incorrect authorization. Check the [Authorization](ss-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  | <ul><li> **source**: (string) Always `non_field_errors`.</li><li> **errors**: A description of the error.</li></ul> |
| error_code  | String  | Short error name. Always `not_authenticated`.                |
| status_code | Integer | HTTP status. Always `401.`                                   |

#### Response example

```json showLineNumbers
{
  "errors": [
    {
      "source": "non_field_errors",
      "errors": [
        "Authentication credentials were not provided."
      ]
    }
  ],
  "error_code": "not_authenticated",
  "status_code": 401
}
```  

---

**See also:**

- [Refund Saver](refund-saver) 
- [Retrieve user consent and refund settings with API](api-adapty/operations/getRefundSaverSettings)