# Add Sale

## Endpoint

<mark style="color:purple;">**`POST`**</mark> `https://api.keepup.store/v2.0/sales/add`

## Headers

`Authorization: Bearer API_KEY`

## Body Parameters

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

{% hint style="info" %}
`sale_type` is set automatically when `amount_received` is more than `0 (zero)`. To learn more [**checkout the sale cycle**](/docs/tutorials/sales.md#understanding-the-sales-cycle)**.**
{% endhint %}

## Sample Requests

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

```javascript
const axios = require('axios');
const data = {
  customer_name: "Efia Konadu",
  phone_number: "+233201234567",
  customer_email: "efia@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 config = {
  method: 'post',
  url: 'https://api.keepup.store/v2.0/sales/add',
  headers: { 
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {access_token}'
  },
  data: data
};

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

```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}

```php
$curl = curl_init();

$data = json_encode([
  "customer_name" => "John Doe",
  "phone_number" => "+1234567890",
  "customer_email" => "johndoe@example.com",
  "items" => json_encode([["item_name" => "Widget A", "quantity" => 2, "price" => 19.99, "item_type" => "product"]]),
  "fulfillment_type" => "delivery",
  "location_name" => "Main Warehouse",
  "location" => "1234 Warehouse Ave, City",
  "lat" => "40.7128",
  "lng" => "-74.0060",
  "fulfillment_cost" => "5.00",
  "discount_type" => "percentage",
  "discount_amount" => "10",
  "note" => "Urgent delivery",
  "issue_date" => "2023-01-01 15:15",
  "due_date" => "2023-01-15 15:15",
  "payment_type" => "Credit Card",
  "amount_received" => "200.00",
  "alert_customer" => "yes",
  "sale_type" => "invoice"
]);

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.keepup.store/v2.0/sales/add",
  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/add"
payload = json.dumps({
  "customer_name": "John Doe",
  "phone_number": "+1234567890",
  "customer_email": "johndoe@example.com",
  "items": "[{\"item_name\":\"Widget A\", \"quantity\":2, \"price\":19.99, \"item_type\":\"product\"}]",
  "fulfillment_type": "delivery",
  "location_name": "Main Warehouse",
  "location": "1234 Warehouse Ave, City",
  "lat": "40.7128",
  "lng": "-74.0060",
  "fulfillment_cost": "5.00",
  "discount_type": "percentage",
  "discount_amount": "10",
  "note": "Urgent delivery",
  "issue_date": "2023-01-01 15:15",
  "due_date": "2023-01-15 15:15",
  "payment_type": "Credit Card",
  "amount_received": "200.00",
  "alert_customer": "yes",
  "sale_type": "invoice"
})
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 recorded",
    "data": {
        "sale_id": 48001,
        "share_link": "https://keepup.store/v/01524BB-65CJAY",
        "balance_due": "0.00",
        "amount_paid": "200.00",
        "amount_received": "200.00",
        "change": "0.00",
        "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/add-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.
