Skip to content

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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=apply_credit" \
--data "token=HOSTKEY_TOKEN" \
--data "invoice_id=12345" \
--data "amount=100.50"
Example of a successful response
{
"result": "success",
"invoiceid": 12345
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=create_addfunds" \
--data "amount=50.0" \
--data "token=YOUR_API_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "create_addfunds",
"invoice": {
"id": 12345,
"amount": 50.0,
"currency": "USD",
"status": "Unpaid"
},
"message": "Invoice 12345 created"
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=delete_cancellation_request" \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "delete_cancellation_request",
"id": 123,
"message": "Cancellation request removed"
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=delete_contact" \
--data "contact_id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "delete_contact",
"clientid": 12345
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=download_invoice" \
--data "token=HOSTKEY_TOKEN"
--data "invoice_id=VALUE"
Example of a successful response
{
"result": "success",
"message": "base64_encoded_pdf_data"
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=generate_due_invoice" \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"invoices": [
{
"id": 105,
"amount": 49.99,
"currency": "USD",
"status": "Unpaid"
}
]
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_billing_data" \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"customer_name": "John Doe",
"eu_b2c": 1,
"eu_withdrawal": 0,
"eu_withdrawal_licenses": [
{
"name": "License Name",
"amount": 10.5,
"currency": "EUR"
}
]
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_cancellation_requests" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"message": [
{
"relid": 123,
"date": "2023-10-27 10:00:00",
"reason": "User requested cancellation",
"type": "End of Billing Period"
}
]
}
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)
email string Customer email for search
id integer Customer ID (account_id)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_client" \
--data "token=HOSTKEY_TOKEN"
--data "id=123"
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_clientgroups" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "get_clientgroups",
"data": {
"groups": [
{
"id": 1,
"groupname": "Retail Customers"
},
{
"id": 2,
"groupname": "Resellers"
}
]
}
}
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
email string Email for searching a specific contact (used when checking sub-account permissions)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_contacts" \
--data "token=HOSTKEY_TOKEN"
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_invoice" \
--data "invoice_id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"status": "success",
"billing": "whmcs_ru",
"items": {
"item": [
{
"relid": 123,
"inv_id": 456,
"type": "Hosting"
}
]
},
"currencycode": "USD",
"userid": 12345,
"customer": {
"client": {
"firstname": "John",
"lastname": "Doe"
}
}
}
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

curl -s "https://invapi.hostkey.com/whmcs" -X POST \
--data "action=get_invoices" \
--data "token=HOSTKEY_TOKEN"
--data "clientid=45"
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" }

```

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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_related_invoices" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"invoices": [
{
"invoiceid": 12345,
"userid": 678,
"status": "Paid",
"total": 50.0,
"currency_code": "USD"
}
]
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=getcredits" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "getcredits",
"message": 150.5
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=getpaymentgw" \
--data "token=YOUR_TOKEN"
--data "invoice_id=123"
Example of a successful response
{
"result": "OK",
"methods": {
"stripe": {
"call": "https://billing.hostkey.com/modules/gateways/stripe/pay.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

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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=mass_pay" \
--data "invoices[]=12345" \
--data "invoices[]=67890" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"invoiceid": 12345
}
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
email 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"
Example of a successful response
{
"result": "OK"
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=request_subscription_cancellation" \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "request_subscription_cancellation",
"data": {
"ticket": "JIRA-12345"
}
}
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
email 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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=reset_password" \
--data "token=HOSTKEY_TOKEN"
--data "email=VALUE"
Example of a successful response
{
"result": "OK",
"message": "Password reset link was sent to the registred email.",
"2fa": 1,
"code": "string"
}
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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=transactions" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "transactions",
"transactions": [
{
"id": 12345,
"amount": 50.0,
"date": "2024-05-20T10:30:00Z",
"description": "Payment for invoice #12345",
"status": "Completed"
}
]
}
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
email 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
{
"result": "OK",
"affiliateemails": [],
"contact_id": 123,
"domainemails": [],
"email_preferences": {
"general": "all"
},
"invoiceemails": "all",
"permissions": "contacts",
"productemails": "all"
}
Failure response

``` { "code": -1, "message": "fill_required_fields" }

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×