Անցնել պարունակությանը

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 user for an existing customer in WHMCS. If the type is not specified, a random contact is created.
apply_credit apply credit to invoice Applies a credit amount (balance) to pay a specific invoice in WHMCS. If the invoice status changes to 'Paid', traffic overage tags are automatically cleared.
create_addfunds create add funds invoice Creates an invoice in WHMCS to top up the customer's balance by the specified amount. If the subscribe option is enabled, automatic renewal is activated.
delete_cancellation_request delete cancellation request Deletes a cancellation request for a specific server, restoring the invoice status or allowing a new one to be created.
delete_contact delete contact Deletes an additional contact associated with a customer in WHMCS.
download_invoice download invoice Returns a PDF file of the invoice in base64 format for downloading or viewing.
generate_due_invoice generate due invoice Generates the next invoice for a server in WHMCS, considering the current billing cycle and active add-ons. It is blocked if the customer has unpaid invoices or if the next payment date has not yet arrived.
get_billing_data get billing data Returns detailed information about the billing data of a specific server (synchronized data from WHMCS).
get_cancellation_requests get cancellation requests Returns a list of active cancellation requests for a specific server or user, with filtering by date, type, and payment status.
get_client get client info Returns detailed information about the authenticated client, including data from WHMCS and internal system data (tags, verification). Supports extended data retrieval via the full parameter.
get_clientgroups get groups Returns a list of available customer groups from WHMCS for the specified location.
get_contacts get client additional contacts Returns a list of additional contacts associated with a customer in WHMCS. If an email is specified, only contacts with corresponding access rights are returned.
get_invoice get invoice data Returns detailed information about an invoice from WHMCS, including customer data and payment status.
get_invoices get client invoices list Returns a list of all invoices associated with the customer in the selected WHMCS location.
get_related_invoices get related invoices Returns a list of all invoices associated with a specific server (via account_id).
getcredits get balance (credits) Returns information about available credits on the user's account in WHMCS.
getpaymentgw get payment gateways Returns a list of available payment methods (gateways) for a specific invoice with processed payment links.
mass_pay mass pay invoices Allows bulk payment of several customer invoices in a single transaction. A minimum of 2 invoices is required.
request_cancellation request subscription/server cancellation Initiates the order or subscription cancellation process. It checks for active licenses, invoice payment status, and calculates the refund amount considering actual time used and traffic limits.
request_subscription_cancellation request subscription cancellation Initiates the bank subscription cancellation process for a server. Creates a JIRA ticket and attaches a request tag to the server.
reset_password reset password Allows resetting a user's password. If reset_token is not provided, a link is sent via email. If the token is known, 2FA verification and password change are performed.
transactions get transactions Returns a list of user transactions for a specific invoice or transaction ID.
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 contact data Updates additional contact information (first name, last name, email, phone) for a customer in WHMCS. Supports email uniqueness check and phone number verification.

whmcs/add_contact

Adds an additional contact user for an existing customer in WHMCS. If the 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 (must be unique)
profile_data[password1] string Password for the new contact
profile_data[password2] string Password confirmation
profile_data[phonenumber] string Phone number (SMS support is checked)

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

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

```

whmcs/apply_credit

Applies a credit amount (balance) to pay a specific invoice in WHMCS. If the invoice status changes to 'Paid', traffic overage tags are 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

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",
"message": "Credit applied successfully"
}
Failure response

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

```

whmcs/create_addfunds

Creates an invoice in WHMCS to top up the customer's balance by the specified amount. If the subscribe option is enabled, automatic renewal is activated.

HTTP-method: POST

Parameters:

Parameter Required Type Description
amount number Top-up amount. If not specified, the minimum payment is $20.
description string Payment description for the invoice
subscribe boolean Enable automatic renewal (autopay)
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",
"invoice": {
"id": 12345,
"amount": 50.0,
"currency": "USD",
"status": "Unpaid"
},
"message": "Invoice 12345 created"
}
Failure response

``` { "code": -1, "message": "minimal payment amount is $20." }

```

whmcs/delete_cancellation_request

Deletes a cancellation request for a specific server, restoring the invoice status 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
token string Authorization token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=delete_cancellation_request" \
--data "id=VALUE"
Example of a successful response
{
"result": "OK",
"action": "delete_cancellation_request",
"data": {
"result": "success"
}
}
Failure response

