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 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 a specified invoice. If the invoice status changes to 'Paid', 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, an invoice with automatic payment support is created. |
delete_cancellation_request | delete cancellation request | Deletes an active service cancellation request for a specific server, restoring the order status in WHMCS. |
delete_contact | delete contact | Deletes an additional contact linked to a customer in WHMCS. If the request is made on behalf of the account owner, all additional contacts are deleted. |
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 invoice for a server in WHMCS, taking into account the current billing cycle and active add-ons. |
get_billing_data | get server billing data | Returns detailed billing information for a specific server, including customer data and EU withdrawal status. |
get_cancellation_requests | get cancellation requests list | Returns a list of active service cancellation requests for a specific server or user, with filtering by date and type. |
get_client | get client information | Returns detailed information about the authenticated client, including data from WHMCS and internal system data (tags, verification status). Supports extended data retrieval via the full parameter. |
get_clientgroups | get groups | Returns a list of available customer groups from WHMCS for the current location. |
get_contacts | get client additional contacts | Returns a list of contacts linked to 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 customer's account in WHMCS for the specified location. |
get_related_invoices | get related invoices | Returns a list of invoices related to a specific server (via account_id) |
getcredits | get credits | Returns information about the user's available credits (balance) in WHMCS for the specified location. |
getpaymentgw | get payment gateways for invoice | Returns a list of available payment methods (payment gateways) for a specific invoice. When using USD, only Stripe, Bitpay, and Bitpaycheckout are filtered. |
mass_pay | mass pay invoices | Creates one common invoice to pay a list of selected customer invoices. |
request_cancellation | request order/subscription cancellation | Initiates the service or subscription cancellation process. Checks for active licenses, traffic debts, and invoice payment status. Depending on the cancellation type, it may perform an automatic refund to the account balance. |
request_subscription_cancellation | request subscription cancellation | Sends a request to JIRA to cancel a server's bank subscription. Checks for active subscriptions and open tickets. |
reset_password | reset password | Initiates the password reset process. If no token is provided, a link is sent via email. If the token is valid, it checks 2FA and updates the password. |
transactions | get client transactions | Returns a list of financial transactions for the user associated with their WHMCS account. |
update_client | update client data | Updates the customer profile in WHMCS, including personal data (name, email), contact information, 2FA settings, and custom fields. Supports updating legal data for companies. |
update_contact | update client contact | Updates additional contact information (first name, last name, email, phone) in the WHMCS system. Supports email uniqueness check and phone number verification. |
whmcs/add_contact¶
Adds a new additional contact 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 |
| profile_data[firstname] | ✅ | string | Contact first name (required for EU-Central location) |
| 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 (checked for SMS support) |
| type | ✅ | string | Request type (0 for a random contact) |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=add_contact" \
--data "profile_data[firstname]=VALUE" \
--data "profile_data[lastname]=VALUE" \
--data "profile_data[email]=VALUE" \
--data "profile_data[password1]=VALUE" \
--data "profile_data[password2]=VALUE" \
--data "profile_data[phonenumber]=VALUE" \
--data "type=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"status": "success"
}
Failure response
``` { "code": -1, "message": "fill_required_fields" }
```
whmcs/apply_credit¶
Applies the customer's available balance (credit) to pay a specified invoice. If the invoice status changes to 'Paid', 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 | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "WHMCS ApplyCredit failed: {\"result\":\"error\",\"error\":\"...\"}" }
```
whmcs/create_addfunds¶
Creates an invoice in WHMCS for topping up the customer's balance. If the subscribe option is enabled, an invoice with automatic payment support is created.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| amount | ✅ | number | Top-up amount. If subscribe is not specified, the minimum amount is $20. |
| subscribe | ❌ | boolean | Enables automatic renewal (auto-payment) |
| description | ❌ | string | Payment description for the invoice |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "minimal payment amount is $20." }
```
whmcs/delete_cancellation_request¶
Deletes an active service cancellation request for a specific server, restoring the order status in WHMCS.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_cancellation_request |
| id | ✅ | integer | Server ID (relid) |
| 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 a customer in WHMCS. If the request is made on behalf of the account owner, all additional contacts are deleted.
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
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
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": "Error getting invoice data or access denied" }
```
whmcs/generate_due_invoice¶
Generates the next invoice for a server in WHMCS, taking into account the current billing cycle and active add-ons.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | ✅ | int | Server ID (eq_id) |
| token | ✅ | string | API authentication 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 billing information for a specific server, including customer data and EU withdrawal status.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_billing_data |
| id | ✅ | int | Server ID |
| token | ✅ | string | Authorization token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid request" }
```
whmcs/get_cancellation_requests¶
Returns a list of active service cancellation requests for a specific server or user, with filtering by date and type.
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 product |
| user_id | ❌ | int | User ID to get all their cancellation requests |
| location | ❌ | string | Location (billing location) |
| period_from | ❌ | string | Start date of the filter period |
| period_to | ❌ | string | End date of the filter period |
| cancellation_type | ❌ | string | Cancellation type for filtering |
| billing_status | ❌ | string | Billing status for filtering |
| token | ✅ | string | API authentication 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 data from WHMCS and internal system data (tags, verification status). Supports extended data retrieval via the full parameter.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client |
| token | ✅ | string | Authorization token |
| full | ❌ | boolean | If true, returns an extended dataset (including groups and full profiles) |
Example Request
Example of a successful response
{
"result": "OK",
"client": {
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"fullname": "John Doe",
"status": "Active",
"currency_code": "USD",
"countrycode": "US",
"phonenumber": "+1234567890",
"address1": "Main St 1",
"city": "New York",
"state": "NY",
"postcode": "10001",
"countryname": "United States",
"companyname": "John Corp",
"groupid": 5,
"ip": "192.168.1.1",
"location": "COM",
"corporate": 0,
"active_since": "2023-01-01",
"twofaenabled": true,
"twofa_method": "totp"
},
"billing_location": "whmcs_com",
"internal": {
"id": 123,
"email": "[email protected]",
"corporate": 0,
"active_since": "2023-01-01"
},
"groupdata": {
"id": 5,
"name": "Premium Users"
}
}
Failure response
``` { "code": -1, "message": "Request failed for client@location: error_message" }
```
whmcs/get_clientgroups¶
Returns a list of available customer groups from WHMCS for the current 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
Failure response
``` { "code": -1, "message": "Invalid token or access denied" }
```
whmcs/get_contacts¶
Returns a list of contacts linked to 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 | Email for filtering contacts (used to check subaccount rights) | |
| full | ❌ | boolean | If true, returns extended data from WHMCS |
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"
}
]
}
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 payment status.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoice |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | integer | Invoice ID |
| location | ❌ | string | Billing location (e.g., whmcs_com) |
| load_client_data | ❌ | boolean | Load client data along with the invoice |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid invoice id 0 at whmcs_com" }
```
whmcs/get_invoices¶
Returns a list of all invoices associated with the customer's account in WHMCS for the specified location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_invoices |
| token | ✅ | string | Authorization token |
| location | ❌ | string | Billing location (extracted from session/auth context) |
Example Request
Example of a successful response
Failure response
``` { "result": "-1", "message": "Invalid client id or Invalid billing location" }
```
whmcs/get_related_invoices¶
Returns a list of invoices related to 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 (product_id) |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "server $id are not linked to the billing" }
```
whmcs/getcredits¶
Returns information about the user's available credits (balance) in WHMCS for the specified location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getcredits |
| token | ✅ | string | Authorization token |
| id | ❌ | int | User ID (if not defined via token) |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "failed to retrive account history at whmcs_com, please contact support - error_details" }
```
whmcs/getpaymentgw¶
Returns a list of available payment methods (payment gateways) for a specific invoice. When using USD, only Stripe, Bitpay, and Bitpaycheckout are filtered.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method name: getpaymentgw |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | int | Invoice ID |
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>https://billing.hostkey.com/viewinvoice.php?id=123"
},
"paypalcheckout": {
"call": "<input type=\"submit\" class=\"btn btn-xl btn-block btn-outline-dark rounded btn-sm\" value=\"Pay Now\" />"
}
}
}
Failure response
``` { "code": -1, "message": "failed to retrive payment gw list: error message" }
```
whmcs/mass_pay¶
Creates one common invoice to pay a list of 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. Minimum 2 values. |
| token | ✅ | string | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "mass_pay_requires_2_invoices" }
```
whmcs/request_cancellation¶
Initiates the service or subscription cancellation process. Checks for active licenses, traffic debts, and invoice payment status. Depending on the cancellation type, it may perform an automatic refund to the account balance.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: request_cancellation |
| id | ✅ | int | Server ID for cancellation |
| cancellation_type | ❌ | int | Cancellation type (1 - immediate cancellation with refund) |
| cancellation_reason | ❌ | string | Order cancellation reason |
| token | ✅ | string | Authorization token |
| billing | ✅ | string | Billing location (location) |
| clientid | ✅ | int | Client ID in WHMCS |
| ✅ | string | User email | |
| refund | ❌ | float | Refund amount |
| currency | ❌ | string | Refund currency |
| service_price | ❌ | float | Service cost 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 invoice (RU/EN) |
| last_invoice | ✅ | int | Last invoice ID |
| prev_invoice_id | ❌ | int | Previous invoice ID for partial refund |
| relid | ✅ | int | Server Account ID (relid) |
| tax | ❌ | float | Tax amount |
| vat_extra | ❌ | boolean | VAT extra flag (COM) |
| rec_before_tax | ❌ | float | Amount before taxes for correct invoicing |
| d_deploy_time | ❌ | string | Deployment date (for EU withdrawal calculation) |
| d_bill_time | ❌ | string | Billing time |
| d_reccuring | ❌ | float | Recurring payment amount |
| d_period | ❌ | string | Billing cycle |
| cbp_adjusted | ❌ | string | CBP adjustment message |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=request_cancellation" \
--data "id=123" \
--data "token=YOUR_TOKEN" \
--data "billing=US" \
--data "clientid=456" \
--data "[email protected]" \
--data "last_invoice=789" \
--data "relid=101"
Failure response
``` { "code": -3, "message": "whmcs_server_exceded_traffic" }
```
whmcs/request_subscription_cancellation¶
Sends a request to JIRA to cancel a server's bank subscription. Checks for active subscriptions and open tickets.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: request_subscription_cancellation |
| id | ✅ | int | Server ID (equipment ID) |
| cancellation_type | ❌ | string | Subscription cancellation type |
| cancellation_reason | ❌ | string | Subscription cancellation reason |
| token | ✅ | string | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "sub_cancel_jira_error" }
```
whmcs/reset_password¶
Initiates the password reset process. If no token is provided, a link is sent via email. If the token is valid, it checks 2FA and updates the password.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | Auth token for API authorization |
| ✅ | string | User email for password reset | |
| location | ❌ | string | Billing location (default Auto) |
| reset_token | ❌ | string | Token hash for password reset |
| pass | ❌ | string | New password (used if token is present) |
| code | ❌ | string | Two-factor authentication (2FA) code |
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
Failure response
``` { "code": -1, "message": "Invalid password reset token, please try again." }
```
whmcs/transactions¶
Returns a list of financial transactions for the user associated with their WHMCS account.
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 | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "\(module/\)action: failed to retrive transactions - error message" }
```
whmcs/update_client¶
Updates the customer profile in WHMCS, including personal data (name, email), contact information, 2FA settings, and custom fields. Supports updating legal data for companies.
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_com) |
| profile_data[billing_email] | ❌ | string | New email address |
| profile_data[billing_firstname] | ❌ | string | Client first name |
| profile_data[billing_lastname] | ❌ | string | Client last name |
| profile_data[co_customertype] | ❌ | string | Customer type (Individual / Company) |
| profile_data[ips] | ❌ | string | List of IP addresses for ACL separated by comma/space |
| profile_data[co_smsnum] | ❌ | string | Phone number (with verification) |
| profile_data[billing_country] | ❌ | string | Country code |
| profile_data[co_inn] | ❌ | string | Tax ID (for companies) |
| profile_data[billing_twofaenabled] | ❌ | boolean | Enable/disable 2FA |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=update_client" \
--data "token=HOSTKEY_TOKEN" \
--data "profile_data[client_id]=12345" \
--data "profile_data[location]=whmcs_com" \
--data "profile_data[billing_email][email protected]"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"location": "whmcs_com",
"billing_email": "[email protected]",
"firstname": "Ivan",
"lastname": "Ivanov"
}
Failure response
``` { "code": -1, "message": "invalid profile data: billing_email can't be empty" }
```
whmcs/update_contact¶
Updates additional contact information (first name, last name, email, phone) in the WHMCS system. Supports email uniqueness check and phone number verification.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | Authorization token |
| params[contact_id] | ✅ | int | Contact ID to update |
| params[email] | ✅ | string | Contact email (uniqueness check performed) |
| params[firstname] | ✅ | string | Contact first name |
| params[lastname] | ❌ | string | Contact last name |
| params[phonenumber] | ❌ | string | Phone number (verification required) |
| params[password1] | ❌ | string | New password 1 |
| params[password2] | ❌ | string | New password 2 (for password change) |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "token=HOSTKEY_TOKEN" \
--data "params[contact_id]=67890" \
--data "params[email][email protected]" \
--data "params[firstname]=Ivan" \
--data "params[lastname]=Ivanov"
Example of a successful response
Failure response
``` { "code": -1, "message": "fill_required_fields" }