The Invoice API lets integrators list, filter, order and retrieve invoices, fetch invoice and statement PDFs, and void or bad-debt an invoice. Base URL: https://billing.pracbill.com.au/api/:tokenid/....
GET /:tokenid/invoice/getRetrieve all invoices.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/invoice/get',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true,
"invoices": {
"121509": {
"iid":"121509",
"uid":"121",
"cid":"6874970",
"shipto":"6874970",
"terms":"30",
"date":"2015-07-08 00:00:00",
"comments":"",
"shipvia":"Local Delivery",
"shipprice":"0.00",
"taxrate_shipprice":"10.0000",
"ex_tax_shipprice":"0.0000",
"tax_shipprice":"0.0000",
"inc_tax_shipprice":"0.0000",
"tax_total":"180.0000",
"total":"1980.0000",
"company":"The Fastener Factory",
"poid":"0",
"paid":"0",
"shipdate":"0000-00-00",
"void":"0",
"tax":"10.00",
"duedate":"2015-08-07",
"id":"0",
"discountcode":"",
"pjid":"0",
"chid":"0",
"call_startrange":"0000-00-00",
"call_endrange":"0000-00-00",
"call_addcalls":"0",
"deptid":"75",
"eng_addsrvfee":"0",
"sequence":"1",
"invoice_type":"General",
"is_kitchen":"0",
"kitchen_processed":"0",
"time":null,
"next_month":"0",
"bad_debt":null,
"total_amount":null,
"tax_amount":null,
"total_inc_tax_amount":null,
"pos_id":null,
"pos_object":null,
"date_modified":"2016-08-02 11:37:46",
"user_modified":"121",
"order_number":"0",
"reconciled":null,
"balance":"1980.0000",
"table_number":"0",
"training_mode":"0",
"tip_amount":"0.0000",
"payments": [{
"payid": 1502, "date": "2016-08-02 11:55:22", "amount": "20", "type": "credit", "full_total": "20"
}],
"items":[ {
"iiid": "330736", "iid": "121509", "pid": "90180", "partnumber": "XENTERM15", "description": "XeniPOS 15\" Touch Screen Terminal", "quantity": "1.0000", "inc_tax_amount": "1705.00000", "ex_tax_amount": "1550.00000", "price": "1550.0000", "cost": "0.00", "backorder": "0", "taxable": "0", "tracked": "0", "weight": "0.00", "chid": "0", "pax_num": "0", "deleted": "0", "user_modified": "121", "date_created": "2015-07-08 14:29:46", "date_modified": "2015-07-08 14:30:44", "taxrate": "10.0000", "tax_amount": "155.0000", "taxrate_id": null, "subtotal": "1705.00000", "training_mode": "0", "parent_iiid": null, "imagefile": "1447700102232019012_75_1435818378_imagefile_sd-pos-vbm-1.jpg", "total": 1550, "price_inc_tax": 1705, "total_inc_tax": 1705
}
,
{
"iiid": "330737", "iid": "121509", "pid": "49077", "partnumber": "misc", "description": "EPSON ethernet Receipt Printer", "quantity": "1.0000", "inc_tax_amount": "275.00000", "ex_tax_amount": "250.00000", "price": "250.0000", "cost": "0.91", "backorder": "0", "taxable": "0", "tracked": "1", "weight": "0.00", "chid": "0", "pax_num": "0", "deleted": "0", "user_modified": "121", "date_created": "2015-07-08 14:30:54", "date_modified": "2015-07-08 14:31:24", "taxrate": "10.0000", "tax_amount": "25.0000", "taxrate_id": null, "subtotal": "275.00000", "training_mode": "0", "parent_iiid": null, "imagefile": null, "total": 250, "price_inc_tax": 275, "total_inc_tax": 275
}
],
"engineering_items":[]
}
Response (error)
{"success":false,"description":"no invoices found"}
GET /:tokenid/invoice/get/filter/:filter/page/:pagenumberRetrieve a paged list of invoices matching a filter.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
filter |
string | Yes | Filter expression in the form {FILTER}{OPERATOR}{FILTER DATA}, e.g. balance>10 (see filter options below). |
pagenumber |
integer | Yes | Page number of results to return. |
| Filter | Type | Description |
|---|---|---|
bad_debt |
boolean | Invoices marked as Bad Debt |
paid |
boolean | Invoices marked as Paid |
date_modified |
date | Invoices that have been modified after or before date passed in |
date |
date | Invoices that have had the date set to the date, before or after, depending on operator |
duedate |
date | Invoices that have had the duedate set to the date, before or after, depending on operator |
balance |
float | Invoices that have had the balance owing equal to, more or less depending on operator |
draft |
boolean | Invoices marked as draft |
The format for the filter is {FILTER}{OPERATOR}{FILTER DATA}, for example balance>10. If you only pass the filter in, without an operator and filter data, it will assume that the operator is = and the data is 1.
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/invoice/get/filter/date_modified>=2018-06-01/page/1',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"results": [{
"id": "123456",
"Type": "Phone",
"Company": "Some Company",
"Date": "27-06-2018",
"Due Date": "27-07-2018",
"Status": "Paid",
"Reconciled": "No",
"Amount": "$120.00",
"": "None Assigned"
}, ..... more results ....
],
"page_number": "1",
"total_pages": 138
}
Response (error)
{"success":false,"description":"no invoices found"}
POST /:tokenid/invoice/getRetrieve all invoices in a certain order. To have the returned data ordered, change the request method to POST and pass the order_by variable set to one of the allowed fields.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
order_by |
string | Field to order by: iid, cid, date, company, duedate or balance. |
Request
var myData = { order_by: 'iid', }
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/invoice/get',
type: 'POST',
data: JSON.stringify(myData),
contentType: 'application/json',
success: function( response ) { console.log(response); }
});
Response (success)
Most of the invoice information has been removed from this example to save space.
{
"success":true,
"invoices": {
"42971": {
"iid": "42971",
"date": "2014-10-01 00:00:00",
}
,
"78523": {
"iid": "78523",
"date": "2015-02-10 00:00:00",
}
}
}
Response (error)
{"success":false,"description":"no invoices found"}
GET /:tokenid/invoice/get/:iidRetrieve a specific invoice. The response includes the complete invoice data including any items or services associated with it.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
iid |
integer | Yes | Invoice ID. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/invoice/get/213281',
data: JSON.stringify(myData),
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true,
"invoice": {
"iid":"35466",
"uid":"121",
"cid":"6874647",
"shipto":"6874647",
"terms":"14",
"date":"2014-09-05 00:00:00",
"comments":"",
"shipvia":"Pickup",
"shipprice":"0.00",
"taxrate_shipprice":"10.0000",
"ex_tax_shipprice":"0.0000",
"tax_shipprice":"0.0000",
"inc_tax_shipprice":"0.0000",
"tax_total":"8.1810",
"total":"29.9970",
"company":"Golfing Zone",
"poid":"0",
"paid":"1",
"shipdate":"0000-00-00",
"void":"0",
"tax":"10.00",
"duedate":"2014-09-19",
"id":"0",
"discountcode":"",
"pjid":"0",
"chid":"0",
"call_startrange":"2014-08-01",
"call_endrange":"2014-08-31",
"call_addcalls":"0",
"deptid":"75",
"eng_addsrvfee":"1",
"sequence":"3",
"invoice_type":"General",
"is_kitchen":"0",
"kitchen_processed":"0",
"time":null,
"next_month":"0",
"bad_debt":null,
"total_amount":null,
"tax_amount":null,
"total_inc_tax_amount":null,
"pos_id":null,
"pos_object":null,
"date_modified":"2015-12-04 00:22:02",
"user_modified":"50",
"order_number":"0",
"reconciled":null,
"balance":"-0.0030",
"table_number":"0",
"training_mode":"0",
"tip_amount":"0.0000",
"items":[],
"engineering_items":[ {
"iesid": "42818", "iid": "35466", "enid": "3481834", "fee": "18.18", "tax_amount": "1.8180", "taxrate": "10.0000", "taxrate_id": "0", "inc_tax_amount": "19.9980", "ex_tax_amount": "18.1800", "svrtype": "537", "svrnum": "Dept 59 (Golfing Zone)", "training_mode": "0", "description": "XeniPOS Base - Dept 59 (Golfing Zone)"
}
,
{
"iesid": "42819", "iid": "35466", "enid": "3481835", "fee": "9.09", "tax_amount": "0.9090", "taxrate": "10.0000", "taxrate_id": "0", "inc_tax_amount": "9.9990", "ex_tax_amount": "9.0900", "svrtype": "538", "svrnum": "Pro Shop (Golfing Zone)", "training_mode": "0", "description": "XeniPOS Terminal - Pro Shop (Golfing Zone)"
}
]
}
Response (error)
{"success":false,"description":"invoice not found"}
GET /:tokenid/invoice/get/customer/:cidRetrieve all invoices and related items assigned to a customer. The response includes the complete invoice data assigned to the customer as well as any items or services associated with it. A filtered form is also available:
/:tokenid/invoice/get/customer/:cid/filter/:filter
The filter is the same as the filter described under Filtered invoice list above.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
cid |
integer | Yes | Customer ID. |
filter |
string | No | Filter expression, e.g. balance>10 (see Filter options above). |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/invoice/get/customer/7029730',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true,
"invoices": {
"213281": {
"iid":"213281",
"uid":"0",
"cid":"7029730",
"shipto":"7029730",
"terms":"",
"date":"2016-08-15 00:00:00",
"comments":"",
"shipvia":"Pickup",
"shipprice":"0.00",
"taxrate_shipprice":"0.0000",
"ex_tax_shipprice":"0.0000",
"tax_shipprice":"0.0000",
"inc_tax_shipprice":"0.0000",
"tax_total":"0.0000",
"total":"200.0000",
"company":"",
"poid":"",
"paid":"0",
"shipdate":"0000-00-00",
"void":"0",
"tax":"0.00",
"duedate":"0000-00-00",
"id":"0",
"discountcode":"",
"pjid":"0",
"chid":"0",
"call_startrange":"0000-00-00",
"call_endrange":"0000-00-00",
"call_addcalls":"0",
"deptid":"106",
"eng_addsrvfee":"0",
"sequence":"0",
"invoice_type":"VWS",
"is_kitchen":"0",
"kitchen_processed":"0",
"time":"00:00:00",
"next_month":"0",
"bad_debt":"0000-00-00",
"total_amount":"0.0000",
"tax_amount":"0.0000",
"total_inc_tax_amount":"0.0000",
"pos_id":"",
"pos_object":"",
"date_modified":"2016-08-15 09:58:47",
"user_modified":"210",
"order_number":"0",
"reconciled":"0",
"balance":"200.0000",
"table_number":"0",
"training_mode":"0",
"tip_amount":"0.0000",
"items": {
"iitems":[ {
"iiid": "577146", "iid": "213281", "pid": "0", "partnumber": "", "description": "", "quantity": "0.0000", "inc_tax_amount": "0.00000", "ex_tax_amount": "0.00000", "price": null, "cost": "0.00", "backorder": "0", "taxable": "0", "tracked": "0", "weight": "0.00", "chid": "0", "pax_num": "0", "deleted": "0", "user_modified": "210", "date_created": "2016-08-15 09:58:47", "date_modified": "2016-08-15 09:58:47", "taxrate": "0.0000", "tax_amount": "0.0000", "taxrate_id": "374", "subtotal": "200.00000", "training_mode": "0", "parent_iiid": "0"
}
],
"services":[],
"calls":[]
}
}
}
}
Response (error)
{"success":false,"description":"no customer invoices"}
GET /:tokenid/customer/get/statement/:cidDisplays a PDF of a customer statement. The return data for this request is a PDF file, so you must point your browser at the URL rather than using ajax.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
cid |
integer | Yes | Customer ID. |
Request
document.location.href = "/api/892f86d5-da86-4e98-9343-1976a375/invoice/get/statement/207853";
Response
A PDF file.
GET /:tokenid/invoice/get/pdf/:iidDisplays a PDF of an invoice. The return data for this request is a PDF file, so you must point your browser at the URL rather than using ajax.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
iid |
integer | Yes | Invoice ID. |
Request
document.location.href = "/api/892f86d5-da86-4e98-9343-1976a375/invoice/get/pdf/115645";
Response
A PDF file.
GET /:tokenid/invoice/:iid/voidVoid an invoice.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
iid |
integer | Yes | Invoice ID. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/invoice/123123/void',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true
}
GET /:tokenid/invoice/:iid/bad_debtMark an invoice as bad debt.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenid |
string | Yes | Your API access token. |
iid |
integer | Yes | Invoice ID. |
Request
$.ajax({
url: '/api/892f86d5-da86-4e98-9343-1976a375/invoice/123123/bad_debt',
type: 'GET',
contentType: 'application/json',
success: function( response ) {
console.log(response);
}
});
Response (success)
{
"success":true
}
Related: Getting started with the API, API overview, Customer API, Credit management API.