Ga naar inhoud

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 request type is not specified, a random contact is created.
apply_credit apply credit to invoice Applies the customer's available balance (credit) to pay a selected invoice. If the invoice status changes to 'Paid' after payment, associated traffic overruns are automatically cleared.
create_addfunds create add funds invoice Creates an invoice in WHMCS for topping up the customer's balance (Add Funds). Supports automatic subscription to recurring payments.
delete_cancellation_request delete cancellation request Deletes an existing service cancellation request for a specific server, allowing the invoice status to be restored or a new one to be generated.
delete_contact delete contact Deletes an additional contact linked to a customer in WHMCS.
download_invoice download invoice Returns a PDF file of the invoice in base64 format. The viewpdf parameter allows displaying the file inline or downloading it as an attachment.
generate_due_invoice generate due invoice Generates the next due invoice for a server in WHMCS, provided the current billing cycle is not completed and there are no unpaid invoices.
get_billing_data get server billing data Returns detailed billing information for a specific server, including customer data and related parameters.
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 information Returns detailed information about the authenticated client, including data from WHMCS and internal system data (tags, groups). Supports extended output mode.
get_clientgroups get groups Returns a list of available customer groups from WHMCS for the specified location.
get_contacts get client subcontacts Returns a list of contacts (subcontacts) linked to 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's account in WHMCS.
get_related_invoices get related invoices Returns a list of invoices associated with a specific server or account in WHMCS
getcredits get balance (credits) Returns information about available credits on the user's account in the specified WHMCS 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 combined invoice to pay a list of selected customer invoices.
request_cancellation request subscription cancellation Sends a subscription cancellation request (bank card subscription) for a server. Checks for active licenses, invoice payment status, and automatic refund eligibility.
request_subscription_cancellation request subscription cancellation Sends a request to JIRA to cancel a server's bank subscription. Checks for active subscriptions and open tickets.
reset_password reset password Initiates the password reset process. If no token is provided, a link is sent via email. If the token is valid, it checks 2FA and updates the password.
transactions get client transactions Returns a list of financial transactions for the user associated with an invoice or a specific transaction.
update_client update client data Updates the customer profile in WHMCS, including personal data (name, email), contact information, 2FA settings, and custom fields. Supports email uniqueness check and phone number verification.
update_contact update contact Updates additional contact information (first name, last name, email, phone) in the WHMCS system. Supports email uniqueness check and phone number validation.

whmcs/add_contact

Adds an additional contact user for 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 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 Password for the new contact
profile_data[password2] string Password confirmation
profile_data[phonenumber] string Phone number (SMS support check)

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=add_contact" \
--data "profile_data[firstname]=John" \
--data "profile_data[email][email protected]" \
--data "profile_data[password1]=Secret123!" \
--data "profile_data[password2]=Secret123!" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"contactid": 67890,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe"
}
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 overruns 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 to pay
amount number Credit amount to apply

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=apply_credit" \
--data "token=HOSTKEY_TOKEN" \
--data "invoice_id=VALUE" \
--data "amount=VALUE"
Example of a successful response
{
"result": "success",
"message": "WHMCS ApplyCredit failed: ..."
}
Failure response

``` { "code": -1, "message": "invalid invoice id 123 at whmcs_eu status - Unpaid" }

```

whmcs/create_addfunds

Creates an invoice in WHMCS for topping up the customer's balance (Add Funds). Supports automatic subscription to recurring payments.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: create_addfunds
amount number Top-up amount. If subscribe=1, the minimum amount is 20.
subscribe boolean Enable automatic payment subscription (auto-renewal)
description string Payment purpose description
token string Authentication API 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,
"status": "Unpaid",
"currency": "USD"
},
"message": "Invoice 12345 created"
}
Failure response

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

```

whmcs/delete_cancellation_request

Deletes an existing service cancellation request for a specific server, allowing the invoice status to be restored or a new one to be generated.

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 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 a PDF file of the invoice in base64 format. The viewpdf parameter allows displaying the file inline or downloading it as an attachment.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: download_invoice
token string Authorization token
invoice_id int Invoice ID
proforma_invoice int Proforma 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 for a server in WHMCS, provided the current billing cycle is not completed and there are no unpaid invoices.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: generate_due_invoice
id integer Server ID
token string Authorization 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": 123,
"amount": 50.0,
"currency": "USD",
"status": "Unpaid"
}
]
}
Failure response

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

```

whmcs/get_billing_data

Returns detailed billing information for a specific server, including customer data and related parameters.

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",
"data": {
"customer_name": "string",
"location": "string"
}
}
Failure response

``` { "code": -1, "message": "invalid request" }

```

whmcs/get_cancellation_requests

Returns a list of active service cancellation requests for a specific server or user with filtering by date, 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
user_id int User ID (if request is from customer)
location string Billing location
period_from string Start date of the period (format Y-m-d)
period_to string End date of the period (format Y-m-d)
cancellation_type string Cancellation type for filtering
billing_status string Billing status (e.g., Paid, Unpaid)
token string Authentication API 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": 12345,
"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",
"account_id": 55,
"billing": "whmcs_eu",
"status": "Active",
"customer_id": 101,
"corporate": "N"
}
]
}
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, groups). Supports extended output mode.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_client
token string Authorization token
full boolean If true, returns an extended dataset (including groups and full client data)
client string Client ID or Email to retrieve information for

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=get_client" \
--data "token=HOSTKEY_TOKEN"
--data "client=VALUE"
Example of a successful response
{
"result": "OK",
"billing_location": "whmcs_com",
"client": {
"id": 123,
"email": "[email protected]",
"firstname": "John",
"lastname": "Doe",
"fullname": "John Doe",
"status": "Active",
"currency_code": "USD",
"countrycode": "US",
"phonenumber": "+1234567890",
"address1": "Main St 1",
"city": "New York",
"state": "NY",
"postcode": "10001",
"countryname": "United States",
"groupid": 5,
"corporate": 0,
"ip": "127.0.0.1"
},
"internal": {
"id": 123,
"email": "[email protected]",
"active_since": "2023-01-15",
"corporate": 0
},
"groupdata": {
"id": 5,
"name": "Premium Users"
}
}
Failure response

