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. |
apply_credit | apply credit | Applies available account credit to a specific unpaid invoice. If the invoice is fully paid, it may trigger traffic overusage clearing for associated tags. |
create_addfunds | create add funds invoice in WHMCS | Creates an 'Add Funds' invoice in the connected WHMCS account for a specific 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 customer. Requires ownership or appropriate permissions. |
download_invoice | get invoice pdf | Downloads a specific invoice as a PDF file in binary format. The response is sent directly to the output stream. |
generate_due_invoice | generate due invoice | Generates the next due invoice for a specific server, provided that no upgrade tags are present and there are no unpaid invoices. |
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, including prebill data and billing status. |
get_client | get client information | Fetches detailed information about the authorized client from WHMCS, including billing location, group data, and custom fields. |
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 contacts associated with a WHMCS customer. If a subaccount email is provided, it filters the results to only include that specific contact 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 returns all available data from WHMCS. |
get_related_invoices | get related invoices | Retrieves a list of invoices associated with a specific server or account. |
getcredits | get credits | Retrieves the credit balance and account history for a specific user in WHMCS. |
getpaymentgw | get payment gateways | Returns the list of available payment gateways for a specific invoice, including processed call URLs. |
mass_pay | mass pay invoices | Processes the payment for a collection of specified invoice IDs simultaneously. |
request_cancellation | request cancellation | Requests a cancellation for a specific server, performing billing validation, refund calculations (including EU B2C rules), and traffic overusage checks. |
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 multi-step password reset process. First call sends a reset link via email; subsequent calls with a token and 2FA code (if enabled) update the client's password. |
transactions | get customer's transactions | Retrieves a list of transactions for the authenticated user or specified transaction ID. |
update_client | update client profile | Updates customer profile data including personal/company details, contact information, and IP access lists. |
update_contact | update additional contacts for a customer | Updates the profile data of an existing contact, including personal details, email, phone number, and password. |
whmcs/add_contact¶
Adds a new contact to the WHMCS system.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: add_contact |
| token | ✅ | string | Authentication token |
| params[first_name] | ✅ | string | Contact's first name |
| params[last_name] | ✅ | string | Contact's last name |
| params[email] | ✅ | string | Contact's email address |
Example Request
Example of a successful response
{
"result": "OK",
"action": "add_contact",
"data": {
"id": 123,
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]"
}
}
whmcs/apply_credit¶
Applies available account credit to a specific unpaid invoice. If the invoice is fully paid, it may trigger traffic overusage clearing for associated tags.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: apply_credit |
| invoice_id | ✅ | int | The ID of the invoice to which credit will be applied. |
| amount | ✅ | number | The amount of credit to apply. Must be greater than zero and less than or equal to the invoice balance/customer credit. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
whmcs/create_addfunds¶
Creates an 'Add Funds' invoice in the connected WHMCS account for a specific customer.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: create_addfunds |
| amount | ✅ | number | The amount to add to the customer's balance. |
| 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
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'/'Fail' to 'OK'/'Fail' |
Example Request
whmcs/delete_contact¶
Deletes a specific contact associated with a WHMCS customer. Requires ownership or appropriate permissions.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_contact |
| params[contact_id] | ✅ | int | The ID of the contact to be deleted |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
whmcs/download_invoice¶
Downloads a specific invoice as a PDF file in binary format. The response is sent directly to the output stream.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: download_invoice |
| invoice_id | ✅ | int | The ID of the invoice to download |
| user_id | ❌ | int | User ID associated with the invoice |
| location | ✅ | string | WHMCS billing location |
| proforma_invoice | ❌ | boolean | Whether to download as a proforma invoice |
| token | ✅ | string | API authentication token |
Example Request
whmcs/generate_due_invoice¶
Generates the next due invoice for a specific server, provided that no upgrade tags are present and there are no unpaid invoices.
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
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
whmcs/get_cancellation_requests¶
Returns a list of active cancellation requests for a specific server or user, including prebill data and billing status.
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 based on user permissions. |
| period_from | ❌ | string | Start date for filtering requests (ISO format). |
| period_to | ❌ | string | End date for filtering requests (ISO format). |
| cancellation_type | ❌ | string | Filter by cancellation type. Use 'All' to ignore this filter. |
| billing_status | ❌ | string | Filter by billing status. Use 'All' to ignore this filter. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "OK",
"message": [
{
"relid": 123,
"account_id": 456,
"owner": "[email protected]",
"corporate": "Y",
"customer_id": 789,
"name_client": "John Doe",
"due_date": "2024-12-31",
"cr_date": "2024-12-01T10:00:00Z",
"cr_reason": "Too expensive",
"cr_type": "auto",
"billing_status": "active",
"hwconfig": "some_config_data",
"server_id": 123,
"cancellation_date": "2024-12-31"
}
]
}
whmcs/get_client¶
Fetches detailed information about the authorized client from WHMCS, including billing location, group data, and custom fields.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client |
| params[email] | ❌ | string | Email used to identify the account if not using whmcs_id |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "OK",
"client": {
"firstname": "John",
"lastname": "Doe",
"fullname": "John Doe",
"email": "[email protected]",
"userid": 123,
"groupid": 5,
"corporate": false,
"currency_code": "USD",
"customfields": []
},
"billing_location": "US",
"groupdata": {
"id": 5,
"name": "Premium Clients"
},
"internal": {
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"billing_group": 5,
"corporate": false,
"currency": "USD"
},
"location": "US"
}
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/module identifier used to fetch groups. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
whmcs/get_contacts¶
Retrieves a list of contacts associated with a WHMCS customer. If a subaccount email is provided, it filters the results to only include that specific contact and checks permissions.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_contacts |
| params[email] | ❌ | string | The email address of the subaccount to filter contacts by. |
| 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",
"name": "John Doe"
}
]
}
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,
"clientid": 456,
"total": 50.0,
"currencycode": "USD",
"status": "Unpaid",
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"location": "US",
"client": {
"id": 456,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"companyname": "Example Corp",
"status": "Active"
},
"customer": null,
"billing": "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 returns all available data from WHMCS.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoices |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
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 |
| account_id | ❌ | int | The ID of the billing account to retrieve invoices for. |
| id | ❌ | int | Server ID. If provided, the system will automatically resolve the associated account_id and location. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
whmcs/getcredits¶
Retrieves the credit balance and account history for a specific user in WHMCS.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getcredits |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
whmcs/getpaymentgw¶
Returns the list of available payment gateways for a specific invoice, including processed call URLs.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getpaymentgw |
| invoice_id | ✅ | int | The ID of the invoice to retrieve gateways for. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
{
"result": "OK",
"methods": [
{
"stripe": {
"call": "https://invapi.hostkey.com/gateway/stripe?invoice_id=123"
},
"bitpay": {
"call": "https://invapi.hostkey.com/gateway/bitpay?invoice_id=123"
},
"banktransfer": {
"call": "<span style='text-align:left'><p data-intl='please_wire_funds_in_favor'>Please wire funds in favor of: </p>https://invapi.hostkey.com/gateway/bank?invoice_id=123</span>"
}
}
]
}
whmcs/mass_pay¶
Processes the payment for a collection of specified invoice IDs simultaneously.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| invoices[] | ✅ | array<int> | Accepts multiple values: invoices[]=101&invoices[]=102. Must contain at least 2 unique invoice IDs. |
| token | ✅ | string | API authentication token |
Example Request
Failure response
whmcs/request_cancellation¶
Requests a cancellation for a specific server, performing billing validation, refund calculations (including EU B2C rules), and traffic overusage checks.
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 immediate/refund-eligible). |
| cancellation_reason | ❌ | string | Custom reason for cancellation. |
| token | ✅ | string | API authentication token |
Example 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 provided by the user for cancellation. |
| token | ✅ | string | API authentication token |
Example Request
whmcs/reset_password¶
Handles the multi-step password reset process. First call sends a reset link via email; subsequent calls with a token and 2FA code (if enabled) update the client's password.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| ✅ | string | The email address of the customer to reset the password for. | |
| location | ❌ | string | WHMCS location/billing ID. Defaults to 'Auto'. |
| reset_token | ❌ | string | The unique reset token received via email for the second step of password reset. |
| pass | ❌ | string | The new password to be set. |
| code | ❌ | string | The 2FA verification code required if the account has two-factor authentication enabled. |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "[email protected]"
Example of a successful response
whmcs/transactions¶
Retrieves a list of transactions for the authenticated user or specified transaction ID.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | API authentication token |
| transaction_id | ❌ | string | Specific transaction ID to retrieve |
Example Request
Example of a successful response
Failure response
whmcs/update_client¶
Updates customer profile data including personal/company details, contact information, and IP access lists.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | API authentication token |
| params[billing_email] | ❌ | string | Updated 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 (requires verification if changed) |
| params[ips] | ❌ | string | Space-separated list of IP addresses for the access control list (ACL) |
| params[tg_username] | ❌ | string | Telegram username to link to the profile |
| params[co_secret] | ❌ | string | Secret word for account security |
| params[billing_companyname] | ❌ | string | Company name (for corporate accounts) |
| params[co_inn] | ❌ | string | VAT/INN number for EU/RU verification |
| params[billing_twofaenabled] | ❌ | boolean | Enable or disable Two-Factor Authentication |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "token=YOUR_API_TOKEN" \
--data "params[billing_email][email protected]" \
--data "params[ips]=192.168.1.1 10.0.0.1"
Example of a successful response
{
"result": "OK",
"action": "update_client",
"data": {
"billing_email": "[email protected]",
"co_smsnum": "+79281234567",
"message": null,
"billing_email_changed": true
}
}
whmcs/update_contact¶
Updates the profile data of an existing contact, including personal details, email, phone number, and password.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| params[email] | ✅ | string | Email address of the contact to update. Must be a valid email format. |
| params[contact_id] | ✅ | integer | The unique ID of the contact in WHMCS. |
| params[firstname] | ❌ | string | First name of the contact. Required for RU location if not already set. |
| params[lastname] | ❌ | string | Last name of the contact. |
| params[phonenumber] | ❌ | string | Phone number for the contact. Will be translated and verified. |
| params[password1] | ❌ | string | New password for the contact. |
| params[password2] | ❌ | string | Password confirmation. If provided, must match password1. |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "params[email][email protected]" \
--data "params[contact_id]=123" \
--data "token=YOUR_TOKEN"
Example of a successful response
{
"result": "success",
"clientid": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"phonenumber": "+79001234567",
"status": "active"
}