``` { "code": -1, "message": "server $id doesn't have a relid data" }

```

whmcs/delete_contact

Deletes an additional contact associated with 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 a PDF file of the invoice in base64 format for downloading or viewing.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: download_invoice
token string Authorization token
invoice_id int Invoice ID
proforma_invoice int Proforma flag (0 or 1)
viewpdf int Display mode: 1 — inline (in browser), 0 — attachment (download)

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 billing location or invalid invoice id" }

```

whmcs/generate_due_invoice

Generates the next invoice for a server in WHMCS, considering the current billing cycle and active add-ons. It is blocked if the customer has unpaid invoices or if the next payment date has not yet arrived.

HTTP-method: POST

Parameters:

Parameter Required Type Description
id int Server ID (equipment ID)
token string API authentication token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"invoices": [
{
"id": 12345,
"amount": 29.99,
"currency": "USD",
"status": "Unpaid"
}
]
}
Failure response

``` { "-1": { "result": -1, "error": "next_invoice_blocked_by_upgrade" }, "-2": { "result": -1, "error": "next_invoice_blocked_by_due_date" }, "-3": { "result": -1, "error": "next_invoice_unpaid_exists" } }

```

whmcs/get_billing_data

Returns detailed information about the billing data of a specific server (synchronized data from WHMCS).

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_billing_data
id int Server ID
token string Authorization token
customer_name string customer_name parameter (detected in code)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_billing_data" \
--data "id=VALUE" \
--data "token=HOSTKEY_TOKEN" \
--data "customer_name=VALUE"
Example of a successful response
{
"result": "OK",
"action": "get_billing_data",
"data": {
"account_id": 12345,
"client_id": 67890,
"status": "Active",
"customer_name": "John Doe",
"location": "EU-Central",
"billing_group": 1,
"customfields": "base64_encoded_string"
}
}
Failure response

``` { "code": -1, "message": "Server not found" }

```

whmcs/get_cancellation_requests

Returns a list of active 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,
"cr_date": "2024-05-20 14:30:00",
"cr_reason": "User requested cancellation",
"cr_type": "End of Billing Period",
"due_date": "2024-06-20",
"name_client": "John Doe",
"customer_id": 55,
"corporate": "N",
"billing": "whmcs_com"
}
]
}
Failure response

``` { "code": -1, "message": "server $id doesn't have a relid data" }

```

whmcs/get_client

Returns detailed information about the authenticated client, including data from WHMCS and internal system data (tags, verification). Supports extended data retrieval via the full parameter.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_client
token string Authorization token
email string Client email for search (used in some scenarios)
full boolean If true, returns an extended set of client data

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_client" \
--data "token=HOSTKEY_TOKEN"
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",
"groupdata": {
"id": 5,
"groupname": "Premium Customers"
},
"internal": {
"id": 123,
"email": "[email protected]",
"corporate": 0,
"active_since": "2024-01-15"
}
}
}
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 location.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_clientgroups
token string Authorization token
location string WHMCS billing location

Example Request

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

``` { "code": -1, "message": "Invalid token or access denied" }

```

whmcs/get_contacts

Returns a list of additional contacts associated with a customer in WHMCS. If an email is specified, only contacts with corresponding access rights are returned.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_contacts
token string Authorization token
email string Email for filtering contacts (used to check access rights under a sub-account)
full boolean If true, returns extended data from WHMCS along with the response

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",
"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
token string Authorization token
invoice_id integer Invoice ID
load_client_data boolean Load client data with the invoice (1 — to load)

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": [
{
"inv_id": 123,
"relid": 456,
"type": "Hosting"
}
]
},
"currencycode": "USD",
"billing": "whmcs"
}
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 in the selected WHMCS location.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_invoices
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_invoices" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"totalresults": 12,
"numreturned": 5,
"invoices": {
"invoice": [
{
"id": 1024,
"userid": 55,
"status": "Paid",
"date": "2023-10-25",
"total": 29.99,
"currency_code": "USD"
}
]
}
}
Failure response

``` { "result": "-1", "error": "Invalid client id" }

```

Returns a list of all 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
id int Server ID (used as product_id in the function)

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": 123,
"userid": 45,
"status": "Paid",
"total": 29.99,
"currency": "USD",
"date": "2024-05-20"
}
]
}
Failure response

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

```

