Ana içeriğe geç

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 an 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 funds from the account balance (credit) to pay a selected invoice. If the invoice is paid with credit, the invoice status changes to Paid.
create_addfunds create add funds invoice Creates an invoice in WHMCS for topping up the customer's balance (Add Funds). Supports automatic enabling of autopayments.
delete_cancellation_request delete cancellation request Deletes an existing cancellation request for a specific server, restoring invoice statuses or allowing a new one to be created.
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. The viewpdf parameter allows displaying the file in an inline viewer or downloading it as an attachment.
generate_due_invoice generate due invoice Generates the next due invoice 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 Returns a list of active service cancellation requests for a specific server or user with filtering by type and payment status.
get_client get client info Returns detailed information about the authenticated client, including data from WHMCS and internal system tags.
get_clientgroups get groups Returns a list of available customer groups from WHMCS for the specified billing location.
get_contacts get contacts Returns a list of additional contacts for the specified client or checks access rights to subaccount contacts.
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 client in WHMCS for the specified location.
get_related_invoices get related invoices Returns a list of invoices associated with a specific server (via account_id)
getcredits get credits (balance) Returns information about the user's available balance (credits) in WHMCS for the specified location.
getpaymentgw get payment gateways Returns a list of available payment methods for a specific invoice with processed payment links
mass_pay mass pay invoices Creates one single invoice to pay a list of selected client invoices.
request_cancellation request cancellation Initiates the order/server cancellation process in WHMCS, including status checks, refund calculation, and JIRA ticket creation.
request_subscription_cancellation request subscription cancellation Sends a request to JIRA to cancel a server's bank subscription. 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 (with 2FA support).
transactions get client transactions Returns a list of financial transactions for the user associated with an invoice or a specific transaction.
update_client update client data Updates customer information in WHMCS, including personal data (name, email), contact information, and custom profile fields.
update_contact update contact data Updates additional contact information (first name, last name, email, phone) for a client in WHMCS. Supports email uniqueness check and phone number verification.

whmcs/add_contact

Adds an 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
type integer Operation type (0 - create new contact)
profile_data[firstname] string Contact first name
profile_data[lastname] string Contact last name
profile_data[email] string Contact email
profile_data[password1] string Password (required for creation)
profile_data[password2] string Password confirmation
profile_data[phonenumber] string Phone number (required for EU-Central location)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=add_contact" \
--data "profile_data[firstname]=VALUE" \
--data "profile_data[email]=VALUE" \
--data "profile_data[password1]=VALUE" \
--data "profile_data[password2]=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]"
}
Failure response

``` { "-1": "fill_required_fields" }

```

whmcs/apply_credit

Applies funds from the account balance (credit) to pay a selected invoice. If the invoice is paid with credit, the invoice status changes to Paid.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: apply_credit
invoice_id int Invoice ID for payment
amount float Credit amount to apply
token string API authentication token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=apply_credit" \
--data "invoice_id=VALUE" \
--data "amount=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "success",
"error": null
}
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 (Add Funds). Supports automatic enabling of autopayments.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: create_addfunds
token string Authorization token
params[amount] number Top-up amount. If not specified, the default value (0) is used
params[description] string Payment description
params[subscribe] boolean Enable automatic billing (autopay)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=create_addfunds" \
--data "token=YOUR_TOKEN" \
--data "params[amount]=50.0" \
--data "params[description]=Top up balance" \
--data "params[subscribe]=true"
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": "failed to create AF invoice: [error WHMCS]" }

```

whmcs/delete_cancellation_request

Deletes an existing cancellation request for a specific server, restoring invoice statuses or allowing a new one to be created.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: delete_cancellation_request
id int Server ID (relid)
token string Auth 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",
"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
token string Authorization token
contact_id int Contact ID to delete

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=delete_contact" \
--data "token=HOSTKEY_TOKEN"
--data "contact_id=VALUE"
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. The viewpdf parameter allows displaying the file in an inline viewer or downloading it as an 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 — inline, 0 — 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_content"
}
Failure response

``` { "code": -1, "message": "Invalid invoice id" }

