# Fetch Sale

### Endpoint

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

### Headers

`Authorization: Bearer API_KEY`

### Path Parameters

|                                                                                              |          |                                                                                                |
| -------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------- |
| <p><strong>sales\_id</strong>                                     </p><p><em>number</em></p> | required | The ID of the sale whose details are being requested. This should be passed as part of the URL |

## Sample Requests

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

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

const sale_id = 'YOUR_SALE_ID'; // Replace 'YOUR_SALE_ID' with your actual sale ID
const config = {
    method: 'get',
    url: `https://api.keepup.store/v2.0/sales/{sale_id}`,
    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
$sale_id = 'YOUR_SALE_ID'; // Replace 'YOUR_SALE_ID' with your actual sale ID
$url = 'https://api.keepup.store/v2.0/sales/' . $sale_id;

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer API_KEY' // Replace 'API_KEY' with your actual API key
  ],
]);

$response = curl_exec($curl);

if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}

curl_close($curl);
?>

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

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

try:
    response = requests.get(url, headers=headers)
    print(response.json())
except requests.exceptions.RequestException as e:
    print(e)
```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "Sale found",
    "data": {
        "sale_info": {
            "sale_id": 46099,
            "sale_number": "62",
            "customer_uuid": "12345",
            "customer_name": "Maureen",
            "customer_phone_number": "+2332612345678",
            "customer_email": "nanadrinks@gmail.com",
            "issued_by": "Jojo",
            "total_amount": "500.00",
            "amount_paid": "500.00",
            "change": "0.00",
            "amount_received": "500.00",
            "balance_due": "0.00",
            "delivery_pickup": null,
            "discount": {
                "discount_amount": "0.00",
                "discount_percentage": "0.00",
                "discount_type": "fixed"
            },
            "tax_profile_id": null,
            "tax_amount": "0.00",
            "taxes": null,
            "status": "receipt",
            "sale_origin": "business",
            "viewed": 3,
            "viewed_at": "2023-06-01 12:12:50",
            "note": null,
            "customer_note": null,
            "share_link": "https://keepup.store/v/ZUSAPZ-01623188",
            "a4_print_link": "https://keepup.store/v/ZUSAPZ-01623188/a4-print",
            "thermal_print_link": "https://keepup.store/v/ZUSAPZ-01623188/thermal-print",
            "items": [
                {
                    "item_type": "service",
                    "item_name": "June Subscription 2023",
                    "description": null,
                    "price": "500.00",
                    "quantity": 1,
                    "total": "500.00"
                }
            ],
            "payment_log": [
                {
                    "updated_by": "Jojo",
                    "amount_received": "500.00",
                    "amount_paid": "500.00",
                    "balance_remaining": "0.00",
                    "payment_type": "MTN Mobile Money",
                    "created_at": "2023-06-01 12:10:20"
                }
            ],
            "order_log": [],
            "feedback": {
                "rate": null,
                "message": null
            },
            "sub_total": "500.00",
            "due_date": "2023-06-08 12:06:13",
            "issued_date": "2023-06-01 12:06:12",
            "created_at": "2023-06-01 12:08:32",
            "updated_at": "2023-06-01 12:10:20"
        },
        "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/fetch-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.
