BetterAuth API Documentation

Complete reference for the BetterAuth licensing platform API. This RESTful API enables you to integrate authentication, license validation, user management, and more into your applications.

Base URL: All v2 API endpoints are prefixed with https://betterauth.online/api/v2/
SDKs & Libraries: Code examples for every endpoint are provided in 10 languages below — just click the language tab to switch.

Introduction

BetterAuth is a self-hosted software licensing platform that provides HWID-locked authentication, license key management, encrypted file delivery, user variables, webhooks, and real-time chat. The API follows REST conventions and returns JSON for all responses.

The typical authentication flow is:

  1. Call POST /auth/init with your app_secret to create a session.
  2. Use the returned session_id for all subsequent requests.
  3. Call POST /auth/login, POST /auth/register, or POST /auth/license to authenticate a user.
  4. Access protected resources using the authenticated session.

Base URL

https://betterauth.online/api/v2/

All endpoint paths in this documentation are relative to this base URL.

Authentication

Most endpoints require authentication via a session ID. Sessions are created by calling POST /auth/init with your application secret. The session ID can be passed in three ways:

MethodExample
Request body parameter{"session_id": "..."}
X-Session-Id headerX-Session-Id: ...
Query parameter?session_id=...

Common Headers

HeaderDescriptionAlternative
X-App-SecretYour application secret keyapp_secret parameter
X-Session-IdActive session identifiersession_id parameter
X-HWIDHardware ID of the clienthwid parameter
Content-Typeapplication/json for POST requests

Response Format

All API responses follow a consistent JSON structure:

{
    "success": true,
    "message": "Operation completed successfully",
    "data": { ... },
    "timestamp": 1700000000
}

Error Codes

CodeNameDescription
400BAD_REQUESTMissing or invalid parameters
401UNAUTHORIZEDInvalid or expired session
403FORBIDDENInsufficient permissions or blacklisted
404NOT_FOUNDResource not found
405METHOD_NOT_ALLOWEDWrong HTTP method
429RATE_LIMITEDToo many requests
500INTERNAL_ERRORServer-side error

Rate Limiting

API requests are rate-limited per IP and per application. If you exceed the limit, the API returns a 429 status with a message indicating when you can retry. Rate limit headers are included in responses:

HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRemaining requests in current window
X-RateLimit-ResetUnix timestamp when the window resets

POST /auth/init

Initialize a new session with the application. This is the first call you must make before any other API operation. Returns a session_id that is required for all subsequent requests.

Parameters

NameTypeRequiredDescription
app_secretstringRequiredYour application's secret key
versionstringOptionalClient version string
hwidstringOptionalHardware ID of the client machine

Response

