Retrieve a list of invoices.

Request Parameters

Parameter Type Description Required
action string “GetInvoices” Required
limitstart int The offset for the returned invoice data (default: 0) Optional
limitnum int The number of records to return (default: 25) Optional
userid int Find invoices for a specific client id Optional
status string Find invoices for a specific status. Standard Invoice statuses plus Overdue Optional
orderby string The field to sort results by. Accepted values are: id, invoicenumber, date, duedate, total, status Optional
order string Order sort attribute. Accepted values are: asc or desc. Optional

Response Parameters

Parameter Type Description
result string The result of the operation: success or error
totalresults int The total number of results available
startnumber int The starting number for the returned results
numreturned int The number of results returned
invoices array An array of invoices matching the criteria passed

Example Request (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            'action' => 'GetInvoices',
            // See
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'userid' => '1',
            'orderby' => 'invoicenumber',
            'responsetype' => 'json',
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);

Example Request (Local API)

$command = 'GetInvoices';
$postData = array(
    'userid' => '1',
    'orderby' => 'invoicenumber',
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);

Example Response JSON

    "result": "success",
    "totalresults": "1",
    "startnumber": "0",
    "numreturned": "1",
    "invoices[invoice][0][id]": "1",
    "invoices[invoice][0][userid]": "1",
    "invoices[invoice][0][firstname]": "Test",
    "invoices[invoice][0][lastname]": "Client",
    "invoices[invoice][0][companyname]": "",
    "invoices[invoice][0][invoicenum]": "",
    "invoices[invoice][0][date]": "2016-01-01",
    "invoices[invoice][0][duedate]": "2016-01-08",
    "invoices[invoice][0][datepaid]": "0000-00-00 00:00:00",
    "invoices[invoice][0][subtotal]": "15.95",
    "invoices[invoice][0][credit]": "0.00",
    "invoices[invoice][0][tax]": "0.00",
    "invoices[invoice][0][tax2]": "0.00",
    "invoices[invoice][0][total]": "15.95",
    "invoices[invoice][0][taxrate]": "0.00",
    "invoices[invoice][0][taxrate2]": "0.00",
    "invoices[invoice][0][status]": "Unpaid",
    "invoices[invoice][0][paymentmethod]": "authorize",
    "invoices[invoice][0][notes]": "",
    "invoices[invoice][0][currencycode]": "USD",
    "invoices[invoice][0][currencyprefix]": "$",
    "invoices[invoice][0][currencysuffix]": "USD"

Version History

Version Changelog
1.0 Initial Version
7.7 Added orderby and order parameters to control returned sorting.