Skip to content

whmcs.php

WHMCS integration module for managing clients, invoices, credits, order cancellations, and server billing data.

API Methods

Method Action Description
add_contact create contact Adds a new contact to an existing client in the billing system.
apply_credit apply credit Applies credit from the client's balance to pay a specified invoice.
create_addfunds create add funds invoice Creates an invoice for adding funds (Add Funds).
delete_cancellation_request delete cancellation request Removes an active server cancellation request and restores the invoice.
delete_contact delete contact Removes a contact from the client account.
download_invoice download invoice Generates and returns the invoice PDF file.
generate_due_invoice generate invoice Generates the next invoice for server payment.
get_billing_data get billing data Retrieves synchronized billing data for a server.
get_cancellation_requests get cancellation requests Returns a list of active server cancellation requests.
get_client get client data Returns information about the authorized client or by ID.
get_clientgroups get client groups Returns a list of client groups in the billing system.
get_contacts get contacts Returns a list of additional client contacts.
get_invoice get invoice Returns data for a specific invoice.
get_invoices get invoices Returns a list of client invoices.
get_related_invoices get related invoices Returns invoices linked to a server or account.
getcredits get credits Returns the client's credit history.
getpaymentgw get payment gateways Returns available payment methods for an invoice.
mass_pay mass payment Pays multiple invoices with a single payment.
request_cancellation request cancellation Initiates the server cancellation process with refund calculation.
reset_password reset password Initiates a password reset or sets a new one with 2FA.
transactions get transactions Returns the client's transaction history.
update_client update client Updates the client profile data in the billing system.
update_contact update contact Updates the client contact data.

whmcs/add_contact

Adds a new contact to an existing client in the billing system.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: add_contact
token string Authorization token
profile_data[email] string New contact email
profile_data[password2] string Password for the new contact
profile_data[firstname] string Contact first name
profile_data[lastname] string Contact last name
profile_data[phonenumber] string Phone number in E164 format
profile_data[companyname] string Company name
profile_data[address1] string Address line 1
profile_data[address2] string Address line 2
profile_data[city] string City
profile_data[state] string State/Region
profile_data[postcode] string Postal code
profile_data[country] string Country
profile_data[tax_id] string Taxpayer identification number
profile_data[permissions] string Contact access rights
profile_data[generalemails] string Receive general emails
profile_data[domainemails] string Receive domain emails
profile_data[invoiceemails] string Receive invoice emails
profile_data[productemails] string Receive product emails
profile_data[supportemails] string Receive support emails
profile_data[affiliateemails] string Receive affiliate program emails
profile_data[subaccount] string Create sub-account

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=add_contact" \
--data "token=HOSTKEY_TOKEN" \
--data "profile_data[email][email protected]" \
--data "profile_data[password2]=SecurePassword123" \
--data "profile_data[firstname]=John" \
--data "profile_data[lastname]=Doe"
Example of a successful response
{
"result": "success",
"contactid": 12345,
"clientid": 67890
}
Failure response
{
"code": -1,
"message": "email not specified"
}

whmcs/apply_credit

Applies credit from the client's balance to pay a specified invoice.

HTTP Method: POST

Parameters:

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

Example Request

curl -s "https://api.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",
"action": "apply_credit",
"invoiceid": 5001,
"balance": 0.0
}
Failure response
{
"code": -1,
"message": "Invalid invoice id or insufficient credit"
}

whmcs/create_addfunds

Creates an invoice for adding funds (Add Funds).

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: create_addfunds
token string Authorization token
amount float Top-up amount
description string Transaction description
subscribe int Flag to enable auto-payment

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=create_addfunds" \
--data "token=HOSTKEY_TOKEN" \
--data "amount=VALUE" \
--data "description=Optional description" \
--data "subscribe=1"
Example of a successful response
{
"result": "OK",
"invoice": 9999,
"message": "Invoice 9999 created"
}
Failure response
{
"code": -1,
"message": "minimal payment amount is 20."
}

whmcs/delete_cancellation_request

Removes an active server cancellation request and restores the invoice.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: delete_cancellation_request
token string Authorization token
id int Server ID
full int Return full data

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=delete_cancellation_request" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE"
Example of a successful response
{
"result": "OK",
"action": "delete_cancellation_request",
"message": "Cancellation request removed"
}
Failure response
{
"code": -1,
"message": "Server does not have a relid data"
}

whmcs/delete_contact

Removes a contact from the client account.

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://api.hostkey.com/whmcs.php" -X POST \
--data "action=delete_contact" \
--data "token=HOSTKEY_TOKEN" \
--data "contact_id=VALUE"
Example of a successful response
{
"result": "success",
"action": "delete_contact",
"clientid": 67890
}
Failure response
{
"code": -1,
"message": "Verification failed, subcontact not found"
}

