Auth Endpoints

Register new accounts, authenticate users, retrieve the current user profile, and log out. These endpoints manage access tokens used to authorize all other API requests.

Registration & Login

POST /v1/auth/register

Register

Register

Create a new user account and receive an access token. The token is returned immediately so you can start making authenticated requests without a separate login call.

Request Body
Name Type Required Description
name string Required The user's display name.
email string Required A valid email address. Must be unique across all accounts.
password string Required The account password. Must be at least 8 characters.
password_confirmation string Required Must match the password field exactly.
curl -X POST https://api.proxyhat.com/v1/auth/register \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "password": "secretpassword",
    "password_confirmation": "secretpassword"
  }'
import requests

response = requests.post(
    "https://api.proxyhat.com/v1/auth/register",
    headers={
        "Content-Type": "application/json",
        "Accept": "application/json",
    },
    json={
        "name": "John Doe",
        "email": "john@example.com",
        "password": "secretpassword",
        "password_confirmation": "secretpassword",
    },
)

data = response.json()
print(data["accessToken"])
const response = await fetch("https://api.proxyhat.com/v1/auth/register", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    name: "John Doe",
    email: "john@example.com",
    password: "secretpassword",
    password_confirmation: "secretpassword",
  }),
});

const data = await response.json();
console.log(data.accessToken);
payload := strings.NewReader(`{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "secretpassword",
  "password_confirmation": "secretpassword"
}`)

req, _ := http.NewRequest("POST", "https://api.proxyhat.com/v1/auth/register", payload)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")

resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["accessToken"])
Response 201
{
  "message": "User created",
  "accessToken": "1|abc123...",
  "tokenType": "Bearer"
}
POST /v1/auth/login

Login

Login

Authenticate with email and password to receive an access token. Use this token as a Bearer token in the Authorization header for all subsequent API requests.

Request Body
Name Type Required Description
email string Required The email address associated with the account.
password string Required The account password.
curl -X POST https://api.proxyhat.com/v1/auth/login \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "email": "john@example.com",
    "password": "secretpassword"
  }'
import requests

response = requests.post(
    "https://api.proxyhat.com/v1/auth/login",
    headers={
        "Content-Type": "application/json",
        "Accept": "application/json",
    },
    json={
        "email": "john@example.com",
        "password": "secretpassword",
    },
)

data = response.json()
api_key = data["accessToken"]
print(f"Token: {api_key}")
const response = await fetch("https://api.proxyhat.com/v1/auth/login", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    email: "john@example.com",
    password: "secretpassword",
  }),
});

const data = await response.json();
console.log(`Token: ${data.accessToken}`);
payload := strings.NewReader(`{
  "email": "john@example.com",
  "password": "secretpassword"
}`)

req, _ := http.NewRequest("POST", "https://api.proxyhat.com/v1/auth/login", payload)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")

resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println("Token:", result["accessToken"])
Response 200
{
  "accessToken": "2|xyz789...",
  "tokenType": "Bearer"
}

Current User

GET /v1/auth/user Requires Auth

Get Current User

Get Current User

Retrieve the authenticated user's profile, including their UUID, name, email, and current traffic balance breakdown (regular, subscription, and total).

curl https://api.proxyhat.com/v1/auth/user \
  -H "Authorization: Bearer __API_KEY__" \
  -H "Accept: application/json"
import requests

response = requests.get(
    "https://api.proxyhat.com/v1/auth/user",
    headers={
        "Authorization": "Bearer __API_KEY__",
        "Accept": "application/json",
    },
)

user = response.json()
print(f"{user[\"name\"]} — {user[\"traffic\"][\"total_human\"]}")
const response = await fetch("https://api.proxyhat.com/v1/auth/user", {
  headers: {
    "Authorization": "Bearer __API_KEY__",
    "Accept": "application/json",
  },
});

const user = await response.json();
console.log(`${user.name} — ${user.traffic.total_human}`);
req, _ := http.NewRequest("GET", "https://api.proxyhat.com/v1/auth/user", nil)
req.Header.Set("Authorization", "Bearer __API_KEY__")
req.Header.Set("Accept", "application/json")

resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()

var user map[string]interface{}
json.NewDecoder(resp.Body).Decode(&user)
fmt.Println(user["name"], user["traffic"])
Response 200
{
  "uuid": "550e8400-e29b-41d4-a716-446655440000",
  "name": "John Doe",
  "email": "john@example.com",
  "traffic": {
    "subscription": null,
    "regular_bytes": 10737418240,
    "regular_human": "10.00 GB",
    "subscription_bytes": 0,
    "subscription_human": "0 B",
    "total_bytes": 10737418240,
    "total_human": "10.00 GB"
  }
}

Session Management

POST /v1/auth/logout Requires Auth

Logout

Logout

Revoke the current access token. After calling this endpoint, the token used to authenticate the request will no longer be valid for future requests.

curl -X POST https://api.proxyhat.com/v1/auth/logout \
  -H "Authorization: Bearer __API_KEY__" \
  -H "Accept: application/json"
import requests

response = requests.post(
    "https://api.proxyhat.com/v1/auth/logout",
    headers={
        "Authorization": "Bearer __API_KEY__",
        "Accept": "application/json",
    },
)

print(response.json()["message"])
const response = await fetch("https://api.proxyhat.com/v1/auth/logout", {
  method: "POST",
  headers: {
    "Authorization": "Bearer __API_KEY__",
    "Accept": "application/json",
  },
});

const data = await response.json();
console.log(data.message);
req, _ := http.NewRequest("POST", "https://api.proxyhat.com/v1/auth/logout", nil)
req.Header.Set("Authorization", "Bearer __API_KEY__")
req.Header.Set("Accept", "application/json")

resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["message"])
Response 200
{
  "message": "Logged out"
}