Returns a paginated list of sales sorted by date
 in descending order.
List All Sales
Header
Authorization String |
Set value to Bearer SECRET_KEY |
customer_id integer |
Specify an ID for the customer whose sales you want to retrieve |
product_id integer |
Specify an ID to retrieve sales for the selected product only |
variant_id integer |
Specify an ID to retrieve sales for the selected product variant only |
user_id integer |
Specify an ID to retrieve sales made by the selected employee only |
start_date datetime |
A timestamp from which to start listing sales. see date & time formats section |
end_date datetime |
A timestamp from which to stop listing sales. see date & time formats section |
limit integer |
Specify how many records you want to retrieve per page. If not specified we use a default value of 50. |
curl -L 'https://api.vendloop.com/sales/' \ -H 'Authorization: Bearer SECRET_KEY'
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.vendloop.com/sales', CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Authorization: Bearer SECRET_KEY' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer SECRET_KEY"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://api.vendloop.com/sales", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
val client = OkHttpClient() val request = Request.Builder() .url("https://api.vendloop.com/sales") .addHeader("Authorization", "Bearer SECRET_KEY") .build() val response = client.newCall(request).execute()
Sample Response
{ "status":true, "message":"Sale records found", "data":[ { "id":"50", "date":"2023-07-18 15:51:43", "due_date":null, "business_id":"1", "store_id":"1", "customer_id":"2", "user_id":"2", "reference_no":"SALE/POS/725185062173", "note":"", "order_tax":"62.0000", "paid":"1302.0000", "payment_status":"paid", "sale_status":"completed", "shipping":"0.0000", "staff_note":"", "sub_total":"1340.0000", "grand_total":"1302.0000", "total_discount":"100.0000", "total_tax":"62.0000", "updated_at":null, "updated_by":null, "device_id":null, "items":[ { "item_discount":"0.0000", "item_id":"9", "item_name":"Shoes (Children / Green)", "item_price":"80.0000", "item_tax":"0.0000", "item_type":"standard", "item_variant_id":"8", "item_variant_name":"Children / Green", "quantity":"2.0000", "sku":"17468468", "tax":null, "tax_method":"addition", "unit_code":"carton", "unit_id":"9" }, { "item_discount":"0.0000", "item_id":"9", "item_name":"Shoes (Children / Red)", "item_price":"90.0000", "item_tax":"0.0000", "item_type":"standard", "item_variant_id":"7", "item_variant_name":"Children / Red", "quantity":"2.0000", "sku":"17468468", "tax":null, "tax_method":"addition", "unit_code":"carton", "unit_id":"9" }, { "item_discount":"0.0000", "item_id":"4", "item_name":"Bottle Water", "item_price":"100.0000", "item_tax":"0.0000", "item_type":"standard", "quantity":"10.0000", "sku":"16216661", "tax":null, "tax_method":"subtraction", "unit_code":"bottle", "unit_id":"3" } ], "payments":[ { "id":"70", "date":"2023-07-18 15:51:43", "user_id":"2", "reference_no":"VPAY/509652487123", "paid_by":"cash", "amount":"1302.0000" } ], "tax":{ "id":"1", "name":"VAT @5%", "code":"vat5", "rate":"5.0000", "type":"percent" } } ], "metadata":{ "limit":50, "start":1, "total":1 } }
{ "status": false, "message": "Sale records not found" }
Fetch a Single Sale
Returns details of a sale with the given ID.
Header
Authorization String |
Set value to Bearer SECRET_KEY |
id required integer |
Auto-generated unique ID |
reference string |
Specify the reference number for this sale. this is ignored if the id parameter is used |
customer_id integer |
Specify an ID for the customer whose sale you want to retrieve |
product_id integer |
Specify an ID to retrieve sales for the selected product only |
variant_id integer |
Specify an ID to retrieve sales for the selected product variant only |
user_id integer |
Specify an ID to retrieve sales made by the selected employee only |
start_date datetime |
A timestamp from which to start listing sales. see date & time formats section |
end_date datetime |
A timestamp from which to stop listing sales. see date & time formats section |
curl -L 'https://api.vendloop.com/sales/{id}' \ -H 'Authorization: Bearer SECRET_KEY'
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.vendloop.com/sales/{id}', CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Authorization: Bearer SECRET_KEY' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer SECRET_KEY"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://api.vendloop.com/sales/{id}", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
val client = OkHttpClient() val request = Request.Builder() .url("https://api.vendloop.com/sales/{id}") .addHeader("Authorization", "Bearer SECRET_KEY") .build() val response = client.newCall(request).execute()
Sample Response
{ "status":true, "message":"Sale record found", "data":{ "id":"50", "date":"2023-07-18 15:51:43", "due_date":null, "business_id":"1", "store_id":"1", "customer_id":"2", "user_id":"2", "reference_no":"SALE/POS/725185062173", "note":"", "order_tax":"62.0000", "paid":"1302.0000", "payment_status":"paid", "sale_status":"completed", "shipping":"0.0000", "staff_note":"", "sub_total":"1340.0000", "grand_total":"1302.0000", "total_discount":"100.0000", "total_tax":"62.0000", "updated_at":null, "updated_by":null, "device_id":null, "items":[ { "item_discount":"0.0000", "item_id":"9", "item_name":"Shoes (Children / Green)", "item_price":"80.0000", "item_tax":"0.0000", "item_type":"standard", "item_variant_id":"8", "item_variant_name":"Children / Green", "quantity":"2.0000", "sku":"17468468", "tax":null, "tax_method":"addition", "unit_code":"carton", "unit_id":"9" }, { "item_discount":"0.0000", "item_id":"9", "item_name":"Shoes (Children / Red)", "item_price":"90.0000", "item_tax":"0.0000", "item_type":"standard", "item_variant_id":"7", "item_variant_name":"Children / Red", "quantity":"2.0000", "sku":"17468468", "tax":null, "tax_method":"addition", "unit_code":"carton", "unit_id":"9" }, { "item_discount":"0.0000", "item_id":"4", "item_name":"Bottle Water", "item_price":"100.0000", "item_tax":"0.0000", "item_type":"standard", "quantity":"10.0000", "sku":"16216661", "tax":null, "tax_method":"subtraction", "unit_code":"bottle", "unit_id":"3" } ], "payments":[ { "id":"70", "date":"2023-07-18 15:51:43", "user_id":"2", "reference_no":"VPAY/509652487123", "paid_by":"cash", "amount":"1302.0000" } ], "tax":{ "id":"1", "name":"VAT @5%", "code":"vat5", "rate":"5.0000", "type":"percent" } } }
{ "status": false, "message": "Sale record not found" }
Create a Sale
Create a sale. Returns the newly created sale.
Header
Authorization String |
Set value to Bearer SECRET_KEY |
user_id required integer |
The ID of the user associated with this sale. User IDs can be retrieved from the users endpoint. |
customer_id required integer |
The ID of the customer associated with this sale. Customer IDs can be retrieved from the customers endpoint. |
status required string |
Status of the sale.
|
items required string |
JSON encoded string of line items for this sale. |
payments string |
JSON encoded string of payments for this sale. |
reference string |
The invoice number for the sale. If none is provided it will be populated by Vendloop POS. |
date datetime |
The date of the sale. If not provided will be added as the time the sale reached the server. see date & time formats section |
discount double |
The discount value of the sale. |
discount_type string |
The discount type of the sale.
|
tax_id integer |
The ID of the tax associated with this sale. Tax IDs can be retrieved from the taxes endpoint. |
note string |
A note on the sale entered by the cashier. |
curl -L 'http://api.vendloop.com/sales' \ -H 'Authorization: Bearer SECRET_KEY' \ -d '{ "user_id": "1", "customer_id": "1", "status": "completed", "reference": "170652348409", "date": "2024-07-18 04:37:29", "discount": 5, "discount_type": "percent", "tax_id": 2, "note": "", "items": [ { "product_id": "1", "price": 100, "discount": 5, "discount_type": "percent", "quantity": 5, "variant_id": 5 } ], "payments": [ { "user_id": "1", "reference": "170652348409", "amount": 100, "paid_by": "cash", "date": "2024-07-18 04:37:29", "note": "" }, { "user_id": "1", "reference": "170652348410", "amount": 100, "paid_by": "deposit", "date": "2024-07-18 04:37:29", "note": "" } ] }'
<?php $fields = [ "user_id" => "1", "customer_id" => "1", "status" => "completed", "reference" => "170652348409", "date" => "2024-07-18 04:37:29", "discount" => 5, "discount_type" => "percent", "tax_id" => 2, "note" => "", "items" => json_encode([ [ "product_id" => "1", "price" => 100, "discount" => 5, "discount_type" => "percent", "quantity" => 5, "variant_id" => 5 ] ]), "payments" => json_encode([ [ "user_id" => "1", "reference" => "170652348409", "amount" => 100, "paid_by" => "cash", "date" => "2024-07-18 04:37:29", "note" => "" ], [ "user_id" => "1", "reference" => "170652348410", "amount" => 100, "paid_by" => "deposit", "date" => "2024-07-18 04:37:29", "note" => "" ] ]) ]; $fields_string = http_build_query($fields); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.vendloop.com/sales', CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $fields_string, CURLOPT_HTTPHEADER => array( 'Authorization: Bearer SECRET_KEY' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer SECRET_KEY"); var formdata = new FormData(); formdata.append("user_id", "1"); formdata.append("customer_id", "1"); formdata.append("status", "completed"); formdata.append("reference", "170652348409"); formdata.append("date", "2024-07-18 04:37:29"); formdata.append("discount", 5); formdata.append("discount_type", "percent"); formdata.append("tax_id", 2); formdata.append("note", ""); formdata.append("items", JSON.stringify([{"product_id": "1", "price": 100, "discount": 5, "discount_type": "percent", "quantity": 5, "variant_id": 5}])); formdata.append("payments", JSON.stringify([{"user_id": "1", "reference": "170652348409", "amount": 100, "paid_by": "cash", "date": "2024-07-18 04:37:29", "note": ""}, {"user_id": "1", "reference": "170652348410", "amount": 100, "paid_by": "deposit", "date": "2024-07-18 04:37:29", "note": ""}])); var requestOptions = { method: 'POST', headers: myHeaders, body: formdata, redirect: 'follow' }; fetch("https://api.vendloop.com/sales", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
val client = OkHttpClient() val mediaType = "text/plain".toMediaType() val body = MultipartBody.Builder().setType(MultipartBody.FORM) .addFormDataPart("user_id", "1") .addFormDataPart("customer_id", "1") .addFormDataPart("status", "completed") .addFormDataPart("reference", "170652348409") .addFormDataPart("date", "2024-07-18 04:37:29") .addFormDataPart("discount", 5) .addFormDataPart("discount_type", "percent") .addFormDataPart("tax_id", 2) .addFormDataPart("note", "") .addFormDataPart("items", Gson().toJson([{"product_id": "1", "price": 100, "discount": 5, "discount_type": "percent", "quantity": 5, "variant_id": 5}])) .addFormDataPart("payments", Gson().toJson([{"user_id": "1", "reference": "170652348409", "amount": 100, "paid_by": "cash", "date": "2024-07-18 04:37:29", "note": ""}, {"user_id": "1", "reference": "170652348410", "amount": 100, "paid_by": "deposit", "date": "2024-07-18 04:37:29", "note": ""}])) .build() val request = Request.Builder() .url("https://api.vendloop.com/sales") .post(body) .addHeader("Authorization", "Bearer SECRET_KEY") .build() val response = client.newCall(request).execute()
Sample Response
{ "status": true, "message": "Sale record added", "data": { "id": "187", "date": "2024-07-18 12:01:50", "due_date": null, "business_id": "1", "store_id": "1", "customer_id": "2", "user_id": "2", "reference": "SALE/032558986109", "note": "", "order_tax": "0.0000", "paid": "206.6250", "payment_status": "paid", "sale_status": "completed", "shipping": "0.0000", "staff_note": "", "sub_total": "217.5000", "grand_total": "206.6250", "total_discount": "10.8750", "total_tax": "0.0000", "updated_at": null, "updated_by": null, "device_id": null, "items": [ { "item_discount": "0.0000", "item_id": "4", "item_name": "Bottle Water", "item_price": "142.5000", "item_tax": "0.0000", "item_type": "standard", "quantity": "1.0000", "sku": "16216661", "tax": null, "tax_method": "subtraction", "unit_code": "bottle", "unit_id": "3" }, { "item_discount": "0.0000", "item_id": "26", "item_name": "Apple", "item_price": "75.0000", "item_tax": "0.0000", "item_type": "standard", "quantity": "1.0000", "sku": "16132561", "tax": null, "tax_method": "subtraction", "unit_code": "ball", "unit_id": "1" } ], "payments": [ { "id": "202", "date": "2024-07-18 12:01:50", "user_id": "2", "reference_no": "049208965727", "paid_by": "cash", "amount": "103.3125" }, { "id": "203", "date": "2024-07-18 12:01:50", "user_id": "2", "reference_no": "780383676091", "paid_by": "cash", "amount": "103.3125" } ], "tax": null } }
{ "status": false, "message": "Failed to add sale" }
Delete a Single Sale
Delete sale with the given ID.
Header
Authorization String |
Set value to Bearer SECRET_KEY |
id required integer |
The ID of the sale to be deleted. |
curl -L 'http://api.vendloop.com/sales/delete' \ -H 'Authorization: Bearer SECRET_KEY' \ -F 'id="{id}"'
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.vendloop.com/sales/delete', CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('id' => '{id}'), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer SECRET_KEY' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer SECRET_KEY"); var formdata = new FormData(); formdata.append("id", "{id}"); var requestOptions = { method: 'POST', headers: myHeaders, body: formdata, redirect: 'follow' }; fetch("https://api.vendloop.com/sales/delete", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
val client = OkHttpClient() val mediaType = "text/plain".toMediaType() val body = MultipartBody.Builder().setType(MultipartBody.FORM) .addFormDataPart("id","{id}") .build() val request = Request.Builder() .url("https://api.vendloop.com/sales/delete") .post(body) .addHeader("Authorization", "Bearer SECRET_KEY") .build() val response = client.newCall(request).execute()
Sample Response
{ "status":true, "message":"Sale record deleted" }
{ "status": false, "message": "Sale record not found" }