whmcs/download_invoice

Generates and returns the invoice PDF file.

HTTP Method: 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 in browser (1) or download (0)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=download_invoice" \
--data "token=HOSTKEY_TOKEN" \
--data "invoice_id=VALUE"
Example of a successful response
{
"result": "OK",
"action": "download_invoice",
"content_type": "application/pdf",
"message": "PDF binary data"
}
Failure response
{
"code": -1,
"message": "Invalid billing location"
}

whmcs/generate_due_invoice

Generates the next invoice for server payment.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: generate_due_invoice
token string Authorization token
id int Server ID

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=generate_due_invoice" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE"
Example of a successful response
{
"result": "OK",
"action": "generate_due_invoice",
"invoices": [
  {
    "id": 12345,
    "status": "Unpaid",
    "total": 50.0
  }
]
}
Failure response
{
"code": -1,
"message": "next_invoice_blocked_by_upgrade"
}

whmcs/get_billing_data

Retrieves synchronized billing data for a server.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_billing_data
token string Authorization token
id int Server ID

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_billing_data" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE"
Example of a successful response
{
"result": "OK",
"Condition_Component": "rent",
"account_id": 500,
"billing_cycle": "monthly",
"billing_reccuring": 49.99,
"billing_status": "Active",
"currencysuffix": "EUR",
"customer_email": "[email protected]",
"customer_name": "John Doe",
"days": 30,
"days_left": 15,
"groupdata": {
  "discountpercent": 0
},
"invert": 0,
"lock_billing_cycle_change": 0,
"name_client": "John Doe",
"next_due_date": "2024-02-15"
}
Failure response
{
"code": -1,
"message": "invalid request"
}

whmcs/get_cancellation_requests

Returns a list of active server cancellation requests.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_cancellation_requests
token string Authorization token
id int Server ID (optional). If not specified, returns the list for the current user
period_from string Start of the filter period (YYYY-MM-DD)
period_to string End of the filter period (YYYY-MM-DD)
cancellation_type string Cancellation type (filter)
billing_status string Billing status (filter)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_cancellation_requests" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "success",
"message": [
  {
    "id": 101,
    "relid": 500,
    "date": "2024-01-20",
    "reason": "Too expensive",
    "type": "Immediate",
    "billing_status": "Active",
    "due_date": "2024-02-20",
    "name_client": "John Doe",
    "corporate": "N",
    "customer_id": 12345
  }
]
}
Failure response
{
"code": -1,
"message": "Server does not have a relid data"
}

whmcs/get_client

Returns information about the authorized client or by ID.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_client
token string Authorization token
client_id int Client ID (used if email is not provided)
email string Client email (used if client_id is not provided)
full bool Return full data (including passwords)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_client" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"client": {
  "id": 123,
  "firstname": "John",
  "lastname": "Doe",
  "email": "[email protected]",
  "companyname": "Acme Corp",
  "status": "Active",
  "credit": 100.5,
  "currency_code": "EUR",
  "corporate": 0,
  "inn": "",
  "contractnum": "",
  "twofa_method": "none",
  "twofaenabled": false,
  "customfields": []
},
"billing_location": "whmcs",
"internal": {
  "id": 456,
  "verified": true,
  "firstname": "John",
  "lastname": "Doe"
},
"groupdata": {
  "id": 1,
  "groupname": "Reseller"
}
}
Failure response
{
"code": -1,
"message": "Request failed for account_id@location: Invalid billing location"
}

whmcs/get_clientgroups

Returns a list of client groups in the billing system.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_clientgroups
token string Authorization token
location string Billing location (e.g., whmcs, whmcs_eu)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_clientgroups" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "success",
"groups": {
  "group": [
    {
      "id": "1",
      "groupname": "Resellers",
      "discount": "10"
    }
  ]
}
}
Failure response
{
"code": -1,
"message": "invalid request"
}

whmcs/get_contacts

Returns a list of additional client contacts.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_contacts
token string Authorization token
full boolean Return full data (including all WHMCS fields)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_contacts" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "get_contacts",
"permission_contacts_granted": true,
"contacts": [
  {
    "id": "101",
    "firstname": "Jane",
    "lastname": "Smith",
    "email": "[email protected]",
    "permissions": "invoices,contacts"
  }
]
}
Failure response
{
"code": -1,
"message": "Fail to get contacts list"
}

whmcs/get_invoice

