Obtain a list of email templates from the system
| Parameter | Type | Description | Required |
|---|---|---|---|
| action | string | "GetEmailTemplates" | Required |
| type | string | The type of email template to retrieve | Optional |
| language | string | The language of the email template to retrieve, if none provided will return default language templates. | Optional |
| Parameter | Type | Description |
|---|---|---|
| result | string | The result of the operation: success or error |
| totalresults | int | The total number of results returned |
| emailtemplates | array | The email templates entries returned |
$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' => 'GetEmailTemplates',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'type' => 'general',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);$command = 'GetEmailTemplates';
$postData = array(
'type' => 'general',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
print_r($results);{
"result": "success",
"totalresults": "2",
"emailtemplates[emailtemplate][0][id]": "38",
"emailtemplates[emailtemplate][0][name]": "Automated Password Reset",
"emailtemplates[emailtemplate][0][subject]": "Your new password for {$company_name}",
"emailtemplates[emailtemplate][0][custom]": "0",
"emailtemplates[emailtemplate][1][id]": "64",
"emailtemplates[emailtemplate][1][name]": "Client Email Address Verification",
"emailtemplates[emailtemplate][1][subject]": "Confirm Your Registration",
"emailtemplates[emailtemplate][1][custom]": "0"
}| Version | Changelog |
|---|---|
| 1.0 | Initial Version |