whmcs.php¶
WHMCS integration module for managing clients, invoices, credits, order cancellations, and server billing data.
API Methods¶
| Method | Action | Description |
|---|---|---|
add_contact | create contact | Adds a new contact to an existing client in the billing system. |
apply_credit | apply credit | Applies credit from the client's balance to pay a specified invoice. |
create_addfunds | create add funds invoice | Creates an invoice for adding funds (Add Funds). |
delete_cancellation_request | delete cancellation request | Removes an active server cancellation request and restores the invoice. |
delete_contact | delete contact | Removes a contact from the client account. |
download_invoice | download invoice | Generates and returns the invoice PDF file. |
generate_due_invoice | generate invoice | Generates the next invoice for server payment. |
get_billing_data | get billing data | Retrieves synchronized billing data for a server. |
get_cancellation_requests | get cancellation requests | Returns a list of active server cancellation requests. |
get_client | get client data | Returns information about the authorized client or by ID. |
get_clientgroups | get client groups | Returns a list of client groups in the billing system. |
get_contacts | get contacts | Returns a list of additional client contacts. |
get_invoice | get invoice | Returns data for a specific invoice. |
get_invoices | get invoices | Returns a list of client invoices. |
get_related_invoices | get related invoices | Returns invoices linked to a server or account. |
getcredits | get credits | Returns the client's credit history. |
getpaymentgw | get payment gateways | Returns available payment methods for an invoice. |
mass_pay | mass payment | Pays multiple invoices with a single payment. |
request_cancellation | request cancellation | Initiates the server cancellation process with refund calculation. |
reset_password | reset password | Initiates a password reset or sets a new one with 2FA. |
transactions | get transactions | Returns the client's transaction history. |
update_client | update client | Updates the client profile data in the billing system. |
update_contact | update contact | Updates the client contact data. |
whmcs/add_contact¶
Adds a new contact to an existing client in the billing system.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: add_contact |
| token | ✅ | string | Authorization token |
| profile_data[email] | ✅ | string | New contact email |
| profile_data[password2] | ✅ | string | Password for the new contact |
| profile_data[firstname] | ❌ | string | Contact first name |
| profile_data[lastname] | ❌ | string | Contact last name |
| profile_data[phonenumber] | ❌ | string | Phone number in E164 format |
| profile_data[companyname] | ❌ | string | Company name |
| profile_data[address1] | ❌ | string | Address line 1 |
| profile_data[address2] | ❌ | string | Address line 2 |
| profile_data[city] | ❌ | string | City |
| profile_data[state] | ❌ | string | State/Region |
| profile_data[postcode] | ❌ | string | Postal code |
| profile_data[country] | ❌ | string | Country |
| profile_data[tax_id] | ❌ | string | Taxpayer identification number |
| profile_data[permissions] | ❌ | string | Contact access rights |
| profile_data[generalemails] | ❌ | string | Receive general emails |
| profile_data[domainemails] | ❌ | string | Receive domain emails |
| profile_data[invoiceemails] | ❌ | string | Receive invoice emails |
| profile_data[productemails] | ❌ | string | Receive product emails |
| profile_data[supportemails] | ❌ | string | Receive support emails |
| profile_data[affiliateemails] | ❌ | string | Receive affiliate program emails |
| profile_data[subaccount] | ❌ | string | Create sub-account |
Example Request
curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=add_contact" \
--data "token=HOSTKEY_TOKEN" \
--data "profile_data[email][email protected]" \
--data "profile_data[password2]=SecurePassword123" \
--data "profile_data[firstname]=John" \
--data "profile_data[lastname]=Doe"
whmcs/apply_credit¶
Applies credit from the client's balance to pay a specified invoice.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: apply_credit |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | int | Invoice ID for payment |
| amount | ✅ | float | Credit amount to apply |
Example Request
Example of a successful response
whmcs/create_addfunds¶
Creates an invoice for adding funds (Add Funds).
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: create_addfunds |
| token | ✅ | string | Authorization token |
| amount | ✅ | float | Top-up amount |
| description | ❌ | string | Transaction description |
| subscribe | ❌ | int | Flag to enable auto-payment |
Example Request
Example of a successful response
whmcs/delete_cancellation_request¶
Removes an active server cancellation request and restores the invoice.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_cancellation_request |
| token | ✅ | string | Authorization token |
| id | ✅ | int | Server ID |
| full | ❌ | int | Return full data |
Example Request
Example of a successful response
whmcs/delete_contact¶
Removes a contact from the client account.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_contact |
| token | ✅ | string | Authorization token |
| contact_id | ✅ | int | Contact ID to delete |
Example Request
Example of a successful response
whmcs/download_invoice¶
Generates and returns the invoice PDF file.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: download_invoice |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | int | Invoice ID |
| proforma_invoice | ❌ | int | Proforma flag (0 or 1) |
| viewpdf | ❌ | int | Display in browser (1) or download (0) |
Example Request
Example of a successful response
whmcs/generate_due_invoice¶
Generates the next invoice for server payment.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: generate_due_invoice |
| token | ✅ | string | Authorization token |
| id | ✅ | int | Server ID |
Example Request
Example of a successful response
whmcs/get_billing_data¶
Retrieves synchronized billing data for a server.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_billing_data |
| token | ✅ | string | Authorization token |
| id | ✅ | int | Server ID |
Example Request
Example of a successful response
{
"result": "OK",
"Condition_Component": "rent",
"account_id": 500,
"billing_cycle": "monthly",
"billing_reccuring": 49.99,
"billing_status": "Active",
"currencysuffix": "EUR",
"customer_email": "[email protected]",
"customer_name": "John Doe",
"days": 30,
"days_left": 15,
"groupdata": {
"discountpercent": 0
},
"invert": 0,
"lock_billing_cycle_change": 0,
"name_client": "John Doe",
"next_due_date": "2024-02-15"
}
whmcs/get_cancellation_requests¶
Returns a list of active server cancellation requests.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_cancellation_requests |
| token | ✅ | string | Authorization token |
| id | ❌ | int | Server ID (optional). If not specified, returns the list for the current user |
| period_from | ❌ | string | Start of the filter period (YYYY-MM-DD) |
| period_to | ❌ | string | End of the filter period (YYYY-MM-DD) |
| cancellation_type | ❌ | string | Cancellation type (filter) |
| billing_status | ❌ | string | Billing status (filter) |
Example Request
Example of a successful response
whmcs/get_client¶
Returns information about the authorized client or by ID.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client |
| token | ✅ | string | Authorization token |
| client_id | ❌ | int | Client ID (used if email is not provided) |
| ❌ | string | Client email (used if client_id is not provided) | |
| full | ❌ | bool | Return full data (including passwords) |
Example Request
Example of a successful response
{
"result": "OK",
"client": {
"id": 123,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"companyname": "Acme Corp",
"status": "Active",
"credit": 100.5,
"currency_code": "EUR",
"corporate": 0,
"inn": "",
"contractnum": "",
"twofa_method": "none",
"twofaenabled": false,
"customfields": []
},
"billing_location": "whmcs",
"internal": {
"id": 456,
"verified": true,
"firstname": "John",
"lastname": "Doe"
},
"groupdata": {
"id": 1,
"groupname": "Reseller"
}
}
Failure response
whmcs/get_clientgroups¶
Returns a list of client groups in the billing system.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_clientgroups |
| token | ✅ | string | Authorization token |
| location | ❌ | string | Billing location (e.g., whmcs, whmcs_eu) |
Example Request
Example of a successful response
whmcs/get_contacts¶
Returns a list of additional client contacts.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_contacts |
| token | ✅ | string | Authorization token |
| full | ❌ | boolean | Return full data (including all WHMCS fields) |
Example Request
Example of a successful response
{
"result": "OK",
"action": "get_contacts",
"permission_contacts_granted": true,
"contacts": [
{
"id": "101",
"firstname": "Jane",
"lastname": "Smith",
"email": "[email protected]",
"permissions": "invoices,contacts"
}
]
}
whmcs/get_invoice¶
Returns data for a specific invoice.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoice |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | int | Invoice ID |
| load_client_data | ❌ | int | Load client data (1 - yes, 0 - no) |
Example Request
Example of a successful response
{
"result": "OK",
"invoiceid": 5001,
"date": "2024-01-01",
"duedate": "2024-01-31",
"total": 50.0,
"status": "Unpaid",
"currencycode": "USD",
"billing": "whmcs",
"items": {
"item": [
{
"description": "VPS Server",
"amount": 50.0,
"relid": 12345,
"inv_id": 12345
}
]
},
"customer": {
"client": {
"firstname": "John",
"lastname": "Doe",
"currency_code": "USD"
}
},
"firstname": "John",
"lastname": "Doe"
}
whmcs/get_invoices¶
Returns a list of client invoices.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoices |
| token | ✅ | string | Authorization token |
Example Request
Example of a successful response
{
"result": "OK",
"totalresults": 5,
"numreturned": 5,
"invoices": {
"invoice": [
{
"id": 5001,
"invoicenumber": "1001",
"date": "2024-01-01",
"duedate": "2024-01-15",
"total": 50.0,
"status": "Unpaid",
"items": {
"item": [
{
"type": "Hosting",
"description": "VPS Server",
"amount": 50.0
}
]
}
}
]
}
}
whmcs/get_related_invoices¶
Returns invoices linked to a server or account.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_related_invoices |
| token | ✅ | string | Authorization token |
| id | ❌ | int | Server ID (eq_id). If provided, used to find account_id. |
| account_id | ❌ | int | Account ID in billing (product_id). Used directly to search for invoices. |
Example Request
Example of a successful response
whmcs/getcredits¶
Returns the client's credit history.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getcredits |
| token | ✅ | string | Authorization token |
Example Request
Example of a successful response
Failure response
{
"code": -1,
"message": "failed to retrive account history at whmcs, please contact support - unknown error"
}
whmcs/getpaymentgw¶
Returns available payment methods for an invoice.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getpaymentgw |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | int | Invoice ID to retrieve payment gateways |
Example Request
Example of a successful response
whmcs/mass_pay¶
Pays multiple invoices with a single payment.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: mass_pay |
| token | ✅ | string | Authorization token |
| invoices | ✅ | array<int> | Array of invoice IDs to pay |
Example Request
whmcs/request_cancellation¶
Initiates the server cancellation process with refund calculation.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: request_cancellation |
| token | ✅ | string | Authorization token |
| id | ✅ | int | Server ID |
| cancellation_type | ✅ | int | Cancellation type (1 - immediate) |
| cancellation_reason | ❌ | string | Cancellation reason |
| terminate_reason_custom | ❌ | string | Custom reason |
Example Request
whmcs/reset_password¶
Initiates a password reset or sets a new one with 2FA.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: reset_password |
| ✅ | string | Client email | |
| reset_token | ❌ | string | Password reset token |
| pass | ❌ | string | New password |
| code | ❌ | string | 2FA code |
Example Request
Example of a successful response
whmcs/transactions¶
Returns the client's transaction history.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: transactions |
| token | ✅ | string | Authorization token |
| invoice_id | ❌ | int | Filter by invoice ID |
| transaction_id | ❌ | string | Filter by transaction ID |
Example Request
Example of a successful response
whmcs/update_client¶
Updates the client profile data in the billing system.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_client |
| token | ✅ | string | Authorization token |
| profile_data[billing_firstname] | ❌ | string | Client first name |
| profile_data[billing_lastname] | ❌ | string | Client last name |
| profile_data[billing_email] | ❌ | string | Client email |
| profile_data[billing_phonenumber] | ❌ | string | Client phone |
| profile_data[co_smsnum] | ❌ | string | SMS number |
| profile_data[ips] | ❌ | string | IP list for ACL |
| profile_data[billing_companyname] | ❌ | string | Company name |
| profile_data[billing_address1] | ❌ | string | Address line 1 |
| profile_data[billing_address2] | ❌ | string | Address line 2 |
| profile_data[billing_city] | ❌ | string | City |
| profile_data[billing_postcode] | ❌ | string | Postal code |
| profile_data[billing_country] | ❌ | string | Country |
| profile_data[billing_state] | ❌ | string | State/Region |
| profile_data[co_inn] | ❌ | string | INN (for legal entities) |
| profile_data[co_kpp] | ❌ | string | KPP (for legal entities) |
| profile_data[co_regaddress] | ❌ | string | Legal address |
| profile_data[co_bankdata] | ❌ | string | Bank details |
| profile_data[co_edo] | ❌ | string | EDO status |
| profile_data[co_edoprovider] | ❌ | string | EDO provider |
| profile_data[co_contractid] | ❌ | string | Contract number |
| profile_data[co_contract] | ❌ | string | Contract data |
| profile_data[co_customertype] | ❌ | string | Client type (Individual/Company) |
| profile_data[co_subscription] | ❌ | string | Subscription ID |
| profile_data[co_web] | ❌ | string | Company website |
| profile_data[co_size] | ❌ | string | Company size |
| profile_data[co_industry] | ❌ | string | Industry |
| profile_data[co_autopayment] | ❌ | string | Auto-payment |
| profile_data[co_payfirstday] | ❌ | string | First day payment |
| profile_data[co_marktemails] | ❌ | string | Marketing emails |
| profile_data[co_marktsms] | ❌ | string | Marketing SMS |
| profile_data[co_passdata] | ❌ | string | Passport data |
| profile_data[co_skype] | ❌ | string | Skype |
| profile_data[co_origin] | ❌ | string | Source |
| profile_data[co_secret] | ❌ | string | Secret word |
| profile_data[co_comment] | ❌ | string | Comment |
| profile_data[billing_status] | ❌ | string | Client status |
| profile_data[billing_emailoptout] | ❌ | boolean | Opt-out of emails |
| profile_data[billing_marketingoptin] | ❌ | boolean | Opt-in to marketing |
| profile_data[billing_overideduenotices] | ❌ | boolean | Ignore overdue notices |
| profile_data[billing_separateinvoices] | ❌ | boolean | Separate invoices |
| profile_data[billing_taxexempt] | ❌ | boolean | Tax exempt |
| profile_data[billing_latefeeoveride] | ❌ | boolean | Ignore late fees |
| profile_data[billing_overrideautoclose] | ❌ | boolean | Ignore auto-close |
| profile_data[billing_allowSingleSignOn] | ❌ | boolean | Allow SSO |
| profile_data[billing_disableautocc] | ❌ | boolean | Disable auto-credit card payment |
| profile_data[billing_groupid] | ❌ | integer | Client group ID |
| profile_data[billing_currency] | ❌ | string | Currency |
| profile_data[billing_notes] | ❌ | string | Notes |
| profile_data[billing_twofaenabled] | ❌ | boolean | Enable 2FA |
| profile_data[co_2famethod] | ❌ | string | 2FA method |
| profile_data[tag_autocreditenabled] | ❌ | boolean | Enable auto-credit |
| profile_data[tg_username] | ❌ | string | Telegram username |
| profile_data[form_id] | ❌ | string | Form ID (personal_data, account_owner, address) |
Example Request
Example of a successful response
{
"result": "success",
"message": "Client updated successfully",
"clientid": 12345,
"billing_email": "[email protected]",
"billing_email_changed": false,
"billing_email_illegal_change_attempt": false,
"edit_master_profile": false,
"close_window": false
}
whmcs/update_contact¶
Updates the client contact data.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_contact |
| token | ✅ | string | Authorization token |
| profile_data[contact_id] | ✅ | int | Contact ID |
| profile_data[email] | ✅ | string | Contact email |
| profile_data[password2] | ❌ | string | New password |
| profile_data[phonenumber] | ❌ | string | Contact phone (E164) |
| profile_data[firstname] | ❌ | string | Contact first name |
| profile_data[lastname] | ❌ | string | Contact last name |
| profile_data[permissions] | ❌ | string | Access rights (comma-separated list) |
Example Request