```

whmcs/generate_due_invoice

Generates the next due invoice 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": { "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

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",
"module": "whmcs",
"action": "get_billing_data",
"customer_name": "John Doe",
"eu_withdrawal": 0,
"location": "whmcs"
}
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 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.
cancellation_type string Filter by cancellation type (e.g., 'End of Billing Period')
billing_status string Filter by payment status in WHMCS (e.g., 'Paid', 'Unpaid')
period_from string Start date of the period (format Y-m-d)
period_to string End date of the period (format Y-m-d)
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,
"cr_date": "2024-05-20 14:30:00",
"cr_reason": "User requested cancellation",
"cr_type": "End of Billing Period",
"name_client": "John Doe",
"due_date": "2024-06-20",
"account_id": 55,
"billing": "whmcs_ru",
"status": "Active",
"corporate": "N",
"customer_id": 10,
"is_subcontact": false
}
]
}
Failure response

``` { "code": -1, "message": "Invalid billing location $location" }

```

whmcs/get_client

Returns detailed information about the authenticated client, including data from WHMCS and internal system tags.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_client
token string Authorization token
email string Client email for search
full boolean Flag to get full data (including passwords and hidden fields)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_client" \
--data "token=HOSTKEY_TOKEN" \
--data "[email protected]" \
--data "full=true"
Example of a successful response
{
"result": "OK",
"client": {
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"fullname": "John Doe",
"companyname": "Example Corp",
"countrycode": "US",
"currency_code": "USD",
"status": "Active",
"ip": "192.168.1.1",
"billing_location": "whmcs_com",
"internal": {
"id": 123,
"email": "[email protected]",
"corporate": 0,
"active_since": "2024-01-01"
},
"groupdata": null
}
}
Failure response

``` { "code": -1, "message": "Request failed for client@domain.com: error_message" }

```

whmcs/get_clientgroups

Returns a list of available customer groups from WHMCS for the specified billing location.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_clientgroups
location string Location (billing location) to get groups
token string API authentication token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_clientgroups" \
--data "location=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "get_clientgroups",
"data": {
"groups": [
{
"id": 1,
"groupname": "VIP Customers"
},
{
"id": 2,
"groupname": "Standard Users"
}
]
}
}
Failure response

``` { "code": -1, "message": "Billing error: WHMCS connection failed" }

```

whmcs/get_contacts

Returns a list of additional contacts for the specified client or checks access rights to subaccount contacts.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_contacts
token string Authorization token
email string Email for contact search (used for subaccount)
full boolean Returns full client data along with contacts

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": {
"contact": [
{
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"permissions": "contacts"
}
]
},
"client": {
"id": 456,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe"
},
"billing_location": "COM"
}
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
token string Authorization token
invoice_id integer Invoice ID
load_client_data integer Load client data flag (1 - yes)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_invoice" \
--data "token=HOSTKEY_TOKEN"
--data "invoice_id=VALUE"
Example of a successful response
{
"result": "OK",
"status": "success",
"items": {
"item": [
{
"relid": 123,
"inv_id": 456
}
]
},
"currencycode": "USD",
"billing": "whmcs",
"customer": {
"client": {
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]"
}
}
}
Failure response

``` { "code": -1, "message": "invalid invoice id 0 at whmcs_ru" }

```

whmcs/get_invoices

Returns a list of all invoices associated with the client in WHMCS for the specified location.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_invoices
token string Authorization token
client_id integer Client ID
location string Billing location (whmcs_id)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_invoices" \
--data "token=HOSTKEY_TOKEN"
--data "client_id=VALUE"
--data "location=VALUE"
Example of a successful response
{
"result": "OK",
"invoices": [
{
"invoiceid": 123,
"invoicenum": "INV-001",
"date": "2023-10-01",
"duedate": "2023-11-01",
"total": 50.0,
"status": "Paid",
"billing": "whmcs_ru"
}
]
}
Failure response

``` { "code": -1, "message": "Invalid client id or Invalid billing location" }

```

Returns a list of invoices associated with 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

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": [
{
"userid": 45,
"status": "Paid",
"invoiceid": 123,
"amount": 50.0,
"currency_code": "USD"
}
]
}
Failure response

``` { "result": -1, "error": "server $id are not linked to the billing" }