Returns data for a specific invoice.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_invoice
token string Authorization token
invoice_id int Invoice ID
load_client_data int Load client data (1 - yes, 0 - no)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_invoice" \
--data "token=HOSTKEY_TOKEN" \
--data "invoice_id=VALUE"
Example of a successful response
{
"result": "OK",
"invoiceid": 5001,
"date": "2024-01-01",
"duedate": "2024-01-31",
"total": 50.0,
"status": "Unpaid",
"currencycode": "USD",
"billing": "whmcs",
"items": {
  "item": [
    {
      "description": "VPS Server",
      "amount": 50.0,
      "relid": 12345,
      "inv_id": 12345
    }
  ]
},
"customer": {
  "client": {
    "firstname": "John",
    "lastname": "Doe",
    "currency_code": "USD"
  }
},
"firstname": "John",
"lastname": "Doe"
}
Failure response
{
"code": -1,
"message": "Invalid invoice id"
}

whmcs/get_invoices

Returns a list of client invoices.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_invoices
token string Authorization token

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_invoices" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"totalresults": 5,
"numreturned": 5,
"invoices": {
  "invoice": [
    {
      "id": 5001,
      "invoicenumber": "1001",
      "date": "2024-01-01",
      "duedate": "2024-01-15",
      "total": 50.0,
      "status": "Unpaid",
      "items": {
        "item": [
          {
            "type": "Hosting",
            "description": "VPS Server",
            "amount": 50.0
          }
        ]
      }
    }
  ]
}
}
Failure response
{
"code": -1,
"message": "Invalid billing location"
}

Returns invoices linked to a server or account.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: get_related_invoices
token string Authorization token
id int Server ID (eq_id). If provided, used to find account_id.
account_id int Account ID in billing (product_id). Used directly to search for invoices.

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=get_related_invoices" \
--data "token=HOSTKEY_TOKEN" \
--data "id=123"
Example of a successful response
{
"result": "success",
"invoices": [
  {
    "id": 5001,
    "invoiceid": "INV-5001",
    "date": "2023-10-25",
    "duedate": "2023-11-01",
    "total": 50.0,
    "status": "Unpaid",
    "userid": 12345
  }
]
}
Failure response
{
"code": -1,
"message": "server 123 are not linked to the billing"
}

whmcs/getcredits

Returns the client's credit history.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: getcredits
token string Authorization token

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=getcredits" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"action": "getcredits",
"message": {
  "credits": [
    {
      "id": 1,
      "date": "2024-01-01",
      "amount": 100.0,
      "description": "Add Funds"
    }
  ]
}
}
Failure response
{
"code": -1,
"message": "failed to retrive account history at whmcs, please contact support - unknown error"
}

whmcs/getpaymentgw

Returns available payment methods for an invoice.

HTTP Method: GET

Parameters:

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

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=getpaymentgw" \
--data "token=HOSTKEY_TOKEN" \
--data "invoice_id=VALUE"
Example of a successful response
{
"result": "OK",
"methods": {
  "creditcard": {
    "name": "Credit Card",
    "call": "https://billing.example.com/pay.php?id=123"
  },
  "yookassa": {
    "name": "YooKassa",
    "call": "https://yookassa.example.com/checkout"
  }
}
}
Failure response
{
"code": -1,
"message": "Invalid invoice id"
}

whmcs/mass_pay

Pays multiple invoices with a single payment.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: mass_pay
token string Authorization token
invoices array<int> Array of invoice IDs to pay

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=mass_pay" \
--data "token=HOSTKEY_TOKEN" \
--data "invoices[]=123" \
--data "invoices[]=456"
Example of a successful response
{
"result": "OK",
"invoiceid": 9999
}
Failure response
{
"code": -1,
"message": "Failed to create masspay invoice"
}

whmcs/request_cancellation

Initiates the server cancellation process with refund calculation.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: request_cancellation
token string Authorization token
id int Server ID
cancellation_type int Cancellation type (1 - immediate)
cancellation_reason string Cancellation reason
terminate_reason_custom string Custom reason

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=request_cancellation" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE" \
--data "cancellation_type=VALUE"
Example of a successful response
{
"result": "OK"
}
Failure response
{
"code": -3,
"message": "whmcs_immediate_cancellation_no_invoices"
}

whmcs/reset_password

Initiates a password reset or sets a new one with 2FA.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: reset_password
email string Client email
reset_token string Password reset token
pass string New password
code string 2FA code

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=reset_password" \
--data "email=VALUE"
Example of a successful response
{
"result": "OK",
"message": "Password reset link was sent to the registred email.",
"2fa": 1
}
Failure response
{
"code": -1,
"message": "Invalid password reset token"
}

