Skip to content
Last updated

GetQuotes

Obtain quotes matching the passed criteria

Request Parameters

ParameterTypeDescriptionRequired
actionstring"GetQuotes"Required
limitstartintThe offset for the returned quote data (default: 0).Optional
limitnumintThe number of records to return (default: 25).Optional
quoteidintA specific quote ID to find quotes for.Optional
useridintA specific client to find quotes for.Optional
subjectstringA specific subject to find quotes for.Optional
stagestringA specific stage ('Draft','Delivered','On Hold','Accepted','Lost', or 'Dead') to find quotes for.Optional
datecreatedstringA specific created date to find quotes for. Format: Y-m-dOptional
lastmodifiedstringA specific last modified date to find quotes for. Format: Y-m-dOptional
validuntilstringA specific valid until date to find quotes for. Format: Y-m-dOptional

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
totalresultsintThe total number of results available.
startnumberintThe starting number for the returned results.
numreturnedintThe number of results returned.
quotesarrayAn array of quotes matching the criteria passed.

Example Request (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'GetQuotes',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

$command = 'GetQuotes';
$postData = array(
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

Example Response JSON

{
    "result": "success",
    "totalresults": 2,
    "startnumber": 0,
    "numreturned": 2,
    "quotes": {
        "quote": [
            {
                "id": 2,
                "subject": "",
                "stage": "Draft",
                "validuntil": "2023-01-30",
                "userid": 1,
                "client": {
                    "id": 1,
                    "firstname": "Richard",
                    "lastname": "Example",
                    "companyname": "Example Inc.",
                    "email": "[email protected]",
                    "datecreated": "2022-12-30",
                    "groupid": 0,
                    "status": "Active"
                },
                "firstname": "",
                "lastname": "",
                "companyname": "",
                "email": "",
                "address1": "",
                "address2": "",
                "city": "",
                "state": "",
                "postcode": "",
                "country": "US",
                "phonenumber": "",
                "tax_id": "",
                "currency": 1,
                "subtotal": "15.86",
                "tax1": "0.00",
                "tax2": "0.00",
                "total": "15.86",
                "proposal": "",
                "customernotes": "",
                "adminnotes": "",
                "datecreated": "2022-12-30",
                "lastmodified": "2022-12-30",
                "datesent": "0000-00-00",
                "dateaccepted": "0000-00-00",
                "items": {
                    "item": [
                        {
                            "id": 1,
                            "description": "Apple",
                            "quantity": "1",
                            "unitprice": "1.23",
                            "discount": "0.00",
                            "taxable": 1
                        },
                        {
                            "id": 2,
                            "description": "Pear",
                            "quantity": "3",
                            "unitprice": "5.00",
                            "discount": "2.50",
                            "taxable": 0
                        }
                    ]
                }
            },
            {
                "id": 1,
                "subject": "",
                "stage": "Draft",
                "validuntil": "2023-01-29",
                "userid": 0,
                "client": null,
                "firstname": "William",
                "lastname": "Smith",
                "companyname": "",
                "email": "",
                "address1": "",
                "address2": "",
                "city": "",
                "state": "",
                "postcode": "",
                "country": "US",
                "phonenumber": "",
                "tax_id": "",
                "currency": 1,
                "subtotal": "0.00",
                "tax1": "0.00",
                "tax2": "0.00",
                "total": "0.00",
                "proposal": "",
                "customernotes": "",
                "adminnotes": "",
                "datecreated": "2022-12-29",
                "lastmodified": "2022-12-30",
                "datesent": "0000-00-00",
                "dateaccepted": "0000-00-00",
                "items": {
                    "item": []
                }
            }
        ]
    }
}

Version History

VersionChangelog
1.0Initial Version
8.7Add the 'client' key to the quote response. If an existing client has been associated to the quote, select client information is returned.