```

whmcs/getcredits

Returns information about the user's available balance (credits) in WHMCS for the specified location.

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_description" }

```

whmcs/getpaymentgw

Returns a list of available payment methods for a specific invoice with processed payment links

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: getpaymentgw
token string Authorization token
invoice_id int Invoice ID to get payment gateways

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=getpaymentgw" \
--data "invoice_id=123"
Example of a successful response
{
"result": "OK",
"methods": {
"paymaster": {
"call": "https://bill.hostkey.com/modules/gateways/paymaster.php?id=123"
},
"paypalcheckout": {
"call": "<span class='btn'>Pay Now</span>"
},
"banktransfer": {
"call": "Please wire funds in favor of: ..."
}
}
}
Failure response

``` { "code": -1, "message": "failed to retrive payment gw list: error message" }

```

whmcs/mass_pay

Creates one single invoice to pay a list of selected client 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

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=mass_pay" \
--data "invoices[]=101" \
--data "invoices[]=102" \
--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 order/server cancellation process in WHMCS, including status checks, refund calculation, and JIRA ticket creation.

HTTP-method: POST

Parameters:

Parameter Required Type Description
id int Server ID for cancellation
cancellation_type int Cancellation type (1 - immediate)
cancellation_reason string Reason for cancellation
refund float Refund amount
currency string Refund currency
service_price float Service cost for calculation
refund_message string Refund message (RU/EN)
refund_message_short string Short refund message
last_invoice int Last invoice ID for refund
prev_invoice_id int Previous invoice ID (if any)
relid string WHMCS account ID
vat_msg string VAT message
rec_before_tax float Amount before taxes
d_deploy_time string Deploy date
d_bill_time string Billing time
d_reccuring string Recurring payment
d_period string Billing period
cbp_adjusted string CBP adjustment message
token string API authentication token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "id=123" \
--data "last_invoice=456" \
--data "relid=789" \
--data "token=YOUR_TOKEN"
Example of a successful response
{
"result": "OK"
}
Failure response

``` { "code": -3, "message": "whmcs_immediate_cancellation_no_invoices" }

```

whmcs/request_subscription_cancellation

Sends a request to JIRA to cancel a server's bank subscription. 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 for subscription cancellation
cancellation_type string Cancellation type (e.g., 1)
cancellation_reason string Reason for subscription cancellation
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",
"ticket": "JIRA-12345"
}
Failure response

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

```

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 (with 2FA support).

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
email string User email for password reset
reset_token string Reset confirmation token (if not empty)
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 "[email protected]"
Example of a successful response
{
"result": "OK",
"action": "reset_password",
"message": "Password reset link was sent to the registred email.",
"2fa": 1,
"debug": "some_token_or_code"
}
Failure response

``` { "result": "-1", "error": "invalid request, user@domain.tld is not email", "message": "Invalid password reset token, please try again." }

```

whmcs/transactions

Returns a list of financial transactions for the user associated with an invoice or a specific transaction.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: transactions
transaction_id string Specific transaction ID for filtering
invoice_id integer Invoice ID to get related transactions
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,
"currency": "USD",
"date": "2024-05-20T10:30:00Z",
"description": "Payment for invoice #123"
}
]
}
Failure response

``` { "code": -1, "message": "failed to retrive transactions - error_details" }

```

whmcs/update_client

Updates customer information in WHMCS, including personal data (name, email), contact information, and custom profile fields.

HTTP-method: POST

Parameters:

Parameter Required Type Description
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 allowed IP addresses separated by comma or space
profile_data[co_smsnum] string Phone number for SMS verification
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 "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",
"message": "Profile updated successfully"
}
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) for a client in WHMCS. Supports email uniqueness check and phone number verification.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: update_contact
contact_id int Contact ID to update
email string Contact email (checked for uniqueness and validity)
firstname string Contact first name
lastname string Contact last name
phonenumber string Phone number (verified via tw_verify_number)
password1 string New password for contact
password2 string Confirm new password
token string API authentication token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=update_contact" \
--data "contact_id=VALUE" \
--data "email=VALUE" \
--data "firstname=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"contactid": 67890,
"clientid": 12345
}
Failure response

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