{
    "success": true,
    "message": "Session initialized",
    "data": {
        "session_id": "sess_abc123...",
        "enckey": "encryption_key",
        "app": {
            "name": "My Application",
            "version": "2.0"
        }
    },
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/auth/init \
  -H "Content-Type: application/json" \
  -d '{
    "app_secret": "your_app_secret_here",
    "version": "1.0.0",
    "hwid": "user_hwid_here"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/auth/init",
    json={
        "app_secret": "your_app_secret_here",
        "version": "1.0.0",
        "hwid": "user_hwid_here"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/auth/init", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        app_secret: "your_app_secret_here",
        version: "1.0.0",
        hwid: "user_hwid_here"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    app_secret = "your_app_secret_here",
    version = "1.0.0",
    hwid = "user_hwid_here"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/auth/init", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"app_secret\":\"your_app_secret_here\","
                   "\"version\":\"1.0.0\",\"hwid\":\"user_hwid_here\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/auth/init");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/auth/init");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"app_secret\":\"your_app_secret_here\","
            + "\"version\":\"1.0.0\",\"hwid\":\"user_hwid_here\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "app_secret": "your_app_secret_here",
    "version":    "1.0.0",
    "hwid":       "user_hwid_here",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/auth/init",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/auth/init");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "app_secret" => "your_app_secret_here",
        "version"    => "1.0.0",
        "hwid"       => "user_hwid_here"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/auth/init")
    .json(&serde_json::json!({
        "app_secret": "your_app_secret_here",
        "version": "1.0.0",
        "hwid": "user_hwid_here"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/auth/init")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    app_secret: "your_app_secret_here",
    version: "1.0.0",
    hwid: "user_hwid_here"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

POST /auth/login

Authenticate a user with username and password. Requires an active session (from /auth/init). Optionally pass hwid for HWID-locked sessions.

Parameters

NameTypeRequiredDescription
session_idstringRequiredSession ID from /auth/init
usernamestringRequiredUser's username
passwordstringRequiredUser's password
hwidstringOptionalHardware ID for HWID locking

Response

{
    "success": true,
    "message": "Logged in successfully",
    "data": {
        "user": {
            "username": "user123",
            "email": "[email protected]",
            "role": "user"
        },
        "subscription": {
            "plan": "premium",
            "expires": 1735689600
        }
    },
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "username": "user123",
    "password": "securepassword",
    "hwid": "user_hwid_here"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/auth/login",
    json={
        "session_id": "your_session_id",
        "username": "user123",
        "password": "securepassword",
        "hwid": "user_hwid_here"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/auth/login", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        username: "user123",
        password: "securepassword",
        hwid: "user_hwid_here"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    username = "user123",
    password = "securepassword",
    hwid = "user_hwid_here"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/auth/login", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"username\":\"user123\","
                   "\"password\":\"securepassword\","
                   "\"hwid\":\"user_hwid_here\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/auth/login");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/auth/login");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"username\":\"user123\","
            + "\"password\":\"securepassword\","
            + "\"hwid\":\"user_hwid_here\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "username":   "user123",
    "password":   "securepassword",
    "hwid":       "user_hwid_here",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/auth/login",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/auth/login");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "username"   => "user123",
        "password"   => "securepassword",
        "hwid"       => "user_hwid_here"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/auth/login")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "username": "user123",
        "password": "securepassword",
        "hwid": "user_hwid_here"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/auth/login")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    username: "user123",
    password: "securepassword",
    hwid: "user_hwid_here"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

POST /auth/register

Register a new user account. Optionally associate with a license key and set email. Requires an active session.

Parameters

NameTypeRequiredDescription
session_idstringRequiredSession ID from /auth/init
usernamestringRequiredDesired username
passwordstringRequiredDesired password
keystringOptionalLicense key to associate
emailstringOptionalEmail address
hwidstringOptionalHardware ID

Response

{
    "success": true,
    "message": "Account created successfully",
    "data": {
        "user": {
            "username": "newuser",
            "email": "[email protected]"
        },
        "subscription": {
            "plan": "basic",
            "expires": 1735689600
        }
    },
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "username": "newuser",
    "password": "securepassword",
    "key": "XXXX-XXXX-XXXX-XXXX",
    "email": "[email protected]",
    "hwid": "user_hwid_here"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/auth/register",
    json={
        "session_id": "your_session_id",
        "username": "newuser",
        "password": "securepassword",
        "key": "XXXX-XXXX-XXXX-XXXX",
        "email": "[email protected]",
        "hwid": "user_hwid_here"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/auth/register", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        username: "newuser",
        password: "securepassword",
        key: "XXXX-XXXX-XXXX-XXXX",
        email: "[email protected]",
        hwid: "user_hwid_here"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    username = "newuser",
    password = "securepassword",
    key = "XXXX-XXXX-XXXX-XXXX",
    email = "[email protected]",
    hwid = "user_hwid_here"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/auth/register", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"username\":\"newuser\","
                   "\"password\":\"securepassword\","
                   "\"key\":\"XXXX-XXXX-XXXX-XXXX\","
                   "\"email\":\"[email protected]\","
                   "\"hwid\":\"user_hwid_here\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/auth/register");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/auth/register");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"username\":\"newuser\","
            + "\"password\":\"securepassword\","
            + "\"key\":\"XXXX-XXXX-XXXX-XXXX\","
            + "\"email\":\"[email protected]\","
            + "\"hwid\":\"user_hwid_here\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "username":   "newuser",
    "password":   "securepassword",
    "key":        "XXXX-XXXX-XXXX-XXXX",
    "email":      "[email protected]",
    "hwid":       "user_hwid_here",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/auth/register",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/auth/register");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "username"   => "newuser",
        "password"   => "securepassword",
        "key"        => "XXXX-XXXX-XXXX-XXXX",
        "email"      => "[email protected]",
        "hwid"       => "user_hwid_here"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/auth/register")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "username": "newuser",
        "password": "securepassword",
        "key": "XXXX-XXXX-XXXX-XXXX",
        "email": "[email protected]",
        "hwid": "user_hwid_here"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/auth/register")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    username: "newuser",
    password: "securepassword",
    key: "XXXX-XXXX-XXXX-XXXX",
    email: "[email protected]",
    hwid: "user_hwid_here"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

POST /auth/license

Authenticate using a license key only (no username/password). Useful for headless or automated scenarios. Optionally pass hwid for HWID verification.

Parameters

NameTypeRequiredDescription
session_idstringRequiredSession ID from /auth/init
keystringRequiredLicense key
hwidstringOptionalHardware ID for HWID locking

Response

{
    "success": true,
    "message": "License authenticated",
    "data": {
        "subscription": {
            "key": "XXXX-XXXX-XXXX-XXXX",
            "plan": "premium",
            "expires": 1735689600,
            "status": "active"
        }
    },
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/auth/license \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "key": "XXXX-XXXX-XXXX-XXXX",
    "hwid": "user_hwid_here"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/auth/license",
    json={
        "session_id": "your_session_id",
        "key": "XXXX-XXXX-XXXX-XXXX",
        "hwid": "user_hwid_here"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/auth/license", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        key: "XXXX-XXXX-XXXX-XXXX",
        hwid: "user_hwid_here"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    key = "XXXX-XXXX-XXXX-XXXX",
    hwid = "user_hwid_here"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/auth/license", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"key\":\"XXXX-XXXX-XXXX-XXXX\","
                   "\"hwid\":\"user_hwid_here\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/auth/license");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/auth/license");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"key\":\"XXXX-XXXX-XXXX-XXXX\","
            + "\"hwid\":\"user_hwid_here\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "key":        "XXXX-XXXX-XXXX-XXXX",
    "hwid":       "user_hwid_here",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/auth/license",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/auth/license");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "key"        => "XXXX-XXXX-XXXX-XXXX",
        "hwid"       => "user_hwid_here"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/auth/license")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "key": "XXXX-XXXX-XXXX-XXXX",
        "hwid": "user_hwid_here"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/auth/license")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    key: "XXXX-XXXX-XXXX-XXXX",
    hwid: "user_hwid_here"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

POST /auth/logout

Destroy an active session. After calling this endpoint, the session_id is no longer valid.

Parameters

NameTypeRequiredDescription
session_idstringRequiredSession ID to destroy

Response

{
    "success": true,
    "message": "Logged out successfully",
    "data": null,
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/auth/logout \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/auth/logout",
    json={
        "session_id": "your_session_id"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/auth/logout", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new { session_id = "your_session_id" };
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/auth/logout", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/auth/logout");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/auth/logout");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/auth/logout",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/auth/logout");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/auth/logout")
    .json(&serde_json::json!({
        "session_id": "your_session_id"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/auth/logout")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = { session_id: "your_session_id" }.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

GET /auth/check

Verify whether a session is still valid. Useful for checking if a user needs to re-authenticate.

Parameters

NameTypeRequiredDescription
session_idstringRequiredSession ID to verify

Response

{
    "success": true,
    "message": "Session is valid",
    "data": {
        "authenticated": true,
        "expires": 1700086400
    },
    "timestamp": 1700000000
}
GET request example: GET /api/v2/auth/check?session_id=your_session_id or use the X-Session-Id header.

GET /user

Get the authenticated user's profile information. Requires a valid, authenticated session.

Parameters

NameTypeRequiredDescription
session_idstringRequiredAuthenticated session ID

Response

{
    "success": true,
    "message": "User profile retrieved",
    "data": {
        "username": "user123",
        "email": "[email protected]",
        "role": "user",
        "created_at": 1690000000
    },
    "timestamp": 1700000000
}
GET request example: GET /api/v2/user?session_id=your_session_id or use the X-Session-Id header.

GET /user/subscriptions

List all subscriptions for the authenticated user. Returns an array of subscription objects with plan details and expiration dates.

Parameters

NameTypeRequiredDescription
session_idstringRequiredAuthenticated session ID

Response

{
    "success": true,
    "message": "Subscriptions retrieved",
    "data": [
        {
            "plan": "premium",
            "status": "active",
            "expires": 1735689600,
            "key": "XXXX-XXXX-XXXX-XXXX"
        }
    ],
    "timestamp": 1700000000
}
GET request example: GET /api/v2/user/subscriptions?session_id=your_session_id or use the X-Session-Id header.

GET /license/{key}

Retrieve information about a specific license key. Requires both the application secret and an authenticated session.

Parameters

NameTypeRequiredDescription
keystringRequiredLicense key (in URL path)
app_secretstringRequiredApplication secret (header or param)
session_idstringRequiredAuthenticated session ID

Response

{
    "success": true,
    "message": "License info retrieved",
    "data": {
        "key": "XXXX-XXXX-XXXX-XXXX",
        "status": "active",
        "plan": "premium",
        "expires": 1735689600,
        "created_at": 1690000000,
        "hwid": "locked_hwid_or_null"
    },
    "timestamp": 1700000000
}
GET request example: GET /api/v2/license/XXXX-XXXX-XXXX-XXXX?session_id=your_session_id with X-App-Secret header.

POST /license/validate

Validate a license key and check its status. Returns whether the license is valid, active, and not expired.

Parameters

NameTypeRequiredDescription
session_idstringRequiredAuthenticated session ID
keystringRequiredLicense key to validate

Response

{
    "success": true,
    "message": "License is valid",
    "data": {
        "valid": true,
        "status": "active",
        "expires": 1735689600
    },
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/license/validate \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "key": "XXXX-XXXX-XXXX-XXXX"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/license/validate",
    json={
        "session_id": "your_session_id",
        "key": "XXXX-XXXX-XXXX-XXXX"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/license/validate", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        key: "XXXX-XXXX-XXXX-XXXX"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    key = "XXXX-XXXX-XXXX-XXXX"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/license/validate", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"key\":\"XXXX-XXXX-XXXX-XXXX\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/license/validate");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/license/validate");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"key\":\"XXXX-XXXX-XXXX-XXXX\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "key":        "XXXX-XXXX-XXXX-XXXX",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/license/validate",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/license/validate");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "key"        => "XXXX-XXXX-XXXX-XXXX"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/license/validate")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "key": "XXXX-XXXX-XXXX-XXXX"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/license/validate")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    key: "XXXX-XXXX-XXXX-XXXX"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

GET /variable/{name}

Retrieve a global or user-specific variable. Global variables are set by the application owner. User variables are per-user. Requires an authenticated session.

Parameters

NameTypeRequiredDescription
namestringRequiredVariable name (in URL path)
session_idstringRequiredAuthenticated session ID

Response

{
    "success": true,
    "message": "Variable retrieved",
    "data": {
        "name": "config_url",
        "value": "https://example.com/config.json",
        "scope": "global"
    },
    "timestamp": 1700000000
}
GET request example: GET /api/v2/variable/config_url?session_id=your_session_id

POST /variable/{name}

Set or update a user-specific variable. The value is stored per-user and can be retrieved later with GET /variable/{name}.

Parameters

NameTypeRequiredDescription
namestringRequiredVariable name (in URL path)
session_idstringRequiredAuthenticated session ID
datastringRequiredVariable value to store

Response

{
    "success": true,
    "message": "Variable set successfully",
    "data": {
        "name": "my_var",
        "value": "some_value"
    },
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/variable/my_var \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "data": "some_value"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/variable/my_var",
    json={
        "session_id": "your_session_id",
        "data": "some_value"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/variable/my_var", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        data: "some_value"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    data = "some_value"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/variable/my_var", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"data\":\"some_value\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/variable/my_var");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/variable/my_var");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"data\":\"some_value\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "data":       "some_value",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/variable/my_var",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/variable/my_var");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "data"       => "some_value"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/variable/my_var")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "data": "some_value"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/variable/my_var")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    data: "some_value"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

GET /file/{id}

Download an encrypted file associated with the application. The file must be accessible to the user's subscription tier. Returns the file contents as a binary download.

Parameters

NameTypeRequiredDescription
idstringRequiredFile ID (in URL path)
session_idstringRequiredAuthenticated session ID

Response

Returns the file as a binary download with Content-Disposition: attachment header. Check Content-Type for the file's MIME type.
Important: The file may be encrypted. Use the enckey from your session to decrypt it client-side.
GET request example: GET /api/v2/file/file_abc123?session_id=your_session_id

POST /log

Submit a log entry to the application's log system. Useful for tracking client-side events, errors, or user activity.

Parameters

NameTypeRequiredDescription
session_idstringRequiredAuthenticated session ID
messagestringRequiredLog message content

Response

{
    "success": true,
    "message": "Log recorded",
    "data": null,
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/log \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "message": "User logged in from 192.168.1.1"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/log",
    json={
        "session_id": "your_session_id",
        "message": "User logged in from 192.168.1.1"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/log", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        message: "User logged in from 192.168.1.1"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    message = "User logged in from 192.168.1.1"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/log", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"message\":\"User logged in from 192.168.1.1\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/log");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/log");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"message\":\"User logged in from 192.168.1.1\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "message":    "User logged in from 192.168.1.1",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/log",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/log");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "message"    => "User logged in from 192.168.1.1"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/log")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "message": "User logged in from 192.168.1.1"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/log")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    message: "User logged in from 192.168.1.1"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

POST /webhook/{id}

Execute a pre-configured webhook. The webhook ID is set in the dashboard. Pass custom parameters to be included in the webhook payload.

Parameters

NameTypeRequiredDescription
idstringRequiredWebhook ID (in URL path)
session_idstringRequiredAuthenticated session ID
paramsobjectOptionalCustom parameters to pass

Response

{
    "success": true,
    "message": "Webhook executed",
    "data": {
        "webhook_id": "wh_abc123",
        "response_code": 200
    },
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/webhook/wh_abc123 \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "params": {
      "custom_field": "value"
    }
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/webhook/wh_abc123",
    json={
        "session_id": "your_session_id",
        "params": {
            "custom_field": "value"
        }
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/webhook/wh_abc123", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        params: {
            custom_field: "value"
        }
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    @params = new { custom_field = "value" }
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/webhook/wh_abc123", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"params\":{\"custom_field\":\"value\"}}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/webhook/wh_abc123");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/webhook/wh_abc123");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"params\":{\"custom_field\":\"value\"}}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "params": map[string]interface{}{
        "custom_field": "value",
    },
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/webhook/wh_abc123",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/webhook/wh_abc123");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "params"     => ["custom_field" => "value"]
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/webhook/wh_abc123")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "params": { "custom_field": "value" }
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/webhook/wh_abc123")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    params: { custom_field: "value" }
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

GET /chat/{channel}

Retrieve recent chat messages from a channel. Messages are returned in chronological order with author info and timestamps.

Parameters

NameTypeRequiredDescription
channelstringRequiredChannel name (in URL path)
session_idstringRequiredAuthenticated session ID

Response

{
    "success": true,
    "message": "Messages retrieved",
    "data": [
        {
            "author": "user123",
            "message": "Hello!",
            "timestamp": 1700000000
        }
    ],
    "timestamp": 1700000000
}
GET request example: GET /api/v2/chat/general?session_id=your_session_id

POST /chat/{channel}

Send a message to a chat channel. The message will be visible to all users in the channel.

Parameters

NameTypeRequiredDescription
channelstringRequiredChannel name (in URL path)
session_idstringRequiredAuthenticated session ID
messagestringRequiredMessage content

Response

{
    "success": true,
    "message": "Message sent",
    "data": null,
    "timestamp": 1700000000
}
curl -X POST https://betterauth.online/api/v2/chat/general \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "your_session_id",
    "message": "Hello everyone!"
  }'
import requests

response = requests.post(
    "https://betterauth.online/api/v2/chat/general",
    json={
        "session_id": "your_session_id",
        "message": "Hello everyone!"
    }
)
print(response.json())
const response = await fetch("https://betterauth.online/api/v2/chat/general", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        session_id: "your_session_id",
        message: "Hello everyone!"
    })
});
const data = await response.json();
console.log(data);
using var client = new HttpClient();
var payload = new {
    session_id = "your_session_id",
    message = "Hello everyone!"
};
var response = await client.PostAsJsonAsync(
    "https://betterauth.online/api/v2/chat/general", payload
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
// Requires libcurl
CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");

const char *json = "{\"session_id\":\"your_session_id\","
                   "\"message\":\"Hello everyone!\"}";

curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/chat/general");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
URL url = new URL("https://betterauth.online/api/v2/chat/general");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);

