auth.php¶
Authentication and authorization module: session management, login via WHMCS, LDAP, API keys, and SSO (Google, GitHub, VK), 2FA verification, SMS and email verification, as well as client tag management.
API Methods¶
| Method | Action | Description |
|---|---|---|
2fa_check | 2FA code verification | Verifies the two-factor authentication code passed in the user_token parameter. |
2fa_resend | resend 2FA code | Requests a resend of the 2FA code to the bound method. |
billing_list | get billing list | Returns a list of available billing systems (WHMCS) for the current domain or user. |
email_check | email verification | Initializes or verifies the user's email address verification. |
flip_tag | toggle tag | Sets or removes a tag for a client (e.g., auto_credit). |
get_log | get authorization log | Returns the authorization event log for a specified period or by token. |
get_log_details | authorization log details | Returns detailed information about a specific log event by token. |
github_init | initialize GitHub SSO | Returns data to initialize the OAuth flow with GitHub. |
github_signin | login via GitHub | Processes the OAuth code from GitHub for login or account linking. |
google_signin | login via Google | Processes the JWT token from Google for login or account linking. |
info | token information | Returns information about the current session, access rights, servers, and billing. |
ipalogin | login via LDAP (IPA) | Authorizes an employee via LDAP (IPA) with the ability to bind to a server. |
login | login by API key | Authorizes a client or server by API key. |
logout | logout | Clears the current session token. |
session_reset | reset sessions | Resets all active user sessions by email and reset token. |
set_tag | set tag | Sets or removes a tag for a client with the ability to specify a value. |
tg_verify | Telegram verification | Binds a Telegram username to the user account. |
vk_init | initialize VK SSO | Returns data to initialize the OAuth flow with VK ID. |
vk_signin | login via VK | Processes the OAuth code from VK for login or account linking. |
whmcslogin | login via WHMCS | Main login method via WHMCS credentials (email/password) or SSO. |
auth/2fa_check¶
Verifies the two-factor authentication code passed in the user_token parameter.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: 2fa_check |
| token | ✅ | string | User session token |
| user_token | ✅ | string | Two-factor authentication code |
Example Request
auth/2fa_resend¶
Requests a resend of the 2FA code to the bound method.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: 2fa_resend |
| token | ✅ | string | User session token |
| from | ❌ | string | Request source (user_profile, resend_dialog) |
Example Request
auth/billing_list¶
Returns a list of available billing systems (WHMCS) for the current domain or user.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: billing_list |
| token | ❌ | string | Session token for authorization. If not provided, returns the list for all billings. |
Example of a successful response
auth/email_check¶
Initializes or verifies the user's email address verification.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: email_check |
| user_email | ✅ | string | Email address for verification |
| location | ✅ | string | Billing location (e.g., US, EU) |
| user_token | ❌ | string | Confirmation code sent to email (for the verification stage) |
Example Request
curl -s "https://api.hostkey.com/auth.php" -X POST \
--data "action=email_check" \
--data "[email protected]" \
--data "location=US"
Example of a successful response
{
"result": "OK",
"state": "sent",
"message": "Verification email sent to [email protected], please confirm in 15 minutes"
}
auth/flip_tag¶
Sets or removes a tag for a client (e.g., auto_credit).
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: flip_tag |
| token | ✅ | string | Session token |
| tag | ✅ | string | Tag name to toggle (only 'auto_credit' is allowed for the user role) |
Example Request
Example of a successful response
auth/get_log¶
Returns the authorization event log for a specified period or by token.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_log |
| token | ✅ | string | Session token |
| user_token | ❌ | string | User token for log search |
| period_start | ❌ | string | Period start (YYYY-MM-DD) |
| period_stop | ❌ | string | Period end (YYYY-MM-DD) |
| user_email | ❌ | string | User email for log filtering |
Example Request
Example of a successful response
auth/get_log_details¶
Returns detailed information about a specific log event by token.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_log_details |
| token | ✅ | string | Session token for authorization |
| user_token | ✅ | string | Log event token to retrieve details |
Example Request
Example of a successful response
auth/github_init¶
Returns data to initialize the OAuth flow with GitHub.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: github_init |
| - | - | - | No other parameters |
Example of a successful response
auth/github_signin¶
Processes the OAuth code from GitHub for login or account linking.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: github_signin |
| code | ✅ | string | OAuth code from GitHub |
| state | ✅ | string | State parameter (used as a session token for linking) |
Example Request
auth/google_signin¶
Processes the JWT token from Google for login or account linking.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: google_signin |
| credential | ✅ | string | JWT token from Google |
| token | ❌ | string | Current session token for linking |
Example Request
Example of a successful response
auth/info¶
Returns information about the current session, access rights, servers, and billing.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: info |
| token | ✅ | string | Session token |
Example Request
Example of a successful response
{
"result": {
"token": "abc123",
"role": "Customer",
"role_type": "Customer",
"servers": [
101,
102
],
"whmcs_id": 555,
"permissions": [
"eq_list",
"billing_list"
],
"token_expire": 1705320000,
"email": "[email protected]",
"subaccount": null,
"manage_orders": 0,
"ipsubnet_announce": 0,
"prebill": 0,
"show_products": 0,
"manage_products": 0,
"customer_id": 456,
"billing_servers": null,
"edit_master_profile": 0,
"original_tags": null,
"whmcs_location": "whmcs",
"show_invoices": 0,
"billing_options": {
"url": "https://billing.example.com",
"location": "US",
"company": "Example Inc",
"active": 1,
"allowed_payments": [
"cc",
"pp"
],
"native_endpoint": "https://billing.example.com",
"sumsub_kyc": 1,
"paypal_id": "12345"
},
"verified": 1,
"sumsub_id": "sumsub_123",
"sumsub_comment": "",
"corporate": 0,
"default_lang": "en",
"private_ranges": [],
"private_vlans": [],
"deploy_keys": {},
"client_ip": "192.168.1.1",
"timing": []
}
}
auth/login¶
Authorizes a client or server by API key.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: login |
| key | ✅ | string | API key |
| ttl | ❌ | int | Token lifetime in seconds |
| base | ❌ | string | Base URL for invapi (optional) |
Example Request
Example of a successful response
{
"result": {
"token": "api_token_123",
"role": "Customer",
"role_type": "Customer",
"whmcs_id": "12345",
"whmcs_location": "whmcs",
"servers": [
101,
102
],
"invapi": "invapi.hostkey.com",
"customer_id": "5678",
"permissions": [
"server/list",
"server/info"
],
"token_expire": 1705327200,
"new": 1,
"prebill": 0
}
}
auth/logout¶
Clears the current session token.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: logout |
| token | ✅ | string | Session token to remove |
Example Request
auth/session_reset¶
Resets all active user sessions by email and reset token.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: session_reset |
| user_email | ✅ | string | User email whose sessions need to be reset |
| reset_token | ✅ | string | Session reset token |
| confirm | ❌ | int | Action confirmation flag (1) |
Example Request
curl -s "https://api.hostkey.com/auth.php" -X POST \
--data "action=session_reset" \
--data "[email protected]" \
--data "reset_token=a1b2c3d4e5f6"
auth/set_tag¶
Sets or removes a tag for a client with the ability to specify a value.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: set_tag |
| token | ✅ | string | Session token |
| tag | ✅ | string | Tag name |
| set | ✅ | string | Tag value (required parameter according to code) |
Example Request
Example of a successful response
auth/tg_verify¶
Binds a Telegram username to the user account.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: tg_verify |
| token | ✅ | string | Session token |
| tg_username | ✅ | string | Telegram username (without @) |
Example Request
auth/vk_init¶
Returns data to initialize the OAuth flow with VK ID.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: vk_init |
| token | ❌ | string | Current session token (optional, used to bind SSO to an existing user) |
Example of a successful response
auth/vk_signin¶
Processes the OAuth code from VK for login or account linking.
HTTP Method: GET
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: vk_signin |
| code | ✅ | string | OAuth code from VK |
| state | ✅ | string | State parameter for CSRF verification |
| device_id | ✅ | string | Device ID for the OAuth request |
| token | ❌ | string | Authentication API token (optional, for linking to an existing account) |
Example Request
auth/whmcslogin¶
Main login method via WHMCS credentials (email/password) or SSO.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: whmcslogin |
| user | ❌ | string | User email (if not SSO) |
| password | ❌ | string | User password (if not SSO) |
| sso | ❌ | string | SSO type (google, github, vk) |
| sso_hash | ❌ | string | SSO session hash |
| location | ❌ | string | Billing location (e.g., NL, US). If not specified, Auto is used. |
| ttl | ❌ | integer | Token lifetime in seconds (default 86400) |
| fix_ip | ❌ | integer | Bind token to IP (1 or 0) |
| full_customer_data | ❌ | string | Include full customer data in response (1 or 0) |
| VisitorID | ❌ | string | Visitor ID for the affiliate system |
Example Request
curl -s "https://api.hostkey.com/auth.php" -X POST \
--data "action=whmcslogin" \
--data "[email protected]" \
--data "password=secret123"
Example of a successful response
{
"result": {
"token": "whmcs_token_123",
"role": "Customer",
"role_type": "Customer",
"whmcs_id": 555,
"whmcs_location": "NL",
"whmcs_token": "",
"permissions": [
"eq_list",
"invoice_list"
],
"corporate": 0,
"verified": "",
"token_expire": 1705330000,
"new": 1,
"country": "Netherlands",
"country_code": "NL",
"currency_code": "EUR",
"vat": "",
"VisitorID": "vis_123",
"prebill": 0,
"billing_options": {
"location": "NL",
"company": "HostKey NL",
"active": 1,
"allowed_payments": [
"cc",
"pp"
],
"native_endpoint": "https://nl.hostkey.com",
"sumsub_kyc": 1
},
"2fa": "sms"
}
}