# Edit Sale

## Endpoint

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

## Headers

`Authorization: Bearer API_KEY`

## Body Parameters

|                                                                   |          |                                                                                                           |
| ----------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------- |
| <h4>sale\_id</h4><p><em>number</em></p>                           | required | The sale ID of the sale to be edited. `Example: 123`                                                      |
| <h4><strong>customer\_name</strong></h4><p><em>date</em></p>      | optional | Customer's full name. `Example: "`Chinedu Okeke`"`                                                        |
| <h4><strong>phone\_number</strong></h4><p><em>string</em></p>     | optional | Customer's phone number. `Example: "233201234567"`                                                        |
| <h4><strong>customer\_email</strong></h4><p><em>string</em></p>   | optional | Customer's email address                                                                                  |
| <h4><strong>items</strong></h4><p><em>json</em></p>               | required | List of items being sold in JSON format. Example: `[{ "item_id": "123", "quantity": 2, "price": 70.00 }]` |
| <h4><strong>fulfillment\_type</strong></h4><p><em>string</em></p> | optional | Type of fulfillment (e.g., `pick-up`, `delivery`).                                                        |
| <h4><strong>location\_name</strong></h4><p><em>string</em></p>    | optional | Location name for the delivery                                                                            |
| <h4><strong>location</strong></h4><p><em>string</em></p>          | optional | Detailed address for delivery                                                                             |
| <h4><strong>lat</strong></h4><p><em>string</em></p>               | optional | Latitude for the delivery location.                                                                       |
| <h4><strong>lng</strong></h4><p><em>string</em></p>               | optional | Longitude for the delivery location.                                                                      |
| <h4><strong>fulfillment\_cost</strong></h4><p><em>string</em></p> | optional | Cost associated with the fulfillment.                                                                     |
| <h4><strong>discount\_type</strong></h4><p><em>string</em></p>    | optional | Type of discount `(fixed or percentage)`                                                                  |
| <h4><strong>discount\_amount</strong></h4><p><em>string</em></p>  | optional | Amount of discount given. `Example: 10.00`                                                                |
| <h4><strong>tax\_profile</strong></h4><p><em>string</em></p>      | optional | Tax profile ID applicable to the sale                                                                     |
| <h4><strong>note</strong></h4><p><em>string</em></p>              | optional | Any additional notes about the sale.                                                                      |
| <h4><strong>issue\_date</strong></h4><p><em>string</em></p>       | optional | Date the sale was issued `(format: YYYY-MM-DD HH:mm:ss).`                                                 |
| <h4><strong>due\_date</strong></h4><p><em>string</em></p>         | optional | Date by which the sale should be settled `(format: YYYY-MM-DD HH:mm:ss).`                                 |
| <h4><strong>payment\_type</strong></h4><p><em>string</em></p>     | optional | Type of payment received. `Example: "mobile_money"`                                                       |
| <h4><strong>amount\_received</strong></h4><p><em>string</em></p>  | optional | Amount received for the sale.                                                                             |
| <h4><strong>alert\_customer</strong></h4><p><em>string</em></p>   | optional | Whether to alert the customer (`yes`,`no`).                                                               |
| <h4><strong>sale\_type</strong></h4><p><em>string</em></p>        | optional | Type of sale document `(quote or invoice).`                                                               |

## Sample Requests

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

```javascript
const axios = require('axios');
const data = {
  customer_name: "Chinedu Okeke",
  phone_number: "+233801234567",
  customer_email: "chinedu@example.com",
  items: JSON.stringify([
    {
      item_id: 11, 
      item_name: "Bananas", 
      quantity: 10, 
      price: 20, 
      item_type: "product"
    },
    ...
  ]),
  fulfillment_type: "delivery",
  location_name: "Awesome Place",
  location: "1234 Awesome Place Ave, Ghana",
  lat: "40.7128",
  lng: "-74.0060",
  fulfillment_cost: "10.00",
  discount_type: "fixed",
  discount_amount: "10.00",
  note: "Urgent delivery",
  issue_date: "2023-01-01 15:15",
  due_date: "2023-01-15 15:15",
  payment_type: "mobile_money",
  amount_received: "200.00",
  alert_customer: "yes"
});

const sale_id = 'YOUR_SALE_ID'; // Replace 'YOUR_SALE_ID' with your actual sale ID
const config = {
  method: 'put',
  url: `https://api.keepup.store/v2.0/sales/edit/${sale_id}`,
  headers: { 
    'Content-Type': 'application/json',
    'Authorization': 'Bearer API_KEY'
  },
  data: data
};

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

```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}

```php
<?php
$curl = curl_init();

$data = [
    "customer_name" => "Chinedu Okeke",
    "phone_number" => "+233801234567",
    "customer_email" => "chinedu@example.com",
    "items" => json_encode([
        [
            "item_id" => 11,
            "item_name" => "Bananas",
            "quantity" => 10,
            "price" => 20,
            "item_type" => "product"
        ]
        // Add more items as needed...
    ]),
    "fulfillment_type" => "delivery",
    "location_name" => "Awesome Place",
    "location" => "1234 Awesome Place Ave, Ghana",
    "lat" => "40.7128",
    "lng" => "-74.0060",
    "fulfillment_cost" => "10.00",
    "discount_type" => "fixed",
    "discount_amount" => "10.00",
    "note" => "Urgent delivery",
    "issue_date" => "2023-01-01 15:15",
    "due_date" => "2023-01-15 15:15",
    "payment_type" => "mobile_money",
    "amount_received" => "200.00",
    "alert_customer" => "yes"
];

$sale_id = 'YOUR_SALE_ID'; // Replace 'YOUR_SALE_ID' with your actual sale ID
curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.keepup.store/v2.0/sales/edit/$sale_id",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json",
        "Authorization: Bearer API_KEY"
    ],
]);

$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

data = {
    "customer_name": "Chinedu Okeke",
    "phone_number": "+233801234567",
    "customer_email": "chinedu@example.com",
    "items": json.dumps([
        {
            "item_id": 11,
            "item_name": "Bananas",
            "quantity": 10,
            "price": 20,
            "item_type": "product"
        }
        # Add more items as needed...
    ]),
    "fulfillment_type": "delivery",
    "location_name": "Awesome Place",
    "location": "1234 Awesome Place Ave, Ghana",
    "lat": "40.7128",
    "lng": "-74.0060",
    "fulfillment_cost": "10.00",
    "discount_type": "fixed",
    "discount_amount": "10.00",
    "note": "Urgent delivery",
    "issue_date": "2023-01-01 15:15",
    "due_date": "2023-01-15 15:15",
    "payment_type": "mobile_money",
    "amount_received": "200.00",
    "alert_customer": "yes"
}

sale_id = 'YOUR_SALE_ID' # Replace 'YOUR_SALE_ID' with your actual sale ID
url = f"https://api.keepup.store/v2.0/sales/edit/{sale_id}"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer API_KEY"
}

response = requests.put(url, headers=headers, data=json.dumps(data))

try:
    response.raise_for_status()
    print(response.json())
except requests.exceptions.HTTPError as err:
    print(err)

```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "sale updated",
    "data": {
        "sale_id": 48001,
        "share_link": "https://keepup.store/v/01524188-65CJAY",
        "balance_due": "0.00",
        "amount_paid": "40.48",
        "amount_received": "200.00",
        "change": "159.52",
        "status": "receipt",
        "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 %}


---

# 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/edit-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.
