whmcs.php¶
WHMCS integration module for managing customers, invoices, credit, order cancellations, and server billing data.
API Methods¶
| Method | Action | Description |
|---|---|---|
add_contact | add contact | Adds a new contact to the WHMCS system with specified details. |
apply_credit | apply credit to invoice | Applies available account credit to a specific unpaid WHMCS invoice. If the invoice is paid via this method, it may trigger traffic usage clearing for certain tags. |
create_addfunds | create add funds invoice in WHMCS | Creates an 'Add Funds' invoice in the specified WHMCS account for a customer. |
delete_cancellation_request | delete cancellation request | Removes a cancellation request for a specific server, potentially restoring the cancelled invoice or generating a new one. |
delete_contact | delete contact | Deletes a specific contact associated with a WHMCS client. Requires ownership or appropriate permissions. |
download_invoice | get invoice pdf | Downloads a specific WHMCS invoice as a PDF file in binary format. The response is sent directly to the output stream with appropriate headers. |
generate_due_invoice | generate due invoice | Generates the next due invoice for a specific server, subject to upgrade tags and billing cycle constraints. |
get_billing_data | get billing data | Retrieves detailed billing information for a specific server, including EU withdrawal license costs and customer details. |
get_cancellation_requests | get cancellation requests | Returns a list of active cancellation requests for a specific server or user, merging data from WHMCS and prebill services. |
get_client | get_client | Returns detailed information about the authenticated client, including WHMCS data and internal system tags. |
get_clientgroups | get groups | Returns the list of preset client groups from WHMCS for a specific location. |
get_contacts | get contacts | Retrieves a list of sub-contacts associated with a customer in WHMCS. If a specific email is provided, it filters the results and checks permissions. |
get_invoice | get invoice | Fetches detailed information about a specific WHMCS invoice, including client data if authorized. |
get_invoices | get invoices | Fetches the list of invoices for a specific customer. If called by a customer, it returns their own invoices; otherwise, it retrieves all invoices for the authorized client. |
get_related_invoices | get related invoices | Retrieves a list of invoices associated with a specific server or account. |
getcredits | get credits | Retrieves the credit history for a specific WHMCS user in a given location. |
getpaymentgw | get payment gateways | Returns the list of available payment gateways for a specific invoice, including processed HTML call actions. |
mass_pay | mass pay invoices | Processes multiple WHMCS invoices for mass payment for a specific client and location. |
request_cancellation | request cancellation | Requests a cancellation for a specific server, handling refunds, EU B2C withdrawal rules, and traffic overusage surcharges. |
request_subscription_cancellation | request subscription cancellation | Requests the cancellation of a subscription for a specific server. It checks billing status, validates existing JIRA tickets to prevent duplicates, and creates a new JIRA ticket for manual processing. |
reset_password | reset password | Handles the password reset process. If no token is provided, it sends a reset link to the client's email. If a token is provided, it validates the token and 2FA (if enabled) before updating the password. |
transactions | get customer's transactions | Retrieves a list of transactions for the authenticated user or specific transaction ID. |
update_client | update client profile | Updates customer profile data including personal/company information, contact details, and custom fields. Supports IP ACL updates and 2FA settings. |
update_contact | update additional contacts for a customer | Updates contact information (first name, last name, email, phone number) and permissions for an existing WHMCS contact. |
whmcs/add_contact¶
Adds a new contact to the WHMCS system with specified details.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: add_contact |
| params[email] | ✅ | string | Email address of the contact |
| params[firstname] | ✅ | string | First name of the contact |
| params[lastname] | ✅ | string | Last name of the contact |
| params[address1] | ❌ | string | Address line 1 |
| params[city] | ❌ | string | City |
| params[state] | ❌ | string | State/Province |
| params[postcode] | ❌ | string | Postcode/Zip code |
| params[country] | ❌ | string | Country code (e.g., US, NL) |
| params[phone] | ❌ | string | Phone number |
| type | ✅ | string | Parameter type (detected in code) |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=add_contact" \
--data "params[email][email protected]" \
--data "params[firstname]=John" \
--data "params[lastname]=Doe" \
--data "type=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "add_contact",
"data": {
"clientid": 12345,
"email": "[email protected]",
"status": "active"
}
}
Failure response
``` { "code": -1, "message": "Error adding contact to WHMCS" }
```
whmcs/apply_credit¶
Applies available account credit to a specific unpaid WHMCS invoice. If the invoice is paid via this method, it may trigger traffic usage clearing for certain tags.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: apply_credit |
| params[invoice_id] | ✅ | int | The ID of the invoice to which credit will be applied |
| params[amount] | ✅ | number | The amount of credit to apply (must be greater than zero and not exceed invoice balance or account credit) |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid invoice id" }
```
whmcs/create_addfunds¶
Creates an 'Add Funds' invoice in the specified WHMCS account for a customer.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: create_addfunds |
| params[amount] | ✅ | number | The amount to add to the customer's balance. |
| params[description] | ❌ | string | Description for the invoice. |
| subscribe | ❌ | boolean | Whether to enable automatic bank card payments (subscription). |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "\(module/\)action: minimal payment amount is [amount]." }
```
whmcs/delete_cancellation_request¶
Removes a cancellation request for a specific server, potentially restoring the cancelled invoice or generating a new one.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_cancellation_request |
| id | ✅ | int | The ID of the server/service to process |
| full | ❌ | boolean | If true, transforms result from 'success' to 'OK' |
Example Request
Failure response
``` { "code": -1, "message": "\(module/\)action: server $id doesn't have a relid data" }
```
whmcs/delete_contact¶
Deletes a specific contact associated with a WHMCS client. Requires ownership or appropriate permissions.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_contact |
| contact_id | ✅ | int | The ID of the contact to be deleted |
| location | ✅ | string | The billing location/module identifier |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "verification failed, subcontact not found" }
```
whmcs/download_invoice¶
Downloads a specific WHMCS invoice as a PDF file in binary format. The response is sent directly to the output stream with appropriate headers.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: download_invoice |
| invoice_id | ✅ | int | The ID of the invoice to download |
| proforma_invoice | ❌ | boolean | Whether to download a proforma invoice |
| viewpdf | ❌ | int | If 1, the PDF is opened inline in the browser; otherwise, it is sent as an attachment |
| token | ✅ | string | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "undefined billing location or access denied" }
```
whmcs/generate_due_invoice¶
Generates the next due invoice for a specific server, subject to upgrade tags and billing cycle constraints.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: generate_due_invoice |
| addonids | ❌ | array | List of active addon IDs to include in the invoice generation |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "next_invoice_blocked_by_upgrade" }
```
whmcs/get_billing_data¶
Retrieves detailed billing information for a specific server, including EU withdrawal license costs and customer details.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_billing_data |
| id | ✅ | int | The ID of the server to retrieve billing data for. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid request" }
```
whmcs/get_cancellation_requests¶
Returns a list of active cancellation requests for a specific server or user, merging data from WHMCS and prebill services.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_cancellation_requests |
| id | ❌ | int | Server ID to filter requests. If 0 or less, the system attempts to fetch for the current user/location context. |
| period_from | ❌ | string | Start date filter (ISO format). |
| period_to | ❌ | string | End date filter (ISO format). |
| cancellation_type | ❌ | string | Filter by cancellation type. Use 'All' to disable filtering. |
| billing_status | ❌ | string | Filter by billing status. Use 'All' to disable filtering. |
| full | ❌ | boolean | If true, the result field is normalized to 'OK' or 'Fail'. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "success",
"message": [
{
"account_id": 123,
"billing_status": "active",
"due_date": "2024-12-31",
"cr_date": "2024-11-01T10:00:00Z",
"cr_reason": "User requested cancellation via portal",
"cr_type": "auto",
"customer_id": 55,
"corporate": "N",
"name_client": "John Doe",
"owner": "[email protected]"
}
]
}
Failure response
``` { "code": -1, "message": "Access denied" }
```
whmcs/get_client¶
Returns detailed information about the authenticated client, including WHMCS data and internal system tags.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client |
| token | ✅ | string | Authorization token |
| full | ❌ | boolean | If true, returns an extended dataset (including contact data and groups) |
| client | ✅ | string | client parameter (detected in code) |
| billing_location | ✅ | string | billing_location parameter (detected in code) |
| groupdata | ✅ | string | groupdata parameter (detected in code) |
| internal | ✅ | string | internal parameter (detected in code) |
Example Request
Example of a successful response
{
"result": "OK",
"action": "get_client",
"client": {
"id": 12345,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"companyname": "Example Corp",
"status": "Active",
"currency_code": "USD",
"countrycode": "US",
"phonenumber": "+1234567890",
"address1": "Main St 1",
"city": "New York",
"state": "NY",
"postcode": "10001",
"country": "United States",
"groupid": 1,
"corporate": 0
},
"billing_location": "whmcs_com",
"internal": {
"id": 12345,
"email": "[email protected]",
"active_since": "2023-01-15"
},
"groupdata": null
}
Failure response
``` { "code": -1, "message": "Request failed for 12345@whmcs_com: client not found" }
```
whmcs/get_clientgroups¶
Returns the list of preset client groups from WHMCS for a specific location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_clientgroups |
| location | ✅ | string | The billing location identifier. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid request" }
```
whmcs/get_contacts¶
Retrieves a list of sub-contacts associated with a customer in WHMCS. If a specific email is provided, it filters the results and checks permissions.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_contacts |
| ❌ | string | The email address of the subaccount to filter by or verify permissions for. | |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "OK",
"action": "get_contacts",
"permission_contacts_granted": true,
"contacts": [
{
"id": 123,
"email": "[email protected]",
"permissions": "contacts,billing"
},
{
"id": 124,
"email": "[email protected]",
"permissions": "all"
}
]
}
Failure response
``` { "code": -1, "message": "$module/get_contacts: fail to get contacts list" }
```
whmcs/get_invoice¶
Fetches detailed information about a specific WHMCS invoice, including client data if authorized.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoice |
| invoice_id | ✅ | int | The unique identifier of the invoice |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "OK",
"action": "get_invoice",
"data": {
"userid": 123,
"client": {
"id": 456,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"currency_code": "USD"
},
"total": 50.0,
"status": "Unpaid",
"date": "2024-01-01",
"duedate": "2024-01-15",
"currencycode": "USD",
"firstname": "John",
"lastname": "Doe",
"location": "US",
"billing": "us",
"items": {
"item": [
{
"relid": 1,
"inv_id": 10
}
]
}
},
"customer": null
}
Failure response
``` { "code": -1, "message": "invalid invoice id 0 at US" }
```
whmcs/get_invoices¶
Fetches the list of invoices for a specific customer. If called by a customer, it returns their own invoices; otherwise, it retrieves all invoices for the authorized client.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "OK",
"totalresults": 12,
"numreturned": 5,
"invoices": {
"invoice": [
{
"id": 101,
"invoicenum": "INV-001",
"date": "2024-01-01",
"duedate": "2024-02-01",
"total": 50.0,
"status": "Unpaid",
"client_id": 5,
"email": "[email protected]"
}
]
}
}
Failure response
``` { "code": -1, "message": "WHMCS module failed to retrieve invoices: error message" }
```
whmcs/get_related_invoices¶
Retrieves a list of invoices associated with a specific server or account.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_related_invoices |
| id | ❌ | int | Server ID to retrieve related invoices for. |
| account_id | ❌ | int | The billing account ID. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "module/get_related_invoices: invalid request" }
```
whmcs/getcredits¶
Retrieves the credit history for a specific WHMCS user in a given location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "failed to retrive account history at US, please contact support - error_details" }
```
whmcs/getpaymentgw¶
Returns the list of available payment gateways for a specific invoice, including processed HTML call actions.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getpaymentgw |
| invoice_id | ✅ | int | The ID of the WHMCS invoice |
| status | ❌ | string | Parameter status (detected in code) |
| userid | ❌ | string | Parameter userid (detected in code) |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "OK",
"methods": {
"stripe": {
"call": "<span style='text-align:left'><p data-intl='please_wire_funds_in_favor'>Please wire funds in favor of: </p><a href=\"https://invapi.hostkey.com?invoice_id=123\" target=_blank>Pay Now</a></span>"
},
"bitpay": {
"call": "<span style='text-align:left'><p data-intl='please_wire_funds_in_favor'>Please wire funds in favor of: </p><a href=\"https://invapi.hostkey.com?invoice_id=123\" target=_blank>Pay Now</a></span>"
},
"bitpaycheckout": {
"call": "<span style='text-align:left'><p data-intl='please_wire_funds_in_favor'>Please wire funds in favor of: </p><a href=\"https://invapi.hostkey.com?invoice_id=123\" target=_blank>Pay Now</a></span>"
},
"paypalcheckout": {
"call": "<span style='text-align:left'><p data-intl='please_wire_funds_in_favor'>Please wire funds in favor of: </p><a href=\"https://invapi.hostkey.com?invoice_id=123\" target=_blank>Pay Now</a></span>"
},
"banktransfer": {
"call": "<span style='text-align:left'><p data-intl='please_wire_funds_in_favor'>Please wire funds in favor of: </p><a href=\"https://invapi.hostkey.com?invoice_id=123\" target=_blank>Pay Now</a></span>"
}
},
"status": "active"
}
Failure response
``` { "code": -1, "message": "invalid invoice id" }
```
whmcs/mass_pay¶
Processes multiple WHMCS invoices for mass payment for a specific client and location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: mass_pay |
| invoices[] | ✅ | array<int> | Array of invoice IDs to be paid. Must contain at least 2 invoice IDs. |
| token | ✅ | string | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "module/mass_pay: failed to created masspay invoice - error_details" }
```
whmcs/request_cancellation¶
Requests a cancellation for a specific server, handling refunds, EU B2C withdrawal rules, and traffic overusage surcharges.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: request_cancellation |
| id | ✅ | int | The ID of the server to cancel. |
| cancellation_type | ❌ | int | Type of cancellation (e.g., 1 for standard). |
| cancellation_reason | ❌ | string | Custom reason for cancellation. |
| token | ✅ | string | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "invalid request" }
```
whmcs/request_subscription_cancellation¶
Requests the cancellation of a subscription for a specific server. It checks billing status, validates existing JIRA tickets to prevent duplicates, and creates a new JIRA ticket for manual processing.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: request_subscription_cancellation |
| id | ✅ | int | The ID of the server/service to cancel. |
| cancellation_type | ❌ | int | Type of cancellation (e.g., 1 for immediate). |
| cancellation_reason | ❌ | string | Reason for the cancellation request. |
| token | ✅ | string | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "sub_cancel_not_allowed_billing" }
```
whmcs/reset_password¶
Handles the password reset process. If no token is provided, it sends a reset link to the client's email. If a token is provided, it validates the token and 2FA (if enabled) before updating the password.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| ✅ | string | The email address of the client for which to reset the password. | |
| location | ❌ | string | The billing location. Defaults to 'Auto'. |
| reset_token | ❌ | string | The password reset token used for verifying the identity of the user. |
| pass | ❌ | string | The new password to be set. |
| code | ❌ | string | The 2FA verification code required if two-factor authentication is enabled for the account. |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "[email protected]"
Example of a successful response
Failure response
``` { "code": -1, "message": "Invalid password reset token, please try again." }
```
whmcs/transactions¶
Retrieves a list of transactions for the authenticated user or specific transaction ID.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | API authentication token |
| transaction_id | ❌ | string | Specific transaction identifier to filter results. |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "whmcs.php/transactions: failed to retrive transactions - error_details" }
```
whmcs/update_client¶
Updates customer profile data including personal/company information, contact details, and custom fields. Supports IP ACL updates and 2FA settings.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| params[client_id] | ✅ | integer | The ID of the client to update |
| params[location] | ✅ | string | WHMCS billing location/module name |
| params[billing_email] | ❌ | string | New email address for the client |
| params[billing_firstname] | ❌ | string | Client's first name |
| params[billing_lastname] | ❌ | string | Client's last name |
| params[co_smsnum] | ❌ | string | Phone number for SMS verification/2FA |
| params[ips][] | ❌ | array<string> | Accepts multiple values: ips[]=1.1.1.1&ips[]=2.2.2.2 |
| params[co_secret] | ❌ | string | Secret word for profile security |
| params[tg_username] | ❌ | string | Telegram username (e.g., @username) |
| params[billing_twofaenabled] | ❌ | boolean | Enable or disable two-factor authentication |
| params[co_customertype] | ❌ | string | Customer type (e.g., Individual, Company) |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "success",
"action": "update_client",
"billing_location": "whmcs_ru",
"client": "John Doe",
"corporate": 0,
"email": "[email protected]",
"twofaenabled": 1,
"message": null
}
Failure response
``` { "code": -1, "message": "Account type change is not allowed" }
```
whmcs/update_contact¶
Updates contact information (first name, last name, email, phone number) and permissions for an existing WHMCS contact.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_contact |
| params[contact_id] | ✅ | int | The ID of the contact to update |
| params[email] | ✅ | string | Email address of the contact |
| params[firstname] | ❌ | string | First name of the contact |
| params[lastname] | ❌ | string | Last name of the contact |
| params[phonenumber] | ❌ | string | Phone number for SMS verification and contact |
| params[password1] | ❌ | string | New password for the contact |
| params[password2] | ❌ | string | Password confirmation |
| params[permissions] | ❌ | string | Comma-separated list of permissions for the contact |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=update_contact" \
--data "params[contact_id]=123" \
--data "params[email][email protected]" \
--data "token=YOUR_API_TOKEN"
Example of a successful response
{
"result": "success",
"action": "update_contact",
"companyname": "John Doe Corp",
"corporate": 1,
"customfields": "base64_encoded_data",
"email": "[email protected]",
"firstname": "John",
"fullname": "John Doe",
"inn": "1234567890",
"lastname": "Doe",
"phonenumber": "+79281234567",
"var": "some_value"
}
Failure response
``` { "code": -1, "message": "fill_required_fields" }
```