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 an additional contact person to an existing customer in WHMCS. If the request type is not specified, a random contact is created. |
apply_credit | apply credit to invoice | Applies the customer's available balance (credit) to pay for a selected invoice. If the credit amount exceeds the invoice total, the maximum possible amount is applied. |
create_addfunds | create add funds invoice | Creates an invoice in WHMCS to top up the customer's balance. If the subscribe option is enabled, it activates automatic payments. |
delete_cancellation_request | delete cancellation request | Deletes an active subscription cancellation request for a specific server, allowing the order status to be restored. |
delete_contact | delete contact | Deletes an additional contact associated with a customer in WHMCS. |
download_invoice | download invoice | Returns a PDF invoice file in base64 format for downloading or viewing. |
generate_due_invoice | generate due invoice | Generates the next invoice for a server in WHMCS if the current billing cycle is not completed and there are no unpaid invoices. |
get_billing_data | get server billing data | Returns detailed information about the billing account and the current service status for the specified Server ID. |
get_cancellation_requests | get cancellation requests | Returns a list of active cancellation requests for a specific server or user, with filtering by type, payment status, and date. |
get_client | get client information | Returns detailed information about the authenticated client, including data from WHMCS and internal system tags. |
get_clientgroups | get groups | Returns a list of available customer groups from WHMCS for the specified location. |
get_contacts | get client additional contacts | Returns a list of contacts associated with a customer in WHMCS. If an email subaccount is specified, only contacts with appropriate access rights are returned. |
get_invoice | get invoice data | Returns detailed information about an invoice from WHMCS, including customer data and payment status. |
get_invoices | get client invoices list | Returns a list of all invoices associated with the client in the selected WHMCS location. |
get_related_invoices | get related invoices | Returns a list of invoices associated with a specific server (via account_id). |
getcredits | get credits | Returns information about available credits (balance) on the user's account in WHMCS. |
getpaymentgw | get payment gateways | Returns a list of available payment methods (payment gateways) for a specific invoice. |
mass_pay | mass pay invoices | Allows making a bulk payment for several invoices with a single transaction, creating a corresponding transaction record in WHMCS. |
request_cancellation | request subscription/server cancellation | Initiates the order or subscription cancellation process. It checks for active licenses, server status, and automatic refund eligibility depending on the billing type. |
request_subscription_cancellation | request subscription cancellation | Initiates the bank subscription cancellation process for a server. It checks for active subscriptions, payment status, and creates a JIRA ticket to process the request. |
reset_password | reset password | Initiates the password reset process. If reset_token is not provided, it sends a link via email and enables 2FA. If a token is provided, it allows setting a new password after verifying the 2FA code. |
transactions | get transactions | Returns a list of user transactions filtered by (Client ID, Server ID, Invoice ID, or specific transaction ID). |
update_client | update client data | Updates customer information in WHMCS, including contact details (name, email, phone), address, marketing settings, and custom profile fields. |
update_contact | update contact | Updates additional contact information for a client (first name, last name, email, phone) in the WHMCS system. Changing the primary email or phone may require re-verification. |
whmcs/add_contact¶
Adds an additional contact person to an existing customer in WHMCS. If the request type is not specified, a random contact is created.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: add_contact |
| params[firstname] | ✅ | string | Contact first name (required for EU-Central location) |
| params[lastname] | ❌ | string | Contact last name |
| params[email] | ✅ | string | Contact email (must be unique) |
| params[password1] | ✅ | string | Password for the new contact |
| params[password2] | ✅ | string | Password confirmation |
| params[phonenumber] | ❌ | string | Phone number (checked for SMS support) |
| params[companyname] | ❌ | string | Company name |
| params[address1] | ❌ | string | Address 1 |
| params[address2] | ❌ | string | Address 2 |
| params[city] | ❌ | string | City |
| params[state] | ❌ | string | State/Region |
| params[postcode] | ❌ | string | Postal code |
| params[country] | ❌ | string | Country |
| type | ✅ | string | Request type (0 for random contact) |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=add_contact" \
--data "params[firstname]=VALUE" \
--data "params[lastname]=VALUE" \
--data "params[email]=VALUE" \
--data "params[password1]=VALUE" \
--data "params[password2]=VALUE" \
--data "params[phonenumber]=VALUE" \
--data "params[companyname]=VALUE" \
--data "params[address1]=VALUE" \
--data "params[address2]=VALUE" \
--data "params[city]=VALUE" \
--data "params[state]=VALUE" \
--data "params[postcode]=VALUE" \
--data "params[country]=VALUE" \
--data "type=0" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "success",
"clientid": 12345,
"contactid": 67890,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]"
}
Failure response
{
"-1": "fill_required_fields",
"message_firstname_incorrect": "message_firstname_incorrect",
"message_lastname_incorrect": "message_lastname_incorrect",
"message_email_incorrect": "message_email_incorrect",
"email_registered": "email_registered",
"sms_number_not_supported": "sms_number_not_supported",
"premium_sms_not_supported": "premium_sms_not_supported",
"message_phone_incorrect_format": "message_phone_incorrect_format",
"system_error": "system_error"
}
whmcs/apply_credit¶
Applies the customer's available balance (credit) to pay for a selected invoice. If the credit amount exceeds the invoice total, the maximum possible amount is applied.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: apply_credit |
| invoice_id | ✅ | int | Invoice ID for payment |
| amount | ✅ | number | Credit amount to apply |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
whmcs/create_addfunds¶
Creates an invoice in WHMCS to top up the customer's balance. If the subscribe option is enabled, it activates automatic payments.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: create_addfunds |
| token | ✅ | string | Authorization token |
| amount | ❌ | float | Top-up amount (minimum 20 for regular payments) |
| description | ❌ | string | Payment description |
| subscribe | ❌ | boolean | Enable automatic billing (recurring payments) |
Example Request
Example of a successful response
whmcs/delete_cancellation_request¶
Deletes an active subscription cancellation request for a specific server, allowing the order status to be restored.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_cancellation_request |
| id | ✅ | int | Server ID (relid) |
| token | ✅ | string | Authorization token |
Example Request
whmcs/delete_contact¶
Deletes an additional contact associated with a customer in WHMCS.
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
whmcs/download_invoice¶
Returns a PDF invoice file in base64 format for downloading or viewing.
HTTP Method: POST|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 mode: 1 — inline (in browser), 0 — attachment (download) |
Example Request
whmcs/generate_due_invoice¶
Generates the next invoice for a server in WHMCS if the current billing cycle is not completed and there are no unpaid invoices.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: generate_due_invoice |
| id | ✅ | int | Server ID |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
whmcs/get_billing_data¶
Returns detailed information about the billing account and the current service status for the specified Server ID.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_billing_data |
| id | ✅ | integer | Server ID |
| token | ✅ | string | Authorization token |
| customer_name | ✅ | string | Parameter customer_name (detected in code) |
Example Request
Example of a successful response
whmcs/get_cancellation_requests¶
Returns a list of active cancellation requests for a specific server or user, with filtering by type, payment status, and date.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_cancellation_requests |
| id | ❌ | int | Server ID to get requests for specific hardware. If not specified, search is performed by user. |
| token | ✅ | string | Authorization token |
| cancellation_type | ❌ | string | Filter by cancellation type (e.g., End of Billing Period) |
| billing_status | ❌ | string | Filter by payment status |
| period_from | ❌ | string | Start date of the period (date format) |
| period_to | ❌ | string | End date of the period (date format) |
Example Request
Example of a successful response
whmcs/get_client¶
Returns detailed information about the authenticated client, including data from WHMCS and internal system tags.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client |
| token | ✅ | string | Authorization token |
| ❌ | string | Client email for searching (used in some scenarios) | |
| full | ❌ | boolean | Flag to get complete profile data |
Example Request
Example of a successful response
{
"result": "OK",
"client": {
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"fullname": "John Doe",
"companyname": "Example Corp",
"countrycode": "US",
"currency_code": "USD",
"status": "Active",
"corporate": 0,
"ip": "192.168.1.1",
"location": "whmcs_com"
},
"billing_location": "whmcs_com",
"groupdata": {
"id": 5,
"groupname": "Premium Customers"
},
"internal": {
"id": 123,
"email": "[email protected]",
"corporate": 0,
"active_since": "2024-01-01"
}
}
whmcs/get_clientgroups¶
Returns a list of available customer groups from WHMCS for the specified location.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_clientgroups |
| token | ✅ | string | Authorization token |
Example Request
Example of a successful response
whmcs/get_contacts¶
Returns a list of contacts associated with a customer in WHMCS. If an email subaccount is specified, only contacts with appropriate access rights are returned.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_contacts |
| token | ✅ | string | Authorization token |
| ❌ | string | Subaccount email for filtering contacts |
Example Request
Example of a successful response
{
"result": "OK",
"permission_contacts_granted": true,
"contacts": [
{
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"permissions": "contacts"
}
]
}
whmcs/get_invoice¶
Returns detailed information about an invoice from WHMCS, including customer data and payment status.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoice |
| invoice_id | ✅ | int | Invoice ID |
| location | ❌ | string | Billing location (WHMCS location) |
| load_client_data | ❌ | int | Load client data along with the invoice |
| token | ✅ | string | Authorization token |
Example Request
Example of a successful response
{
"result": "OK",
"status": "success",
"items": {
"item": [
{
"relid": 123,
"inv_id": 456,
"type": "Hosting"
}
]
},
"currencycode": "USD",
"billing": "whmcs",
"customer": {
"client": {
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]"
}
}
}
whmcs/get_invoices¶
Returns a list of all invoices associated with the client in the selected WHMCS location.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoices |
| token | ✅ | string | Authorization token |
| location | ❌ | string | Billing location (WHMCS location) |
Example Request
Example of a successful response
whmcs/get_related_invoices¶
Returns a list of invoices associated with a specific server (via account_id).
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_related_invoices |
| account_id | ❌ | int | WHMCS account ID. If not specified, it is determined automatically by server id |
| token | ✅ | string | Authorization token |
| id | ❌ | int | Server ID (used to determine account_id) |
Example Request
Example of a successful response
whmcs/getcredits¶
Returns information about available credits (balance) on the user's account in WHMCS.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | Authorization token |
Example Request
Failure response
whmcs/getpaymentgw¶
Returns a list of available payment methods (payment gateways) for a specific invoice.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getpaymentgw |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | integer | Invoice ID to get gateways for |
Example Request
Example of a successful response
{
"result": "OK",
"methods": {
"paymaster": {
"call": "https://bill.hostkey.com/modules/gateways/paymaster.php?id=123"
},
"bitpaycheckout": {
"call": "<input type=\"submit\" class=\"btn btn-xl btn-block btn-outline-dark rounded btn-sm\" value=\"Pay Now\" />"
},
"banktransfer": {
"call": "<span style='text-align:left'>Please wire funds in favor of: Bank Details</span>"
}
}
}
whmcs/mass_pay¶
Allows making a bulk payment for several invoices with a single transaction, creating a corresponding transaction record in WHMCS.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: mass_pay |
| invoices[] | ✅ | array | Array of invoice IDs for payment. Must contain at least 2 values. |
| token | ✅ | string | API authentication token |
Example Request
whmcs/request_cancellation¶
Initiates the order or subscription cancellation process. It checks for active licenses, server status, and automatic refund eligibility depending on the billing type.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | ✅ | int | Server ID to cancel |
| cancellation_type | ❌ | int | Cancellation type (1 — immediate with refund) |
| cancellation_reason | ❌ | string | Order cancellation reason |
| refund | ✅ | float | Refund amount |
| currency | ✅ | string | Refund currency |
| service_price | ❌ | float | Service price for calculation |
| refund_message | ✅ | string | Refund message text (RU/EN) |
| refund_message_short | ✅ | string | Short refund message text |
| clientid | ✅ | int | Client ID in WHMCS |
| billing | ✅ | string | Billing location (e.g., whmcs_eu) |
| ✅ | string | Client email for notification | |
| last_invoice | ✅ | int | Last invoice item ID |
| prev_invoice_id | ❌ | int | Previous invoice ID to account for overpayment |
| relid | ✅ | int | Account ID (billing link) |
| vat_msg | ❌ | string | Tax/VAT message |
| rec_before_tax | ❌ | float | Amount before tax deduction |
| total_with_tax | ❌ | float | Total amount including tax |
| d_deploy_time | ❌ | string | Deployment date |
| d_bill_time | ❌ | string | Billing time |
| d_recurring | ❌ | string | Recurring payment (billing cycle) |
| d_period | ❌ | string | Billing period |
| cbp_adjusted | ❌ | string | CBP adjustment message |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "id=123" \
--data "refund=50.00" \
--data "currency=USD" \
--data "refund_message=Refund processed successfully" \
--data "refund_message_short=Refunded" \
--data "clientid=456" \
--data "billing=whmcs_ru" \
--data "[email protected]" \
--data "last_invoice=789" \
--data "relid=101" \
--data "token=YOUR_API_TOKEN"
whmcs/request_subscription_cancellation¶
Initiates the bank subscription cancellation process for a server. It checks for active subscriptions, payment status, and creates a JIRA ticket to process the request.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: request_subscription_cancellation |
| id | ✅ | int | Server ID (relid) |
| cancellation_type | ❌ | string | Subscription cancellation type |
| cancellation_reason | ❌ | string | Subscription cancellation reason |
| token | ✅ | string | API authentication token |
Example Request
whmcs/reset_password¶
Initiates the password reset process. If reset_token is not provided, it sends a link via email and enables 2FA. If a token is provided, it allows setting a new password after verifying the 2FA code.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | Auth token for API authorization |
| ✅ | string | User email to send password reset link | |
| reset_token | ❌ | string | Token to complete the reset process (used during re-call) |
| pass | ❌ | string | New user password |
| code | ❌ | string | Two-factor authentication (2FA) code |
| location | ❌ | string | Billing location (default Auto) |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=reset_password" \
--data "token=HOSTKEY_TOKEN" \
--data "[email protected]"
Example of a successful response
whmcs/transactions¶
Returns a list of user transactions filtered by (Client ID, Server ID, Invoice ID, or specific transaction ID).
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: transactions |
| transaction_id | ❌ | int | Specific transaction ID |
| invoice_id | ❌ | int | Invoice ID for filtering |
| server_id | ❌ | int | Server ID (account_id) |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
whmcs/update_client¶
Updates customer information in WHMCS, including contact details (name, email, phone), address, marketing settings, and custom profile fields.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_client |
| token | ✅ | string | Authorization token |
| profile_data[client_id] | ✅ | integer | Client ID in WHMCS |
| profile_data[location] | ✅ | string | Billing location (e.g., whmcs_ru) |
| profile_data[billing_email] | ❌ | string | New customer email address |
| profile_data[billing_firstname] | ❌ | string | First name in billing |
| profile_data[billing_lastname] | ❌ | string | Last name in billing |
| profile_data[co_smsnum] | ❌ | string | Phone number for SMS (undergoes verification) |
| profile_data[ips] | ❌ | string | List of IP addresses for ACL separated by comma/space |
| profile_data[co_customertype] | ❌ | string | Customer type (Individual / Company) |
| profile_data[form_id] | ❌ | string | Form ID for mandatory field validation |
| profile_data[co_secret] | ❌ | string | Secret word (automatically filled from customfields) |
Example Request
Example of a successful response
{
"result": "OK",
"clientid": 123,
"location": "whmcs_ru",
"billing_email": "[email protected]",
"message": "Profile settings updated"
}
whmcs/update_contact¶
Updates additional contact information for a client (first name, last name, email, phone) in the WHMCS system. Changing the primary email or phone may require re-verification.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_contact |
| contact_id | ✅ | int | Contact ID to update |
| ✅ | string | Contact email (required) | |
| firstname | ✅ | string | Contact first name |
| lastname | ❌ | string | Contact last name |
| phonenumber | ❌ | string | Phone number (undergoes validation and transliteration) |
| password1 | ❌ | string | New password for the contact |
| password2 | ❌ | string | Password confirmation |
| token | ✅ | string | API authentication token |
Example Request