# List Sales

### Endpoint

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

### Headers

`Authorization: Bearer API_KEY`

### Query Parameters

<table data-full-width="false"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><h4><strong>date_from</strong></h4><p><em>date</em></p></td><td>optional</td><td><p>Start date for filtering sales records </p><p><code>(format: YYYY-MM-DD)</code>.</p></td></tr><tr><td><h4><strong>date_to</strong></h4><p><em>date</em></p></td><td>optional</td><td><p>End date for filtering sales records </p><p><code>(format: YYYY-MM-DD)</code>.</p></td></tr><tr><td><h4><strong>customer</strong></h4><p><em>string</em></p></td><td>optional</td><td>Filter sales by customer name or customer code.</td></tr><tr><td><h4>phone_number</h4><p><em>string</em></p></td><td>optional</td><td>Filter sales by customer's phone number.</td></tr><tr><td><h4><strong>sale_number</strong></h4><p><em>number</em></p></td><td>optional</td><td>Specific sale number to retrieve.</td></tr><tr><td><h4><strong>sale_status</strong></h4><p><em>string</em></p></td><td>optional</td><td><p>Filter sales based on the status </p><p><code>( receipt, invoice, quote )</code>.</p></td></tr><tr><td><h4><strong>sale_origin</strong></h4><p><em>string</em></p></td><td>optional</td><td><p>Filter sales based on the origin </p><p><code>( business, storefront )</code>.</p></td></tr><tr><td><h4><strong>page</strong></h4><p><em>number</em></p></td><td>optional</td><td>Specify the page number for pagination <code>(default is 1)</code>.</td></tr></tbody></table>

### Sample Requests

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

```javascript
const axios = require('axios');

const config = {
    method: 'get',
    url: 'https://api.keepup.store/v2.0/sales',
    headers: {
        'Authorization': 'Bearer API_KEY' // Replace 'API_KEY' with your actual API key
    }
};

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

{% endcode %}
{% endtab %}

{% tab title="PHP" %}

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

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.keepup.store/v2.0/sales',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY' // Replace 'API_KEY' with your actual API key
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.keepup.store/v2.0/sales"
headers = {
    "Authorization": "Bearer API_KEY" # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, headers=headers)
print(response.json())

```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Sales found: 51",
    "data": {
        "meta": {
            "total_records": 51,
            "amount_paid": "59,092.30",
            "balance_due": "87,065.10"
        },
        "sales": [
            {
                "sale_id": 46099,
                "sale_number": "62",
                "customer_name": "Kofi Nti",
                "customer_phone_number": "+233201234567",
                "customer_email": "kofinti@gmail.com",
                "issued_by": "Jojo",
                "total_amount": "500.00",
                "amount_paid": "500.00",
                "balance_due": "0.00",
                "status": "receipt",
                "sale_origin": "business",
                "viewed": 3,
                "feedback": null,
                "order_log": null,
                "change": "0.00",
                "created_at": "2023-06-01 12:06:12",
                "updated_at": "2023-06-01 12:10:20"
            },
            ...
        ]
    }
}
```

{% endtab %}

{% tab title="Error" %}

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

{% endtab %}
{% endtabs %}