``` { "code": -1, "message": "Request failed for client@example.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 location (billing 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",
"data": [
{
"id": 1,
"groupname": "VIP Customers"
},
{
"id": 2,
"groupname": "Standard Users"
}
]
}
Failure response

``` { "code": -1, "message": "Billing error: Invalid location or connection failed" }

```

whmcs/get_contacts

Returns a list of contacts (subcontacts) linked to 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
email string Email for filtering contacts (used to check subcontact permissions)
full boolean If true, returns extended information from WHMCS along with system data
token string Authentication API token

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|GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_invoice
invoice_id int Invoice ID
load_client_data int Load client data with the invoice (1 - yes)
token string Authentication API token

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",
"userid": 123,
"clientid": 456,
"items": {
"item": [
{
"relid": 10,
"inv_id": 10
}
]
},
"currencycode": "USD",
"billing": "whmcs"
}
Failure response

``` { "code": -1, "message": "invalid invoice id $invoice_id at $location" }

```

whmcs/get_invoices

Returns a list of all invoices associated with the customer's account in WHMCS.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_invoices
token string Authorization token
client_id integer Client ID (used for filtering)

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",
"invoices": {
"invoice": [
{
"id": 101,
"userid": 5,
"status": "Paid",
"amount": 25.0,
"currencycode": "USD",
"date": "2023-10-01"
}
]
},
"totalresults": 2,
"numreturned": 2
}
Failure response

``` { "result": "-1", "error": "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
token string Authorization token
id int Server ID (relid)

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,
"date": "2024-01-15"
}
]
}
Failure response

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

```

whmcs/getcredits

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

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: getcredits
token string Authorization token
id integer User ID (if available)

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_eu, please contact support - error_details" }

```

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 identifier: getpaymentgw
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=HOSTKEY_TOKEN"
--data "invoice_id=VALUE"
Example of a successful response
{
"result": "OK",
"methods": {
"paymaster": {
"call": "https://bill.hostkey.com/modules/gateways/paymaster.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'><p data-intl='please_wire_funds_in_favor'>Please wire funds in favor of:&nbsp;</p>..."
}
}
}
Failure response

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

```

whmcs/mass_pay

Creates one single combined invoice to pay a list of selected customer invoices.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: mass_pay
invoices[] array Array of invoice IDs to pay. Accepts multiple values: invoices[]=1&invoices[]=2
token string Authentication API 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

Sends a subscription cancellation request (bank card subscription) for a server. Checks for active licenses, invoice payment status, and automatic refund eligibility.

HTTP Method: POST

Parameters:

Parameter Required Type Description
id int Server ID for subscription cancellation
cancellation_type int Cancellation type (1 — immediate with refund)
cancellation_reason string Reason for cancellation
token string Authorization token
billing string Billing location
clientid int Client ID
email string User email
refund float Refund amount
currency string Refund currency
service_price float Service price for calculation
refund_message string Refund message text (long)
refund_message_short string Short refund message
refund_message_inv string Message for invoice
last_invoice int Last invoice ID
prev_invoice_id int Previous invoice ID
tax float Tax amount
total_with_tax float Total amount including tax
rec_before_tax float Amount before tax
cbp_adjusted string CBP adjustment message

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 "cancellation_type=1"
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 open tickets.

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 for immediate)
cancellation_reason string Reason for subscription cancellation
token string Authentication API token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "action=request_subscription_cancellation" \
--data "id=123" \
--data "token=YOUR_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, a link is sent via email. If the token is valid, it checks 2FA and updates the password.

HTTP Method: POST

Parameters:

Parameter Required Type Description
token string Authorization token for API access
email string User email to send the reset link or verify existing token
reset_token string Token to complete the reset process (used in the second step)
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.",
"debug": {}
}
Failure response

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

```

whmcs/transactions

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

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 to retrieve related transactions
token string Authentication API 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",
"transactions": [
{
"id": 12345,
"amount": 50.0,
"date": "2024-05-20T10:30:00Z",
"status": "Completed",
"description": "Payment for invoice #123"
}
]
}
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, 2FA settings, and custom fields. Supports email uniqueness check and phone number verification.

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_eu)
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)

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_eu"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"location": "whmcs_eu",
"billing_email_changed": true,
"message": "Profile settings updated"
}
Failure response

``` { "code": -1, "message": "invalid profile data: billing_email can't be empty" }

```

whmcs/update_contact

Updates additional contact information (first name, last name, email, phone) in the WHMCS system. Supports email uniqueness check and phone number validation.

HTTP Method: POST

Parameters:

Parameter Required Type Description
contact_id int Contact ID to update
email string Contact email (must be unique)
firstname string Contact first name
lastname string Contact last name
phonenumber string Phone number (undergoes validation and transliteration)
password1 string New password 1
password2 string New password 2 (for password change)
token string Authentication API token

Example Request

curl -s "https://invapi.hostkey.com/whmcs.php" -X POST \
--data "contact_id=67890" \
--data "[email protected]"
--data "firstname=Ivan"
--data "lastname=Ivanov"
--data "phonenumber=+1234567890"
--data "token=YOUR_API_TOKEN"
Example of a successful response
{
"result": "OK",
"clientid": 12345,
"contactid": 67890,
"message": "Contact updated successfully"
}
Failure response

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

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