whmcs/getcredits

Returns information about available credits on the user's account in WHMCS.

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": 15.5
}
Failure response

``` { "code": -1, "message": "failed to retrive account history at WHMCS_LOCATION, please contact support" }

```

whmcs/getpaymentgw

Returns a list of available payment methods (gateways) for a specific invoice with processed payment links.

HTTP-method: POST|GET

Parameters:

Parameter Required Type Description
action string Action name (getpaymentgw)
token string Authorization token
invoice_id integer Invoice ID to get available payment methods

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/index.php?id=123"
},
"bitpaycheckout": {
"call": "<input type=\"submit\" class=\"btn btn-xl btn-block btn-outline-dark rounded btn-sm\" value=\"Pay Now\" />"
},
"banktransfer": {
"call": "<span style='text-align:left'>Please wire funds in favor of: Bank Details...</span>"
}
}
}
Failure response

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

```

whmcs/mass_pay

Allows bulk payment of several customer invoices in a single transaction. A minimum of 2 invoices is required.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: mass_pay
invoices[] array<int> Array of invoice IDs for payment. Accepts multiple values: invoices[]=1&invoices[]=2
token string API authentication token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=mass_pay" \
--data "invoices[]=1" \
--data "invoices[]=2" \
--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 or subscription cancellation process. It checks for active licenses, invoice payment status, and calculates the refund amount considering actual time used and traffic limits.

HTTP-method: POST

Parameters:

Parameter Required Type Description
id int Server ID for cancellation
cancellation_type int Cancellation type (1 — immediate with refund)
cancellation_reason string Order cancellation reason
token string Authorization token
billing string Billing location
clientid int Client ID in WHMCS
email string User email for notification
refund float Refund amount
currency string Refund currency
service_price float Service price for calculation
refund_message string Refund message text
refund_message_short string Short refund message text
refund_message_inv string Message text for the invoice
last_invoice int Last invoice ID
prev_invoice_id int Previous invoice ID
relid int Account ID (Relid)
vat_msg string Tax/VAT message
rec_before_tax float Amount before taxes
total_with_tax float Total amount including tax

Example Request

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

``` { "code": -3, "message": "whmcs_server_exceded_traffic (traffic limit exceeded)" }

```

whmcs/request_subscription_cancellation

Initiates the bank subscription cancellation process for a server. Creates a JIRA ticket and attaches a request tag to the server.

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 Subscription 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",
"data": {
"status": "string",
"issueKey": "string"
}
}
Failure response

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

```

whmcs/reset_password

Allows resetting a user's password. If reset_token is not provided, a link is sent via email. If the token is known, 2FA verification and password change are performed.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: reset_password
token string Auth token for request authorization
email string User email for password reset
reset_token string Token to complete the reset process (if email was already requested)
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 protected]"
Example of a successful response
{
"result": "OK",
"message": "Password reset link was sent to the registered email.",
"debug": {}
}
Failure response

``` { "code": -1, "message": "Invalid password reset token, please try again." }

```

whmcs/transactions

Returns a list of user transactions for a specific invoice or transaction ID.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: transactions
transaction_id string Specific transaction ID
invoice_id integer 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 #123"
}
]
}
Failure response

``` { "code": -1, "message": "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 customer email address
profile_data[billing_firstname] string Customer first name
profile_data[billing_lastname] string Customer last name
profile_data[co_customertype] string Customer type (Individual / Company)
profile_data[ips] string List of allowed IP addresses separated by a delimiter
profile_data[co_smsnum] string Phone number for SMS (requires verification)
profile_data[billing_country] string Country of residence/registration
profile_data[password2] string New customer password
profile_data[co_inn] string Tax ID (for companies)
profile_data[co_kpp] string KPP code (for companies)

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"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"location": "whmcs_com",
"billing_email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"customfields": "base64_encoded_string"
}
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 customer in WHMCS. Supports email uniqueness check and phone number verification.

HTTP-method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: update_contact
token string Authorization token
profile_data[contact_id] int Contact ID to update
profile_data[email] string Contact email (uniqueness is checked)
profile_data[firstname] string Contact first name
profile_data[lastname] string Contact last name
profile_data[phonenumber] string Phone number (undergoes verification)
profile_data[password1] string New password 1
profile_data[password2] string New password 2 (for password change)

Example Request

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

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

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