# Cancel Sale

## Endpoint

<mark style="color:purple;">`PUT`</mark> `https://api.keepup.store/v2.0/sales/cancel/{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/cancel/{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/cancel/{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/cancel/{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 cancelled",
    "data": {
        "status": "cancelled"
    }
}
```

{% endtab %}

{% tab title="Error" %}

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

{% endtab %}
{% endtabs %}
