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 additional contact for the customer in WHMCS. If request type is not specified, a random contact with a random email is created. |
apply_credit | apply credit to invoice | Applies available balance (credit) of the customer to pay a selected invoice in WHMCS. If the invoice status changes to 'Paid' after payment, traffic overage is automatically cleared. |
create_addfunds | create add funds invoice | Creates an invoice in WHMCS for topping up the customer's balance. If the subscribe option is enabled, automatic renewal will be configured. |
delete_cancellation_request | delete cancellation request | Deletes an existing cancellation request for a specific server, allowing the invoice status to be restored or a new one to be generated. |
delete_contact | delete contact | Deletes an additional contact linked to the customer in WHMCS. |
download_invoice | download invoice | Returns a PDF file of the invoice in base64 format for viewing or downloading. |
generate_due_invoice | generate due invoice | Generates the next due invoice in WHMCS. Blocked if the customer has unpaid invoices or if the current billing cycle is not yet completed. |
get_billing_data | get server billing data | Returns detailed information about the billing parameters of a specific server, including EU B2C data (right of withdrawal) and license details in case of cancellation under EU rules. |
get_cancellation_requests | get cancellation requests | Returns a list of active service cancellation requests for a specific server or user with filtering by date, type, and payment status. |
get_client | get client information | Returns detailed information about the authenticated client, including WHMCS data (profile, group, currency) and internal system data (tags, verification status). If the full parameter is provided, an extended dataset is returned. |
get_clientgroups | get client groups | Returns a list of available client groups from WHMCS for the specified location. |
get_contacts | get client contacts | Returns a list of additional contacts linked to the customer in WHMCS. If email subaccount is specified, only contacts with corresponding access rights are returned. |
get_invoice | get invoice data | Returns detailed information about an invoice from WHMCS, including customer data and a list of items. |
get_invoices | get client invoices list | Returns a list of all invoices associated with the customer in WHMCS. If the client is authenticated, only their invoices are returned. |
get_related_invoices | get related invoices | Returns a list of invoices associated with a specific server or customer account in WHMCS |
getcredits | get balance (credits) | Returns information about available credits on the customer's account in the specified WHMCS location. |
getpaymentgw | get payment gateways | Returns a list of available payment methods (gateways) for a specific invoice with support for link formatting and HTML button code. |
mass_pay | mass pay invoices | Creates one single invoice to pay multiple selected customer invoices. |
request_cancellation | request order/subscription cancellation | Initiates the process of canceling an order or subscription in WHMCS. Checks for active licenses, invoice payment status, and refund eligibility (including EU B2C rules). If there are traffic debts, it may calculate the withholding amount. |
request_subscription_cancellation | request subscription cancellation | Initiates the bank subscription cancellation process for a server, creating a JIRA ticket and tagging the server accordingly. |
reset_password | reset password | Allows initiating the password reset process (sending a link via email) or completing it using a recovery token and 2FA code. |
transactions | get client transactions | Returns a list of user financial transactions from WHMCS by the specified ID or within the current session. |
update_client | update client data | Updates customer information in WHMCS and the local database, including contact details, 2FA settings, IP-ACL, and custom fields. Changing email or phone may require re-verification. |
update_contact | update contact | Updates existing customer contact data (first name, last name, email, phone) in the WHMCS system. Changing email or phone may require re-verification. |
whmcs/add_contact¶
Adds a new additional contact for the customer in WHMCS. If request type is not specified, a random contact with a random email is created.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: add_contact |
| token | ✅ | string | Authorization token |
| profile_data[firstname] | ✅ | string | Contact first name |
| profile_data[lastname] | ❌ | string | Contact last name |
| profile_data[email] | ✅ | string | Contact email (must be unique) |
| profile_data[password1] | ✅ | string | Password for the new contact |
| profile_data[password2] | ✅ | string | Password confirmation |
| profile_data[phonenumber] | ❌ | string | Phone number (undergoes verification) |
| type | ✅ | integer | Request type (0 to create a random contact) |
Example Request
Failure response
``` { "code": -1, "message": "fill_required_fields" }
```
whmcs/apply_credit¶
Applies available balance (credit) of the customer to pay a selected invoice in WHMCS. If the invoice status changes to 'Paid' after payment, traffic overage is automatically cleared.
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 | Authentication API token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid invoice id 123 at whmcs_eu status - Unpaid" }
```
whmcs/create_addfunds¶
Creates an invoice in WHMCS for topping up the customer's balance. If the subscribe option is enabled, automatic renewal will be configured.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: create_addfunds |
| amount | ✅ | number | Top-up amount |
| description | ❌ | string | Payment description |
| subscribe | ❌ | boolean | Enable automatic renewal (only for amount 1) |
| token | ✅ | string | Authentication API token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "minimal payment amount is 10.0" }
```
whmcs/delete_cancellation_request¶
Deletes an existing cancellation request for a specific server, allowing the invoice status to be restored or a new one to be generated.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_cancellation_request |
| id | ✅ | int | Server ID |
| token | ✅ | string | Authorization token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "Server doesn't have a relid data" }
```
whmcs/delete_contact¶
Deletes an additional contact linked to the customer in WHMCS.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_contact |
| contact_id | ✅ | int | Contact ID to delete |
| location | ❌ | string | Billing location (WHMCS location) |
| token | ✅ | string | Authentication API token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "verification failed, subcontact not found" }
```
whmcs/download_invoice¶
Returns a PDF file of the invoice in base64 format for viewing or downloading.
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 | 1 — open in browser (inline), 0 — download as file (attachment) |
Example Request
Failure response
``` { "code": -1, "message": "Invalid invoice id" }
```
whmcs/generate_due_invoice¶
Generates the next due invoice in WHMCS. Blocked if the customer has unpaid invoices or if the current billing cycle is not yet completed.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: generate_due_invoice |
| id | ✅ | int | Server/service ID for invoice generation |
| token | ✅ | string | Authorization token |
Example Request
Example of a successful response
Failure response
``` { "next_invoice_blocked_by_upgrade": { "result": -1, "error": "next_invoice_blocked_by_upgrade" }, "next_invoice_blocked_by_due_date": { "result": -1, "error": "next_invoice_blocked_by_due_date" }, "next_invoice_unpaid_exists": { "result": -1, "error": "next_invoice_unpaid_exists" } }
```
whmcs/get_billing_data¶
Returns detailed information about the billing parameters of a specific server, including EU B2C data (right of withdrawal) and license details in case of cancellation under EU rules.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_billing_data |
| id | ✅ | int | Server ID |
| token | ✅ | string | Authorization token |
| notes | ✅ | string | notes parameter (detected in code) |
| groupdata | ✅ | string | groupdata parameter (detected in code) |
| customer_name | ✅ | string | customer_name parameter (detected in code) |
| eu_b2c | ✅ | string | eu_b2c parameter (detected in code) |
| eu_withdrawal | ✅ | string | eu_withdrawal parameter (detected in code) |
| billing_cycle | ✅ | string | billing_cycle parameter (detected in code) |
| eu_withdrawal_licenses | ✅ | string | eu_withdrawal_licenses parameter (detected in code) |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST|GET \
--data "action=get_billing_data" \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN" \
--data "notes=VALUE" \
--data "groupdata=VALUE" \
--data "customer_name=VALUE" \
--data "eu_b2c=VALUE" \
--data "eu_withdrawal=VALUE" \
--data "billing_cycle=VALUE" \
--data "eu_withdrawal_licenses=VALUE"
Example of a successful response
Failure response
``` { "code": -1, "message": "Server not found" }
```
whmcs/get_cancellation_requests¶
Returns a list of active service cancellation requests for a specific server or user with filtering by date, type, and payment status.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_cancellation_requests |
| id | ❌ | int | Server ID to get requests for a specific resource. If not specified, search is performed by user. |
| user_id | ❌ | int | User ID (in customer context). |
| location | ❌ | string | Billing location. |
| period_from | ❌ | string | Start date of the period (format YYYY-MM-DD). |
| period_to | ❌ | string | End date of the period (format YYYY-MM-DD). |
| cancellation_type | ❌ | string | Cancellation type for filtering. |
| billing_status | ❌ | string | Billing status (e.g., Paid, Unpaid). |
| token | ✅ | string | Authentication API token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "Invalid billing location" }
```
whmcs/get_client¶
Returns detailed information about the authenticated client, including WHMCS data (profile, group, currency) and internal system data (tags, verification status). If the full parameter is provided, an extended dataset is returned.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client |
| token | ✅ | string | Authorization token |
| ❌ | string | Client email for search (used in some scenarios) | |
| full | ❌ | boolean | Flag to return extended data |
Example Request
Example of a successful response
{
"result": "OK",
"client": {
"id": 123,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"companyname": "Example Corp",
"countrycode": "US",
"currency_code": "USD",
"groupid": 1,
"corporate": 0,
"active_since": "2023-01-15",
"customfields": {}
},
"billing_location": "whmcs_eu",
"internal": {
"id": 456,
"email": "[email protected]",
"corporate": 0,
"active_since": "2023-01-15"
},
"groupdata": {
"id": 1,
"groupname": "Standard Users"
}
}
Failure response
``` { "code": -1, "message": "Request failed for client@location: error message" }
```
whmcs/get_clientgroups¶
Returns a list of available client 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 |
| location | ❌ | string | Billing location (e.g., whmcs_eu) |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "Invalid request or billing location not found" }
```
whmcs/get_contacts¶
Returns a list of additional contacts linked to the customer in WHMCS. If email subaccount is specified, only those contacts that have corresponding 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 (if not specified, all client contacts are returned) |
Example Request
Example of a successful response
{
"result": "OK",
"permission_contacts_granted": true,
"contacts": {
"contact": [
{
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"permissions": "contacts"
}
]
},
"client": {
"id": 456,
"email": "[email protected]",
"firstname": "Main",
"lastname": "User"
},
"billing_location": "whmcs_eu"
}
Failure response
``` { "code": -1, "message": "fail to get contacts list" }
```
whmcs/get_invoice¶
Returns detailed information about an invoice from WHMCS, including customer data and a list of items.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoice |
| invoice_id | ✅ | int | Invoice ID |
| token | ✅ | string | Authorization token |
| load_client_data | ❌ | int | Load client data flag (1 - load) |
Example Request
Example of a successful response
{
"result": "OK",
"billing": "whmcs_eu",
"currencycode": "USD",
"userid": 123,
"status": "Unpaid",
"items": {
"item": [
{
"inv_id": 50,
"type": "Hosting",
"description": "Monthly Subscription",
"amount": 15.0
}
]
},
"customer": {
"client": {
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]"
}
}
}
Failure response
``` { "code": -1, "message": "invalid invoice id 0 at whmcs_eu" }
```
whmcs/get_invoices¶
Returns a list of all invoices associated with the customer in WHMCS. If the client is authenticated, only their invoices are returned.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoices |
| token | ✅ | string | Authorization token |
| client_id | ✅ | integer | Client ID |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "Invalid client id" }
```
whmcs/get_related_invoices¶
Returns a list of invoices associated with a specific server or customer account in WHMCS
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_related_invoices |
| id | ❌ | int | Server ID (product_id) |
| account_id | ❌ | int | Account ID to search for invoices |
| token | ✅ | string | Authentication API token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "Invalid billing location $location" }
```
whmcs/getcredits¶
Returns information about available credits on the customer's account in the specified WHMCS location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getcredits |
| token | ✅ | string | Authorization token |
| id | ❌ | integer | User ID (if available) |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "failed to retrive account history at WHMCS_LOCATION, please contact support - [error]" }
```
whmcs/getpaymentgw¶
Returns a list of available payment methods (gateways) for a specific invoice with support for link formatting and HTML button code.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | int | Invoice ID to get available payment methods |
Example Request
Example of a successful response
{
"result": "OK",
"methods": {
"stripe": {
"call": "<a href=\"https://billing.hostkey.com/viewinvoice.php?id=123\">Pay Now</a>"
},
"paypalcheckout": {
"call": "<input type=\"submit\" class=\"btn btn-xl btn-block btn-outline-dark rounded btn-sm\" value=\"Pay Now\" />"
},
"banktransfer": {
"call": "<span>Please wire funds in favor of: ...</span>"
}
}
}
Failure response
``` { "code": -1, "message": "Invalid billing location or invalid invoice" }
```
whmcs/mass_pay¶
Creates one single invoice to pay multiple selected customer invoices.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: mass_pay |
| invoices[] | ✅ | array | Array of invoice IDs to pay |
| token | ✅ | string | Authentication API token |
Example Request
Failure response
``` { "code": -1, "message": "mass_pay_requires_2_invoices" }
```
whmcs/request_cancellation¶
Initiates the process of canceling an order or subscription in WHMCS. Checks for active licenses, invoice payment status, and refund eligibility (including EU B2C rules). If there are traffic debts, it may calculate the withholding amount.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | ✅ | integer | Server ID for cancellation |
| cancellation_type | ❌ | integer | Cancellation type (1 - immediate) |
| cancellation_reason | ❌ | string | Order cancellation reason |
| token | ✅ | string | Authorization token |
| billing | ✅ | string | Billing location |
| clientid | ✅ | integer | Client ID in WHMCS |
| ✅ | string | User email for notification | |
| refund | ❌ | float | Refund amount |
| currency | ❌ | string | Refund currency |
| service_price | ❌ | float | Service price for calculation |
| refund_message | ❌ | string | Refund message text (EN) |
| refund_message_short | ❌ | string | Short refund message text (EN) |
| refund_message_inv | ❌ | string | Message text for partial refund invoice |
| last_invoice | ❌ | integer | Last invoice ID |
| prev_invoice_id | ❌ | integer | Previous invoice ID to account for overpayment |
| tax | ❌ | float | Tax amount (VAT) |
| vat_extra | ❌ | boolean | Flag to include VAT in the refund amount |
| rec_before_tax | ❌ | float | Amount before taxes for correct invoice generation |
| d_deploy_time | ❌ | string | Deployment date (for EU B2C) |
| d_bill_time | ❌ | string | Billing time |
| d_reccuring | ❌ | string | Recurring payment |
| d_period | ❌ | string | Billing period |
| cbp_adjusted | ❌ | boolean | CBP adjustment flag |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "id=123" \
--data "token=YOUR_TOKEN" \
--data "billing=location_name" \
--data "clientid=456" \
--data "[email protected]"
Failure response
``` { "code": -3, "message": "whmcs_immediate_cancellation_no_invoices" }
```
whmcs/request_subscription_cancellation¶
Initiates the bank subscription cancellation process for a server, creating a JIRA ticket and tagging the server accordingly.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: request_subscription_cancellation |
| id | ✅ | int | Server ID |
| cancellation_type | ❌ | string | Cancellation type (e.g., 1) |
| cancellation_reason | ❌ | string | Cancellation reason |
| token | ✅ | string | Authentication API token |
Example Request
Example of a successful response
{
"result": "OK",
"ticket": "JIRA-1234",
"data": {
"account_id": 12345,
"amount": 0.0,
"billing": "whmcs_eu",
"cancellation_reason": "User requested cancellation",
"cancellation_type": "1",
"clientid": 9876,
"created": "2024-01-01 12:00:00",
"currency": "USD",
"customfields": "{}",
"dc_location": "NL",
"description": "Server subscription cancellation",
"displayid": "S12345",
"email": "[email protected]",
"hwconfig": {},
"invoiceid": 0
}
}
Failure response
whmcs/reset_password¶
Allows initiating the password reset process (sending a link via email) or completing it using a recovery token and 2FA code.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: reset_password |
| ✅ | string | User email for password reset | |
| location | ❌ | string | Billing location (default Auto) |
| reset_token | ❌ | string | Password recovery token to complete the process |
| pass | ❌ | string | New user password |
| code | ❌ | string | Two-factor authentication (2FA) code |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=reset_password" \
--data "[email protected]"
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid request, user@domain.tld is not email" }
```
whmcs/transactions¶
Returns a list of user financial transactions from WHMCS by the specified ID or within the current session.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: transactions |
| transaction_id | ❌ | string | Specific transaction ID for filtering |
| invoice_id | ❌ | integer | Invoice ID |
| token | ✅ | string | Authentication API token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "failed to retrive transactions - error_message" }
```
whmcs/update_client¶
Updates customer information in WHMCS and the local database, including contact details, 2FA settings, IP-ACL, and custom fields. Changing email or phone may require re-verification.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_client |
| client_id | ✅ | int | Client ID in the local database |
| location | ✅ | string | Billing location (e.g., whmcs_eu) |
| profile_data[billing_email] | ❌ | string | New client email |
| profile_data[billing_firstname] | ❌ | string | Client first name |
| profile_data[billing_lastname] | ❌ | string | Client last name |
| profile_data[co_smsnum] | ❌ | string | Phone number (undergoes verification) |
| profile_data[ips] | ❌ | string | List of IP addresses for ACL separated by comma or space |
| profile_data[co_customertype] | ❌ | string | Client type (Individual/Company) |
| profile_data[tg_username] | ❌ | string | Telegram username (@username) |
| profile_data[co_secret] | ❌ | string | Secret word for profile verification |
| token | ✅ | string | Authentication API token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=update_client" \
--data "client_id=12345" \
--data "location=whmcs_eu" \
--data "profile_data[billing_email][email protected]" \
--data "token=YOUR_API_TOKEN"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"location": "whmcs_eu",
"billing_email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"customfields": "base64_encoded_string"
}
Failure response
``` { "code": -1, "message": "invalid profile data: first name contain incorrect symbols" }
```
whmcs/update_contact¶
Updates existing customer contact data (first name, last name, email, phone) in the WHMCS system. Changing email or phone may require re-verification.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: update_contact |
| params[contact_id] | ✅ | int | Contact ID to update |
| params[email] | ✅ | string | User email |
| params[firstname] | ❌ | string | Contact first name |
| params[lastname] | ❌ | string | Contact last name |
| params[phonenumber] | ❌ | string | Phone number (automatically transliterated) |
| params[password1] | ❌ | string | New password |
| params[password2] | ❌ | string | New password confirmation |
| token | ✅ | string | Authentication API token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=update_contact" \
--data "params[contact_id]=VALUE" \
--data "params[email][email protected]" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"contactid": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"phonenumber": "+79001234567"
}
Failure response
``` { "code": -1, "message": "fill_required_fields" }