# Refund Sale

## Endpoint

<mark style="color:purple;">`PUT`</mark> `https://api.keepup.store/v2.0/sales/refund/{sale_id}`

## Headers

`Authorization: Bearer API_KEY`

## Body Parameters

<table><thead><tr><th width="239"></th><th width="153"></th><th></th></tr></thead><tbody><tr><td><p><strong>alert_customer</strong></p><p>string</p></td><td>optional</td><td>Whether to alert the customer (<code>yes</code>, <code>no</code>).</td></tr></tbody></table>

## Sample Requests

{% tabs %}
{% tab title="Node.js" %}
{% code overflow="wrap" fullWidth="true" %}

```javascript
const axios = require('axios');
const data = JSON.stringify({
  "alert_customer": "yes",
});

const config = {
  method: 'post',
  url: 'https://api.keepup.store/v2.0/sales/refund/{sale_id}',
  headers: { 
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {access_token}'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.error(error);
});

```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}

```php
$curl = curl_init();

$data = json_encode([
  "alert_customer" => "yes",
]);

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.keepup.store/v2.0/sales/refund/{sale_id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "Authorization: Bearer {access_token}"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.keepup.store/v2.0/sales/refund/{sale_id}"
payload = json.dumps({
  "alert_customer": "yes",
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer {access_token}'
}

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

print(response.text)

```

{% endtab %}
{% endtabs %}

## Sample Response

{% tabs %}
{% tab title="Success" %}

```json
{
    "status": 200,
    "message": "sale refunded",
    "data": {
        "status": "refunded"
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keepup.store/docs/api/sales/refund-sale.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