whmcs/transactions

Returns the client's transaction history.

HTTP Method: GET

Parameters:

Parameter Required Type Description
action string Method identifier: transactions
token string Authorization token
invoice_id int Filter by invoice ID
transaction_id string Filter by transaction ID

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X GET \
--data "action=transactions" \
--data "token=HOSTKEY_TOKEN"
Example of a successful response
{
"result": "OK",
"transactions": [
  {
    "id": 123,
    "date": "2024-01-01",
    "amount": 50.0,
    "status": "Complete"
  }
]
}
Failure response
{
"code": -1,
"message": "Failed to retrieve transactions"
}

whmcs/update_client

Updates the client profile data in the billing system.

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: update_client
token string Authorization token
profile_data[billing_firstname] string Client first name
profile_data[billing_lastname] string Client last name
profile_data[billing_email] string Client email
profile_data[billing_phonenumber] string Client phone
profile_data[co_smsnum] string SMS number
profile_data[ips] string IP list for ACL
profile_data[billing_companyname] string Company name
profile_data[billing_address1] string Address line 1
profile_data[billing_address2] string Address line 2
profile_data[billing_city] string City
profile_data[billing_postcode] string Postal code
profile_data[billing_country] string Country
profile_data[billing_state] string State/Region
profile_data[co_inn] string INN (for legal entities)
profile_data[co_kpp] string KPP (for legal entities)
profile_data[co_regaddress] string Legal address
profile_data[co_bankdata] string Bank details
profile_data[co_edo] string EDO status
profile_data[co_edoprovider] string EDO provider
profile_data[co_contractid] string Contract number
profile_data[co_contract] string Contract data
profile_data[co_customertype] string Client type (Individual/Company)
profile_data[co_subscription] string Subscription ID
profile_data[co_web] string Company website
profile_data[co_size] string Company size
profile_data[co_industry] string Industry
profile_data[co_autopayment] string Auto-payment
profile_data[co_payfirstday] string First day payment
profile_data[co_marktemails] string Marketing emails
profile_data[co_marktsms] string Marketing SMS
profile_data[co_passdata] string Passport data
profile_data[co_skype] string Skype
profile_data[co_origin] string Source
profile_data[co_secret] string Secret word
profile_data[co_comment] string Comment
profile_data[billing_status] string Client status
profile_data[billing_emailoptout] boolean Opt-out of emails
profile_data[billing_marketingoptin] boolean Opt-in to marketing
profile_data[billing_overideduenotices] boolean Ignore overdue notices
profile_data[billing_separateinvoices] boolean Separate invoices
profile_data[billing_taxexempt] boolean Tax exempt
profile_data[billing_latefeeoveride] boolean Ignore late fees
profile_data[billing_overrideautoclose] boolean Ignore auto-close
profile_data[billing_allowSingleSignOn] boolean Allow SSO
profile_data[billing_disableautocc] boolean Disable auto-credit card payment
profile_data[billing_groupid] integer Client group ID
profile_data[billing_currency] string Currency
profile_data[billing_notes] string Notes
profile_data[billing_twofaenabled] boolean Enable 2FA
profile_data[co_2famethod] string 2FA method
profile_data[tag_autocreditenabled] boolean Enable auto-credit
profile_data[tg_username] string Telegram username
profile_data[form_id] string Form ID (personal_data, account_owner, address)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=update_client" \
--data "token=HOSTKEY_TOKEN" \
--data "profile_data[billing_firstname]=John" \
--data "profile_data[billing_lastname]=Doe"
Example of a successful response
{
"result": "success",
"message": "Client updated successfully",
"clientid": 12345,
"billing_email": "[email protected]",
"billing_email_changed": false,
"billing_email_illegal_change_attempt": false,
"edit_master_profile": false,
"close_window": false
}
Failure response
{
"code": -1,
"message": "Invalid profile data or access denied"
}

whmcs/update_contact

Updates the client contact data.

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
profile_data[email] string Contact email
profile_data[password2] string New password
profile_data[phonenumber] string Contact phone (E164)
profile_data[firstname] string Contact first name
profile_data[lastname] string Contact last name
profile_data[permissions] string Access rights (comma-separated list)

Example Request

curl -s "https://api.hostkey.com/whmcs.php" -X POST \
--data "action=update_contact" \
--data "token=HOSTKEY_TOKEN" \
--data "profile_data[contact_id]=VALUE" \
--data "profile_data[email]=VALUE"
Example of a successful response
{
"result": "success",
"action": "update_contact",
"contactid": 101
}
Failure response
{
"code": -1,
"message": "email not specified"
}

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