> For the complete documentation index, see [llms.txt](https://docs.keepup.store/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keepup.store/docs/api/sales/update-balance.md).

# Update Balance

## Endpoint

<mark style="color:purple;">`PUT`</mark> `https://api.keepup.store/v2.0/sales/balance/{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>amount_paid</strong></p><p>string</p></td><td>required</td><td>Amount paid for the sale.</td></tr><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><tr><td><p><strong>payment_type</strong></p><p>string</p></td><td>optional</td><td>Method of payment.</td></tr><tr><td><p><strong>date</strong></p><p>string</p></td><td>optional</td><td>Date by which the sale should be settled (format: YYYY-MM-DD HH:MM).</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({
  "date": "2023-01-15 15:15",
  "payment_type": "Credit Card",
  "amount_paid": "200.00",
  "alert_customer": "yes",
});

const config = {
  method: 'post',
  url: 'https://api.keepup.store/v2.0/sales/balance/{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([
  "date" => "2023-01-15 15:15",
  "payment_type" => "Credit Card",
  "amount_paid" => "200.00",
  "alert_customer" => "yes",
]);

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.keepup.store/v2.0/sales/balance/{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/balance/{sale_id}"
payload = json.dumps({
  "date": "2023-01-15 15:15",
  "payment_type": "Credit Card",
  "amount_paid": "200.00",
  "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": "balance updated",
    "data": {
        "balance_due": "0.00",
        "amount_paid": "110.00",
        "amount_received": "200.00",
        "change": "0.00",
        "status": "receipt",
        "payment_log": [
            {
                "updated_by": "API",
                "amount_received": "200.00",
                "amount_paid": "110.00",
                "balance_remaining": "0.00",
                "payment_type": "Credit Card",
                "created_at": "2023-05-02 15:15:00"
            }
        ],
        "outstanding_balance": {
            "meta": {
                "total_outstanding_balance_due": "0.00",
                "total_records": 0
            },
            "sales": []
        }
    }
}
```

{% endtab %}

{% tab title="Error" %}

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

{% endtab %}
{% endtabs %}