String json = "{\"session_id\":\"your_session_id\","
            + "\"message\":\"Hello everyone!\"}";

try (OutputStream os = conn.getOutputStream()) {
    byte[] input = json.getBytes(StandardCharsets.UTF_8);
    os.write(input, 0, input.length);
}

BufferedReader br = new BufferedReader(
    new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
    System.out.println(line);
}
payload := map[string]interface{}{
    "session_id": "your_session_id",
    "message":    "Hello everyone!",
}
body, _ := json.Marshal(payload)

resp, err := http.Post(
    "https://betterauth.online/api/v2/chat/general",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
$ch = curl_init("https://betterauth.online/api/v2/chat/general");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode([
        "session_id" => "your_session_id",
        "message"    => "Hello everyone!"
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
let client = reqwest::Client::new();
let res = client
    .post("https://betterauth.online/api/v2/chat/general")
    .json(&serde_json::json!({
        "session_id": "your_session_id",
        "message": "Hello everyone!"
    }))
    .send()
    .await?;
let body: serde_json::Value = res.json().await?;
println!("{:?}", body);
require "net/http"
require "json"

uri = URI("https://betterauth.online/api/v2/chat/general")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.body = {
    session_id: "your_session_id",
    message: "Hello everyone!"
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
    http.request(request)
}
puts JSON.parse(response.body)

GET /blacklist/check

Check if an IP address or Hardware ID is on the application's blacklist. Pass at least one of ip or hwid.

Parameters

NameTypeRequiredDescription
ipstringOptional*IP address to check
hwidstringOptional*Hardware ID to check

* At least one of ip or hwid must be provided.

Response

{
    "success": true,
    "message": "Not blacklisted",
    "data": {
        "blacklisted": false
    },
    "timestamp": 1700000000
}
GET request example: GET /api/v2/blacklist/check?ip=192.168.1.1&hwid=user_hwid

GET /app/status

Get the current status of the application, including whether it's online/offline and the current version.

Parameters

NameTypeRequiredDescription
app_secretstringRequiredApplication secret (header or param)

Response

{
    "success": true,
    "message": "Application online",
    "data": {
        "name": "My Application",
        "status": "online",
        "version": "2.0.0",
        "users_online": 42
    },
    "timestamp": 1700000000
}
GET request example: GET /api/v2/app/status with X-App-Secret header.

GET /ping

Health check endpoint. Returns a simple pong response. No authentication required. Use this to verify the API is reachable.

Response

{
    "success": true,
    "message": "pong",
    "data": null,
    "timestamp": 1700000000
}
No authentication required. Simply call GET https://betterauth.online/api/v2/ping.

v1 API (Legacy)

The v1 API is the legacy version and is maintained for backward compatibility. New integrations should use v2. The v1 API uses a slightly different request/response format.

https://betterauth.online/api/v1/

Available Endpoints

EndpointMethodDescription
/initPOSTInitialize session (same as v2 /auth/init)
/loginPOSTLogin with credentials
/registerPOSTRegister new user
/licensePOSTLogin with license key
/userGETGet user profile
/subscriptionsGETList user subscriptions
/varGET/POSTGet or set variables
/fileGETDownload file
/logPOSTSubmit log entry
/pingGETHealth check
/banGETCheck ban status
/resetPOSTReset HWID or password
Deprecation Notice: The v1 API may receive limited updates. We recommend migrating to v2 for all new integrations and eventually updating existing ones.

BetterAuth API Documentation — © 2026 BetterAuth. All rights reserved.

Questions? Visit betterauth.online

BetterAuth Support Online

Or email us: [email protected]
Start a conversation

We typically reply within minutes during business hours. Otherwise, we'll get back to you within 24 hours.