Skip to content

twofa.php

Two-factor authentication module for managing and verifying security codes via TOTP, email, or SMS.

API Methods

Method Action Description
send_email_code Send a verification code to the user's email address Triggers the delivery of a 2FA verification code via email.
send_sms_code Send a verification code via SMS Triggers the delivery of a 2FA verification code via SMS.
set_method_email Set email as the 2FA method Configures the user's two-factor authentication method to use email.
set_method_none Disable 2FA method Disables two-factor authentication for the user.
set_method_sms Set SMS as the 2FA method Configures the user's two-factor authentication method to use SMS.
set_method_totp Set TOTP as the 2FA method Configures the user's two-factor authentication method to use TOTP (Authenticator apps).
verify_code Verify 2FA code Verifies the provided security code against the active 2FA method.
verify_email_code verify email code Verifies the authentication code sent via email.
verify_sms_code verify sms code Verifies the authentication code sent via SMS.
verify_totp_code verify totp code Verifies the TOTP (Time-based One-Time Password) code from an authenticator app.

twofa/send_email_code

Triggers the delivery of a 2FA verification code via email.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: send_email_code
token ✅ string Authentication token for the session.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=send_email_code" \
--data "token=HOSTKEY_TOKEN"
Success response example
{
"result": "OK",
"action": "send_email_code",
"data": {}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/send_sms_code

Triggers the delivery of a 2FA verification code via SMS.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: send_sms_code
token ✅ string Authentication token for the session.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=send_sms_code" \
--data "token=HOSTKEY_TOKEN"
Success response example
{
"result": "OK",
"action": "send_sms_code",
"data": {}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/set_method_email

Configures the user's two-factor authentication method to use email.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: set_method_email
token ✅ string Authentication token for the session.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=set_method_email" \
--data "token=HOSTKEY_TOKEN"
Success response example
{
"result": "OK",
"action": "set_method_email",
"data": {}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/set_method_none

Disables two-factor authentication for the user.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: set_method_none
token ✅ string Authentication token for the session.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=set_method_none" \
--data "token=HOSTKEY_TOKEN"
Success response example
{
"result": "OK",
"action": "set_method_none",
"data": {}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/set_method_sms

Configures the user's two-factor authentication method to use SMS.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: set_method_sms
token ✅ string Authentication token for the session.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=set_method_sms" \
--data "token=HOSTKEY_TOKEN"
Success response example
{
"result": "OK",
"action": "set_method_sms",
"data": {}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/set_method_totp

Configures the user's two-factor authentication method to use TOTP (Authenticator apps).

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: set_method_totp
token ✅ string Authentication token for the session.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=set_method_totp" \
--data "token=HOSTKEY_TOKEN"
Success response example
{
"result": "OK",
"action": "set_method_totp",
"data": {}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/verify_code

Verifies the provided security code against the active 2FA method.

HTTP method: POST

Parameters:

action ✅ string Method identifier: verify_code
token ✅ string Authentication token for the session.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=verify_code" \
--data "token=HOSTKEY_TOKEN"
Success response example
{
"result": "OK",
"action": "verify_code",
"data": {}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/verify_email_code

Verifies the authentication code sent via email.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: verify_email_code
token ✅ string Authentication token for the request.
code ✅ string The verification code received via email.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=verify_email_code" \
--data "token=VALUE" \
--data "code=VALUE"
Success response example
{
"result": "OK",
"action": "verify_email_code",
"data": {
"status": "verified"
}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/verify_sms_code

Verifies the authentication code sent via SMS.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: verify_sms_code
token ✅ string Authentication token for the request.
code ✅ string The verification code received via SMS.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=verify_sms_code" \
--data "token=VALUE" \
--data "code=VALUE"
Success response example
{
"result": "OK",
"action": "verify_sms_code",
"data": {
"status": "verified"
}
}
Error examples
{
"code": -1,
"message": "Action required"
}

twofa/verify_totp_code

Verifies the TOTP (Time-based One-Time Password) code from an authenticator app.

HTTP method: POST

Parameters:

Parameter Required Type Description
action ✅ string Method identifier: verify_totp_code
token ✅ string Authentication token for the request.
code ✅ string The TOTP code from the authenticator application.

Request example

curl -s "https://invapi.hostkey.com/twofa.php" -X POST \
--data "action=verify_totp_code" \
--data "token=VALUE" \
--data "code=VALUE"
Success response example
{
"result": "OK",
"action": "verify_totp_code",
"data": {
"status": "verified"
}
}
Error examples
{
"code": -1,
"message": "Action required"
}
question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×