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 a customer or creates a random contact user. |
apply_credit | apply credit to invoice | Applies the customer's available balance (credit) to pay a selected invoice. If the invoice status changes to 'Paid' after payment, associated traffic overage tags are automatically cleared. |
create_addfunds | create add funds invoice | Creates an invoice in WHMCS for topping up the customer's balance (Add Funds). Supports creating a regular invoice or an invoice with automatic subscription inclusion. |
delete_cancellation_request | delete cancellation request | Deletes an active service cancellation request for a specific server, allowing the order status to be restored or a new invoice to be generated. |
delete_contact | delete contact | Deletes an additional contact linked to a customer in WHMCS. |
download_invoice | download invoice | Returns the invoice PDF file in base64 format. Allows viewing the invoice (inline) or downloading it as a file (attachment). |
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 billing data | Returns detailed billing information for a specific server, including customer data, EU B2C status, and refund information (if applicable). |
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 info | Returns detailed customer information from WHMCS, including profile data, groups, and internal system data. |
get_clientgroups | get groups | Returns a list of available customer groups from WHMCS for the specified location. |
get_contacts | get contacts | Returns a list of additional contacts for the specified customer or checks access rights to them. |
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 a user's account in WHMCS for the specified location. |
get_related_invoices | get related invoices | Returns a list of invoices associated with a specific server or account in WHMCS. |
getcredits | get credits | Returns information about available credits in the WHMCS account balance. |
getpaymentgw | get payment gateways | Returns a list of available payment methods for a specific invoice with processed payment links. |
mass_pay | mass pay invoices | Allows bulk payment of several invoices simultaneously for a customer. A minimum of 2 invoices is required. |
request_cancellation | request order/server cancellation | Initiates the process of canceling an order or service in WHMCS. Checks for active licenses, invoice payment status, and automatic refund eligibility (including EU B2C rules). May account for write-offs if there are traffic debts. |
request_subscription_cancellation | request subscription cancellation | Creates a JIRA ticket to cancel the bank subscription for a server. Checks for active subscriptions and payment status. |
reset_password | reset password | Initiates the password reset process. If no token is provided, an email link is sent. If the token is valid, it allows setting a new password or requesting a 2FA code. |
transactions | get client transactions | Returns a list of financial transactions for the user from WHMCS. If no data is found, returns an empty array. |
update_client | update client data | Updates the customer profile in WHMCS, including personal data (name, email), contact information, and custom fields. Supports updating legal data for companies. |
update_contact | update contact info | Updates contact person data (first name, last name, email, phone) in the WHMCS system. If the email is updated, re-verification may be required. |
whmcs/add_contact¶
Adds a new additional contact for a customer or creates a random contact user.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| type | ❌ | integer | Operation type (0 - create random contact) |
| 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 | Contact password 1 |
| profile_data[password2] | ✅ | string | Contact password 2 (confirmation) |
| profile_data[phonenumber] | ❌ | string | Contact phone number |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "type=0" \
--data "profile_data[firstname]=John" \
--data "profile_data[lastname]=Doe" \
--data "profile_data[email][email protected]" \
--data "profile_data[password1]=Secret123!" \
--data "profile_data[password2]=Secret123!" \
--data "token=YOUR_API_TOKEN"
Example of a successful response
{
"result": "OK",
"contactid": 12345,
"clientid": 12345,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]"
}
Failure response
``` { "code": -1, "message": "fill_required_fields" }
```
whmcs/apply_credit¶
Applies the customer's available balance (credit) to pay a selected invoice. If the invoice status changes to 'Paid' after payment, associated traffic overage tags are automatically cleared.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: apply_credit |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | integer | Invoice ID for payment |
| amount | ✅ | number | Credit amount to apply to the invoice |
Example Request
Failure response
``` { "code": -1, "message": "invalid invoice id 123 at location COM" }
```
whmcs/create_addfunds¶
Creates an invoice in WHMCS for topping up the customer's balance (Add Funds). Supports creating a regular invoice or an invoice with automatic subscription inclusion.
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 (subscription) when paying an invoice for 1 currency unit |
| token | ✅ | string | API authentication 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 active service cancellation request for a specific server, allowing the order status to be restored or a new invoice to be generated.
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
Example of a successful response
Failure response
``` { "code": -1, "message": "Server $id doesn't have a relid data" }
```
whmcs/delete_contact¶
Deletes an additional contact linked to a customer in WHMCS.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: delete_contact |
| contact_id | ✅ | int | Contact ID to delete |
| token | ✅ | string | API authentication token |
Example Request
Failure response
``` { "code": -1, "message": "verification failed, subcontact not found" }
```
whmcs/download_invoice¶
Returns the invoice PDF file in base64 format. Allows viewing the invoice (inline) or downloading it as a file (attachment).
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 invoice flag (0 or 1) |
| viewpdf | ❌ | int | Display mode: 1 — open in browser (inline), 0 — download 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 |
|---|---|---|---|
| action | ✅ | string | Method identifier: generate_due_invoice |
| id | ✅ | int | Server ID (equipment ID) |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "next_invoice_blocked_by_upgrade": { "code": -1, "message": "next_invoice_blocked_by_upgrade" }, "next_invoice_blocked_by_due_date": { "code": -1, "message": "next_invoice_blocked_by_due_date" }, "next_invoice_unpaid_exists": { "code": -1, "message": "next_invoice_unpaid_exists" } }
```
whmcs/get_billing_data¶
Returns detailed billing information for a specific server, including customer data, EU B2C status, and refund information (if applicable).
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": -3, "message": "whmcs_server_exceded_traffic" }
```
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. |
| 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 | Filter by cancellation type |
| billing_status | ❌ | string | Filter by payment status (e.g., Paid, Unpaid) |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "Invalid billing location whmcs_ru" }
```
whmcs/get_client¶
Returns detailed customer information from WHMCS, including profile data, groups, and internal system data.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_client |
| token | ✅ | string | Authorization token |
| full | ❌ | boolean | Return complete data (true) or only basic data (false) |
| ❌ | string | Customer email for search | |
| id | ❌ | integer | Customer ID (account_id) |
Example Request
Example of a successful response
{
"result": "OK|success",
"client": {
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"fullname": "John Doe",
"status": "Active",
"currency_code": "USD",
"groupid": 1,
"countrycode": "US",
"city": "New York",
"state": "NY",
"postcode": "10001",
"address1": "123 Main St",
"address2": "Apt 4B",
"phonenumber": "+1234567890",
"companyname": "John Corp",
"corporate": 0,
"ip": "1.2.3.4",
"billing_location": "whmcs",
"groupdata": {
"id": 1,
"groupname": "Standard Users"
},
"internal": {
"id": 123,
"email": "[email protected]",
"corporate": 0,
"active_since": "2023-01-15"
}
}
}
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 specified location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_clientgroups |
| token | ✅ | string | Authorization token |
| location | ❌ | string | Billing location (WHMCS location) |
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 for the specified customer or checks access rights to them.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_contacts |
| token | ✅ | string | Authorization token |
| ❌ | string | Email for searching a specific contact (used when checking sub-account permissions) |
Example Request
Example of a successful response
{
"result": "OK",
"module": "whmcs",
"action": "get_contacts",
"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
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 customer data (1 - yes) |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "invalid invoice id 0 at whmcs_ru" }
```
whmcs/get_invoices¶
Returns a list of all invoices associated with a user'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 |
| clientid | ❌ | integer | Customer ID |
Example Request
Example of a successful response
{
"result": "OK",
"totalresults": 2,
"numreturned": 2,
"invoices": {
"invoice": [
{
"id": 105,
"userid": 45,
"status": "Paid",
"date": "2023-10-01",
"total": 29.99,
"currency_code": "USD"
},
{
"id": 106,
"userid": 45,
"status": "Unpaid",
"date": "2023-11-01",
"total": 29.99,
"currency_code": "USD"
}
]
}
}
Failure response
``` { "result": "-1", "message": "Invalid client id" }
```
whmcs/get_related_invoices¶
Returns a list of invoices associated with a specific server or account in WHMCS.
HTTP Method: POST|GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_related_invoices |
| account_id | ❌ | int | Account ID to search for invoices |
| location | ❌ | string | Billing location (WHMCS location) |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "result": -1, "error": "server $id are not linked to the billing" }
```
whmcs/getcredits¶
Returns information about available credits in the WHMCS account balance.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: getcredits |
| token | ✅ | string | Authorization token |
Example Request
Failure response
``` { "code": -1, "message": "failed to retrive account history at whmcs_ru, please contact support - error_message" }
```
whmcs/getpaymentgw¶
Returns a list of available payment methods for a specific invoice with processed payment links.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method action |
| token | ✅ | string | Authorization token |
| invoice_id | ✅ | int | Invoice ID |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "failed to retrive payment gw list: error message" }
```
whmcs/mass_pay¶
Allows bulk payment of several invoices simultaneously for a customer. A minimum of 2 invoices is required.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: mass_pay |
| invoices[] | ✅ | array | Array of invoice IDs for payment. 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 process of canceling an order or service in WHMCS. Checks for active licenses, invoice payment status, and automatic refund eligibility (including EU B2C rules). May account for write-offs if there are traffic debts.
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_reason | ❌ | string | Order cancellation reason |
| token | ✅ | string | Authorization token |
| billing | ✅ | string | Billing location |
| clientid | ✅ | int | Customer ID |
| ✅ | string | User email | |
| refund | ❌ | float | Refund amount |
| currency | ❌ | string | Refund currency |
| service_price | ❌ | float | Service price |
| refund_message | ❌ | string | Full refund message |
| refund_message_short | ❌ | string | Short refund message |
| last_invoice | ✅ | int | Last invoice item ID |
| prev_invoice_id | ❌ | int | Previous invoice ID |
| relid | ✅ | int | WHMCS account ID (service_relid) |
| tax | ❌ | float | Tax amount |
| vat_extra | ❌ | boolean | VAT extra flag |
| rec_before_tax | ❌ | float | Amount before taxes |
| d_deploy_time | ❌ | string | Deploy date (deploy_date) |
| d_bill_time | ❌ | string | Current request time |
| d_reccuring | ❌ | float | Recurring payment (rec) |
| 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=location_name" \
--data "clientid=456" \
--data "[email protected]" \
--data "last_invoice=789" \
--data "relid=1011"
Failure response
``` { "code": -3, "message": "whmcs_server_exceded_traffic" }
```
whmcs/request_subscription_cancellation¶
Creates a JIRA ticket to cancel the bank subscription for a server. Checks for active subscriptions and payment status.
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 | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "sub_cancel_no_active_subscription" }
```
whmcs/reset_password¶
Initiates the password reset process. If no token is provided, an email link is sent. If the token is valid, it allows setting a new password or requesting a 2FA code.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: reset_password |
| token | ✅ | string | Auth token for API authorization |
| ✅ | string | User email for password reset | |
| reset_token | ❌ | string | Access recovery token (used during re-request) |
| pass | ❌ | string | New user password |
| code | ❌ | string | Two-factor authentication (2FA) code |
Example Request
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 from WHMCS. If no data is found, returns an empty array.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: transactions |
| transaction_id | ❌ | string | Specific transaction ID for filtering |
| invoice_id | ❌ | int | Invoice ID for filtering |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
Failure response
``` { "code": -1, "message": "failed to retrive transactions - error_details" }
```
whmcs/update_client¶
Updates the customer profile in WHMCS, including personal data (name, email), contact information, 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 | Customer 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 | Billing first name |
| profile_data[billing_lastname] | ❌ | string | Billing last name |
| profile_data[co_customertype] | ❌ | string | Customer type (Individual/Company) |
| profile_data[ips] | ❌ | string | List of IP addresses for ACL separated by comma or space |
| profile_data[co_smsnum] | ❌ | string | Phone number (undergoes verification) |
| profile_data[tg_username] | ❌ | string | Telegram username (@username) |
| profile_data[form_id] | ❌ | string | Form ID (personal_data, account_owner, address) |
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_ru" \
--data "profile_data[billing_email][email protected]"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"location": "whmcs_ru",
"billing_email": "[email protected]",
"customfields": {},
"taxexempt": false,
"twofaenabled": 0
}
Failure response
``` { "code": -1, "message": "invalid profile data: billing_firstname can't be empty" }
```
whmcs/update_contact¶
Updates contact person data (first name, last name, email, phone) in the WHMCS system. If the email is updated, re-verification may be required.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| contact_id | ✅ | int | Contact ID to update |
| ✅ | string | Contact person email | |
| firstname | ✅ | string | Contact first name |
| lastname | ❌ | string | Contact last name |
| phonenumber | ❌ | string | Phone number (automatically translated) |
| password1 | ❌ | string | New contact password |
| password2 | ❌ | string | Password confirmation |
| token | ✅ | string | API authentication token |
Example Request
curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "contact_id=123" \
--data "[email protected]" \
--data "firstname=Ivan" \
--data "lastname=Ivanov" \
--data "token=YOUR_API_TOKEN"
Example of a successful response
Failure response
``` { "code": -1, "message": "fill_required_fields" }