auth.php¶
Authentication and authorization module: session management, login via WHMCS, LDAP, API keys and SSO (Google, GitHub, VK), 2FA verification, SMS and email, as well as customer tag management.
API Methods¶
| Method | Action | Description |
|---|---|---|
2fa_check | verify 2FA code | Verifies the provided two-factor authentication (2FA) code to complete the login process. |
2fa_resend | resend 2FA code | Triggers a new 2FA (Two-Factor Authentication) verification code to be sent to the user's registered contact method. |
billing_list | get billing list | Returns a list of billing records or active services associated with the client, potentially filtered by location. |
email_check | check email availability | Checks if a specific email address is already registered in the system to prevent duplicates. |
flip_tag | flip_tag | Toggles the state of a specific tag for a given component. |
get_log | get authorization log | Returns the authorization event log for a specified period or by token. |
get_log_details | get log details | Retrieves detailed information about a specific authentication log entry using the provided token. |
github_init | GitHub initialization | Initializes the GitHub authentication process. |
github_signin | GitHub OAuth sign-in | Authenticates a user using GitHub OAuth credentials to establish a session. |
google_signin | Google OAuth2 authentication | Authenticates a user via Google OAuth2 and establishes a session. |
info | get authentication info | Retrieves information about the current authenticated session or client status. |
ipalogin | FreeIPA authentication | Authenticates a user via FreeIPA and returns the associated roles and account information. |
login | login | Authenticates a user via email and password, initiating a session and logging the attempt. |
logout | logout | Terminates the current user session by invalidating the provided token. |
session_reset | reset session | Resets the current user session, effectively logging out or invalidating existing session tokens. |
set_tag | set tags | Mass inserts or updates tags for various components. Supports web icon assignment for presets. |
tg_verify | Telegram verification | Verifies a user via Telegram authentication process. |
vk_init | initialize vk session | Initializes a VK session or performs authentication-related setup. |
vk_signin | VK sign-in | Authenticates a user via VKontakte social media integration. |
whmcslogin | authenticate user via WHMCS or SSO | Authenticates a user using email/password or an SSO provider (Google, GitHub, VK). If multiple billing locations are found with valid credentials, it returns an async response to select the correct one. On success, returns a session token and user permissions. |
auth/2fa_check¶
Verifies the provided two-factor authentication (2FA) code to complete the login process.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: 2fa_check |
| token | ✅ | string | Authentication token used for session verification. |
| params[code] | ✅ | string | The 2FA code provided by the user. |
Example Request
Example of a successful response
auth/2fa_resend¶
Triggers a new 2FA (Two-Factor Authentication) verification code to be sent to the user's registered contact method.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | The current authentication token for the session. |
| params[user_id] | ✅ | int | The ID of the user for whom the 2FA code should be resent. |
| from | ✅ | string | Parameter from |
Example Request
Example of a successful response
auth/billing_list¶
Returns a list of billing records or active services associated with the client, potentially filtered by location.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: billing_list |
| token | ✅ | string | Authentication token for API access. |
| params[location] | ❌ | string | Filter billing records by specific location code (e.g., 'NL', 'DE'). |
Example Request
Example of a successful response
{
"result": "OK",
"action": "billing_list",
"data": [
{
"userid": 123,
"currency_code": "EUR",
"corporate": false,
"email": "[email protected]"
}
]
}
auth/email_check¶
Checks if a specific email address is already registered in the system to prevent duplicates.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: email_check |
| params[email] | ✅ | string | The email address to check for existence. |
Example Request
curl -s "https://invapi.hostkey.com/auth.php" -X POST \
--data "action=email_check" \
--data "params[email][email protected]"
Example of a successful response
{
"result": "OK",
"action": "email_check",
"data": {
"exists": true,
"email": "[email protected]"
}
}
auth/flip_tag¶
Toggles the state of a specific tag for a given component.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| params[component] | ✅ | string | Component type (table name). |
| params[component_id] | ✅ | int|array | ID or list of IDs for the component. If 0 - returns all possible tags/values. |
| params[tag] | ✅ | string | The name of the tag to flip. |
| token | ✅ | string | API authentication token |
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 | Start of the period (YYYY-MM-DD) |
| period_stop | ❌ | string | End of the period (YYYY-MM-DD) |
| user_email | ❌ | string | User email for log filtering |
Example Request
Example of a successful response
auth/get_log_details¶
Retrieves detailed information about a specific authentication log entry using the provided token.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: get_log_details |
| token | ✅ | string | Authentication token used to identify the session or user context. |
Example Request
Example of a successful response
auth/github_init¶
Initializes the GitHub authentication process.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| - | - | - | No other parameters are available |
auth/github_signin¶
Authenticates a user using GitHub OAuth credentials to establish a session.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: github_signin |
| token | ✅ | string | GitHub OAuth access token obtained from the provider. |
| state | ✅ | string | Parameter state |
| code | ✅ | string | Parameter code |
Example Request
Example of a successful response
auth/google_signin¶
Authenticates a user via Google OAuth2 and establishes a session.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: google_signin |
| token | ✅ | string | OAuth2 token received from Google provider. |
| credential | ✅ | string | Google OAuth2 credential string. |
Example Request
Example of a successful response
auth/info¶
Retrieves information about the current authenticated session or client status.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: info |
| token | ✅ | string | Authentication token for the session. |
Example Request
Example of a successful response
auth/ipalogin¶
Authenticates a user via FreeIPA and returns the associated roles and account information.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: ipalogin |
| params[user] | ✅ | string | Auth username. |
| params[password] | ✅ | string | Auth password. |
Example Request
Example of a successful response
{
"result": "OK",
"action": "ipalogin",
"data": {
"count": 0,
"email": "[email protected]",
"error": null,
"host": "ipa.example.com",
"path": "/cn=users,cn=accounts,dc=example,dc=com",
"roles": [
{
"id": 5,
"name": "admin"
}
],
"uid": 1001
}
}
auth/list_hashes¶
Returns a list of all existing authentication hashes.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: list_hashes |
| - | - | - | No other parameters are available |
Example of a successful response
auth/login¶
Authenticates a user via email and password, initiating a session and logging the attempt.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: login |
| params[email] | ✅ | string | User's email address used for authentication. |
| params[password] | ✅ | string | User's password. |
| key | ✅ | string | Parameter key |
| ttl | ✅ | string | Parameter ttl |
Example Request
Example of a successful response
{
"result": "OK",
"action": "login",
"data": {
"token": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
"user_email": "[email protected]",
"web_ip": "192.168.1.1"
}
}
auth/logout¶
Terminates the current user session by invalidating the provided token.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | The authentication token to be invalidated. |
Example Request
Example of a successful response
auth/register¶
Registers a new client or account within the system.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| - | - | - | No other parameters are available |
Example of a successful response
auth/session_reset¶
Resets the current user session, effectively logging out or invalidating existing session tokens.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| token | ✅ | string | Authentication token for the current session. |
| confirm | ✅ | string | Confirmation parameter to prevent accidental logout. |
Example Request
auth/set_tag¶
Mass inserts or updates tags for various components. Supports web icon assignment for presets.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| params[tags] | ✅ | array<object> | Array of tag objects to be processed. Each object must contain component, component_id, and tag. If the component is 'presets' and the tag name is one of [web_icon, web_icon_ru, web_icon_com], the value field must be a valid FontAwesome icon class from: fa-solid fa-server, fa-solid fa-microchip, fa-solid fa-memory, fa-solid fa-hard-drive, fa-solid fa-database, fa-solid fa-cloud, fa-solid fa-network-wired, fa-solid fa-globe, fa-solid fa-shield-halved, fa-solid fa-rocket, fa-solid fa-bolt, fa-solid fa-fire, fa-solid fa-gauge-high, fa-solid fa-cubes, fa-solid fa-layer-group, fa-solid fa-box, fa-solid fa-desktop, fa-solid fa-gamepad, fa-solid fa-snowflake, fa-solid fa-circle-nodes. |
| params[log_history] | ❌ | boolean | Whether to record the operation in the history log. |
| params[allow_update] | ❌ | boolean | If true, existing tags will be updated. If false and a duplicate tag is found, an error will be returned. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
auth/sms_check¶
Verifies the provided SMS authentication code for a specific user or session.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: sms_check |
| token | ✅ | string | Authentication token used to identify the session/user. |
| params[code] | ✅ | string | The SMS verification code provided by the user. |
Example Request
Example of a successful response
auth/sms_send¶
Sends an SMS message to a specified phone number.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| params[phone] | ✅ | string | Recipient's phone number in international format (e.g., +1234567890). |
| params[message] | ✅ | string | The text content of the SMS message. |
| token | ✅ | string | API authentication token |
Example Request
Example of a successful response
auth/sms_validate¶
Validates the provided SMS code for a specific user or session to complete authentication.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: sms_validate |
| params[code] | ✅ | string | The verification code received via SMS. |
| params[phone] | ✅ | string | The phone number associated with the authentication request. |
Example Request
Example of a successful response
auth/tg_verify¶
Verifies a user via Telegram authentication process.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: tg_verify |
| token | ✅ | string | Authentication token for the session or request. |
Example Request
Example of a successful response
auth/track_sale¶
Records a sale event in the system, typically used for synchronizing billing or tracking transaction history.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: track_sale |
| user_id | ✅ | int | Parameter user_id |
| invoice_id | ✅ | int | Parameter invoice_id |
| sum | ✅ | string | Parameter sum |
| token | ✅ | string | API authentication token |
Example Request
auth/unregister¶
Unregisters a specific tag from a component, effectively removing the association between an entity and a tag.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: unregister |
| params[component] | ✅ | string | The component to which the tag belongs (e.g., 'presets'). |
| params[component_id] | ✅ | int | The unique identifier of the component entity. |
| params[tag] | ✅ | string | The tag value to be removed. Supports wildcard '%' for pattern matching. |
Example Request
Example of a successful response
auth/validate¶
Validates the provided authentication credentials and returns a session or error status.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: validate |
| params[login] | ✅ | string | Login identifier for the user account. |
| params[password] | ✅ | string | User password. |
Example Request
Example of a successful response
auth/validate_login¶
Validates user credentials and returns authentication status or error details.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: validate_login |
| user | ✅ | string | Parameter user |
| password | ✅ | string | Parameter password |
Example Request
Example of a successful response
{
"result": "OK",
"action": "validate_login",
"data": {
"status": "success",
"user": {
"id": 123,
"email": "[email protected]",
"role": "admin"
},
"token": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
}
}
auth/vk_init¶
Initializes a VK session or performs authentication-related setup.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: vk_init |
| state | ✅ | string | Parameter state |
Example Request
auth/vk_signin¶
Authenticates a user via VKontakte social media integration.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | ✅ | string | Method identifier: vk_signin |
| token | ✅ | string | VK authentication token received from the provider. |
| state | ✅ | string | Parameter state |
| code | ✅ | string | Parameter code |
| device_id | ✅ | int | Parameter device_id |
Example Request
Example of a successful response
{
"result": "OK",
"action": "vk_signin",
"data": {
"user_id": 12345678,
"name": "John Doe",
"email": "[email protected]",
"avatar_url": "https://sun9.api.vk.com/photo-123_abc.jpg"
}
}
auth/whmcslogin¶
Authenticates a user using email/password or an SSO provider (Google, GitHub, VK). If multiple billing locations are found with valid credentials, it returns an async response to select the correct one. On success, returns a session token and user permissions.
HTTP Method: POST
Parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| sso | ❌ | string | SSO provider used for authentication. Allowed values: google, github, vk. |
| sso_hash | ❌ | string | The SSO token or hash provided by the third-party service. |
| user | ✅ | string | User's email address for traditional login. Must be a valid email format and ASCII encoded. |
| password | ✅ | string | User's password for traditional login. |
Example Request
Example of a successful response
{
"token": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0",
"role": "Customer",
"role_type": "Customer",
"whmcs_id": 123,
"whmcs_location": "US",
"whmcs_token": "",
"permissions": [
"manageproducts",
"show_invoices",
"edit_master_profile"
],
"corporate": 0,
"verified": "",
"token_expire": 1735689600,
"new": 1,
"country": "United States",
"country_code": "US",
"currency_code": "USD",
"vat": "12.34",
"VisitorID": "visitor_abc_123",
"prebill": true,
"prebill_scope": "all",
"prebill_global": true,
"tags": [
{
"tag": "role_id",
"value": 6,
"extra": "whmcs_login:221 123456"
}
],
"billing_options": {
"location": "US",
"company": "Example Company"
},
"client_data": {}
}