Overview

SwiftAuth is a high-performance authentication and licensing platform. The API is split into two parts: the Dashboard API (for managing your apps) and the Client API (for your application to authenticate users).

Base URL: https://swiftauth.net/api

All requests and responses use JSON. Include Content-Type: application/json in all requests with a body.

Quickstart

Get up and running in under 5 minutes:

1. Create an account

Sign up at swiftauth.net/dashboard and verify your email.

2. Create an application

From the dashboard, create a new app. Copy your App ID and App Secret.

3. Authenticate users

Call /api/client/init then /api/client/login or /api/client/license.

Rate Limits

All endpoints are rate limited. Client API endpoints share a global limit, with stricter limits on sensitive operations.

EndpointLimitWindow
/api/auth/login5 requests15 minutes per IP+username
/api/auth/register3 requests1 hour per IP
/api/auth/forgot-password2 requests24 hours per IP
/api/client/* (general)60 requests1 minute per IP
/api/client/login, /register, /license20 requests1 minute per IP
/api/client/init5 requests5 minutes per IP
/api/client/check10 requests1 minute per IP+appId

When rate limited, the API returns 429 Too Many Requests with a descriptive message.

Authentication

The Dashboard API uses JWT bearer tokens. After logging in via /api/auth/login, include the token in subsequent requests:

Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

The Client API uses session tokens obtained from /api/client/init. Pass the session token in the request body. Requests that mutate state also require a nonce via the X-Nonce header.

Error Handling

Errors return a consistent JSON structure:

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Username and password are required"
  }
}

Common HTTP status codes: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 429 Rate Limited.

Auth

POST /api/auth/register Create account
ParameterTypeDescription
emailstringrequired Account email
usernamestringrequired Account username
passwordstringrequired Account password (8+ chars, uppercase, lowercase, number)

Returns a generic response regardless of success/failure to prevent account enumeration. If email service is configured, sends a verification email. Rate limited to 3 per IP per hour.

// Response (202 Accepted)
{
  "success": true,
  "data": {
    "message": "If this email is not already registered, you will receive a verification link shortly.",
    "requireVerify": true
  }
}
Email domains: Only common providers are allowed (Gmail, Outlook, Yahoo, ProtonMail, iCloud, etc.). Disposable emails are rejected.
POST /api/auth/login Get JWT token
ParameterTypeDescription
usernamestringrequired
passwordstringrequired
twoFactorCodestringoptional TOTP code if 2FA is enabled

Rate limited to 5 attempts per IP+username per 15 minutes. If 2FA is enabled and no code is provided, returns requires2FA: true. If email is unverified, returns requireVerify: true.

// Success Response
{
  "data": {
    "token": "eyJhbGciOi...",
    "account": { "id": "...", "username": "...", "email": "...",
                 "role": "user", "twoFactorEnabled": false }
  }
}

// 2FA Required Response
{ "success": false, "requires2FA": true, "message": "Two-factor authentication code required" }

// Unverified Email Response (403)
{ "success": false, "requireVerify": true, "message": "Please verify your email address before logging in." }
GET /api/auth/me Current account info

Returns the authenticated account details including plan info, API usage, and application count. Requires Bearer token.

// Response
{
  "data": {
    "id": "...", "email": "[email protected]", "username": "john",
    "role": "user", "apiKey": "sa_...xyz1",
    "emailVerified": true, "twoFactorEnabled": false,
    "lastLoginAt": "2025-01-15T10:30:00Z",
    "createdAt": "2025-01-01T00:00:00Z",
    "applicationCount": 2,
    "plan": {
      "name": "free", "displayName": "Free", "priceMonth": 0,
      "limits": { "maxApps": 1, "maxUsersPerApp": 15, "maxApiCallsMonth": 2500, "webSocketAccess": false }
    },
    "apiCallsUsed": 150,
    "apiCallsResetAt": "2025-02-01T00:00:00Z"
  }
}
POST /api/auth/change-password Change password

Requires Bearer token. Accepts either the current password or a 2FA code (if 2FA is enabled) for verification.

ParameterTypeDescription
currentPasswordstringrequired* Current password
twoFactorCodestringoptional TOTP code (alternative to currentPassword if 2FA is enabled)
newPasswordstringrequired Must meet password complexity: 8+ chars, uppercase, lowercase, number
// Response
{ "success": true, "data": { "message": "Password changed" } }
POST /api/auth/verify-email Verify email address

Verifies the account email using the token sent during registration. On success, automatically signs in the user and returns a JWT.

ParameterTypeDescription
tokenstringrequired Verification token from email
// Response
{
  "data": {
    "message": "Email verified successfully",
    "account": { "id": "...", "email": "...", "username": "...", "role": "user" },
    "token": "eyJhbGciOi..."
  }
}
POST /api/auth/resend-verification Resend verification email

Generates a new verification token and sends a verification email. Returns a generic message regardless of whether the account exists (prevents enumeration).

ParameterTypeDescription
emailstringrequired Account email
// Response
{ "success": true, "data": { "message": "If an account with that email exists, a verification email has been sent." } }
POST /api/auth/forgot-password Request password reset

Sends a password reset email. Returns a generic response regardless of whether the account exists. Rate limited to 2 requests per IP per 24 hours.

ParameterTypeDescription
emailstringrequired Account email
// Response
{ "success": true, "data": { "message": "If an account with that email exists, a password reset link has been sent." } }
POST /api/auth/reset-password Reset password with token

Resets the account password using a token from the password reset email. Token expires after 1 hour and is single-use.

ParameterTypeDescription
tokenstringrequired Reset token from email
newPasswordstringrequired Must meet password complexity requirements
// Response
{ "success": true, "data": { "message": "Password has been reset successfully. You can now log in." } }
POST /api/auth/reset-password-2fa Reset password with 2FA

Reset password using username + TOTP code for users who have 2FA enabled but lost email access. Rate limited to 2 requests per IP per 24 hours.

ParameterTypeDescription
usernamestringrequired Username or email
twoFactorCodestringrequired Current TOTP code
newPasswordstringrequired New password
POST /api/auth/logout Revoke JWT token

Revokes the current JWT token by adding it to a blocklist. The token will be rejected on subsequent requests until it naturally expires. Requires Bearer token.

// Response
{ "success": true, "data": { "message": "Logged out" } }
POST /api/auth/regenerate-api-key Regenerate API key

Generates a new API key for the authenticated account. The old key is immediately invalidated. Requires Bearer token.

// Response
{ "data": { "apiKey": "sa_new_key_here..." } }

Two-Factor Authentication (2FA)

POST /api/auth/2fa/setup Start 2FA setup

Generates a TOTP secret and returns it along with the otpauth URL for QR code scanning. The secret is stored but 2FA is not enabled until verified with /2fa/enable. Requires Bearer token.

// Response
{
  "data": {
    "secret": "JBSWY3DPEHPK3PXP",
    "otpauth": "otpauth://totp/SwiftAuth:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=SwiftAuth"
  }
}
POST /api/auth/2fa/enable Enable 2FA

Verifies the TOTP code and enables 2FA on the account. Must call /2fa/setup first. Requires Bearer token.

ParameterTypeDescription
codestringrequired 6-digit TOTP code from authenticator app
// Response
{ "success": true, "data": { "message": "2FA enabled successfully" } }
POST /api/auth/2fa/disable Disable 2FA

Disables 2FA. Requires both the current password and a valid TOTP code for security. Requires Bearer token.

ParameterTypeDescription
passwordstringrequired Current account password
codestringrequired Current 6-digit TOTP code
// Response
{ "success": true, "data": { "message": "2FA disabled" } }
GET /api/auth/plans List available plans

Returns all available subscription plans with pricing and feature limits. No authentication required.

// Response
{
  "data": [
    {
      "name": "free",
      "displayName": "Free",
      "priceMonth": 0,
      "limits": {
        "maxApps": 1,
        "maxUsersPerApp": 15,
        "maxApiCallsMonth": 2500,
        "webSocketAccess": false,
        "features": ["users", "licenses", "devices", "logs"]
      }
    },
    { "name": "pro", "displayName": "Pro", "priceMonth": 4.99, ... },
    { "name": "business", "displayName": "Business", "priceMonth": 9.99, ... }
  ]
}
POST /api/auth/upgrade-plan Change subscription plan
ParameterTypeDescription
planstringrequired Plan name: free, pro, or business
Note: Only downgrading to free is currently available via self-service. Paid plan upgrades (pro, business) must be assigned by an administrator.

Applications

All application endpoints require Bearer token authentication.

GET /api/apps List your applications

Returns all applications owned by the authenticated account with resource counts.

// Response
{
  "data": [{
    "id": "...", "name": "MyApp", "secret": "***abc123",
    "enabled": true, "version": "1.0.0", "paused": false,
    "antiDebug": false, "antiVM": false, "description": "",
    "createdAt": "...", "updatedAt": "...",
    "counts": { "users": 150, "licenses": 500, "sessions": 42,
                "variables": 10, "files": 3, "tokens": 5, "rules": 2 }
  }]
}
POST /api/apps Create application

Creates a new application. Subject to plan limits on max applications.

ParameterTypeDescription
namestringrequired Application name (must be unique per account)
descriptionstringoptional
versionstringoptional Default: "1.0.0"
// Response (201 Created)
{
  "data": {
    "id": "...", "name": "MyApp", "secret": "full_secret_shown_only_on_creation",
    "enabled": true, "version": "1.0.0", "description": ""
  }
}
GET /api/apps/:appId Get application details

Returns a single application's details. The secret is masked (last 6 characters only).

// Response
{
  "data": {
    "id": "...", "name": "MyApp", "secret": "***abc123",
    "enabled": true, "paused": false, "version": "1.0.0",
    "antiDebug": false, "antiVM": false,
    "lockHwid": false, "lockIp": false, "lockPcName": false,
    "description": "", "createdAt": "...", "updatedAt": "..."
  }
}
PATCH /api/apps/:appId Update application

Update any combination of application settings.

ParameterTypeDescription
namestringoptional Application name
descriptionstringoptional
versionstringoptional
enabledbooleanoptional Enable/disable the app
pausedbooleanoptional Pause app (blocks new logins)
antiDebugbooleanoptional Enable anti-debug detection
antiVMbooleanoptional Enable VM detection
lockHwidbooleanoptional Lock users to hardware ID
lockIpbooleanoptional Lock users to IP address
lockPcNamebooleanoptional Lock users to PC name
DELETE /api/apps/:appId Delete application

Permanently deletes the application and all associated data (users, licenses, sessions, variables, files, rules, logs, integrations).

ParameterTypeDescription
confirmbooleanrequired Must be true to confirm deletion
POST /api/apps/:appId/reset-secret Regenerate app secret

Generates a new secret key for the application. The old secret is immediately invalidated. All SDK clients will need the new secret to call /api/client/init.

// Response
{ "data": { "secret": "new_full_secret_48chars..." } }
GET /api/apps/:appId/stats Application statistics

Returns aggregate statistics for the application including user, license, session, and login counts.

// Response
{
  "data": {
    "users": { "total": 150, "active": 120, "banned": 5 },
    "licenses": { "total": 500, "used": 300, "unused": 200 },
    "sessions": { "active": 42 },
    "logins": { "today": 85, "thisWeek": 450 }
  }
}

Users

Manage application users. All endpoints require :appId.

GET /api/apps/:appId/users List users
Query ParamTypeDescription
searchstringSearch by username or email
limitintDefault: 50
offsetintDefault: 0
sortBystringusername, created_at, last_login_at, expires_at
sortOrderstringasc or desc
bannedstring"true" or "false"
expiredstring"true" to filter expired users
POST /api/apps/:appId/users Create user
ParameterTypeDescription
usernamestringrequired
passwordstringrequired
emailstringoptional
levelintoptional Default: 1
expiresAtstringoptional RFC3339 format
deviceLimitintoptional Default: 1
metadataobjectoptional JSON metadata
GET /api/apps/:appId/users/:userId Get user details

Returns user with preloaded devices and subscriptions.

PATCH /api/apps/:appId/users/:userId Update user

Accepts any combination of: password, email, level, expiresAt, deviceLimit, enabled, banned, banReason, hwid, displayName, pcName, lockedIp, hwidResetMax, hwidResetCooldown, ipResetMax, ipResetCooldown, metadata.

DELETE /api/apps/:appId/users/:userId Delete user

Permanently removes the user.

POST /api/apps/:appId/users/:userId/reset-hwid Reset HWID & IP

Clears HWID, locked IP, and all registered devices. Respects per-user cooldown and max reset limits.

POST /api/apps/:appId/users/:userId/extend Extend expiry
ParameterTypeDescription
durationintrequired Seconds to add
GET /api/apps/:appId/users/:userId/ip Get user IP info

Returns the user's last login IP and locked IP. Admin only — requires the account to have the admin role.

// Response
{ "data": { "lastLoginIp": "1.2.3.4", "lockedIp": "1.2.3.4" } }
DELETE /api/apps/:appId/users/:userId/sessions Kill user sessions

Deletes all active sessions for the specified user. Also sends a force_logout event via WebSocket if the user is connected.

// Response
{ "data": { "deleted": 3 } }

Licenses

GET /api/apps/:appId/licenses List licenses
Query ParamTypeDescription
searchstringSearch key, used_by, or note
limitintDefault: 50
offsetintDefault: 0
sortBystringkey, created_at, expires_at, used_count
usedstring"true" or "false"
bannedstring"true"
expiredstring"true"
POST /api/apps/:appId/licenses Generate licenses
ParameterTypeDescription
countintNumber of keys to generate (1-1000)
levelintLicense level (default: 1)
maxUsesintMax activations (0 = unlimited)
durationintExpiry duration in seconds (applied on activation)
expiresAtstringRFC3339 absolute expiry for the key itself
prefixstringKey prefix (e.g., "SWIFT")
notestringAdmin note
POST /api/apps/:appId/licenses/verify Verify a license key
ParameterTypeDescription
keystringrequired License key to verify

Returns the license details if valid, or an error if not found/expired/banned.

PATCH /api/apps/:appId/licenses/:licenseId Update license

Accepts: level, maxUses, duration, deviceLimit, displayName, note, enabled, banned.

DELETE /api/apps/:appId/licenses/:licenseId Delete license

Permanently removes the license key.

GET /api/apps/:appId/licenses/:licenseId Get license details

Returns full details for a single license key.

POST /api/apps/:appId/licenses/batch-delete Batch delete licenses

Delete multiple licenses at once, either by IDs or by filter. Provide ids for specific deletions, or filter for bulk cleanup.

ParameterTypeDescription
idsarrayoptional Array of license IDs to delete
filterstringoptional Bulk filter: "used", "expired", or "banned"
// Response
{ "data": { "deleted": 15 } }
GET /api/apps/:appId/licenses/:licenseId/ip Get license IP info

Returns IP and device info for the user who activated this license. Admin only — requires the account to have the admin role.

// Response
{
  "data": {
    "lastLoginIp": "1.2.3.4", "lockedIp": "1.2.3.4",
    "hwid": "ABC123...", "pcName": "DESKTOP-XYZ"
  }
}

Devices

View and manage trusted devices registered via HWID tracking.

GET /api/apps/:appId/devices List devices
Query ParamTypeDescription
searchstringSearch by HWID or username
limitintDefault: 50
offsetintDefault: 0
DELETE /api/apps/:appId/devices/:deviceId Remove device

Removes a registered device, allowing the user to authenticate from a new device.

Tokens

Generate and manage application access tokens.

GET /api/apps/:appId/tokens List tokens
Query ParamTypeDescription
limitintDefault: 50
offsetintDefault: 0
POST /api/apps/:appId/tokens Generate tokens
ParameterTypeDescription
countintNumber of tokens (1-500)
maxUsesint0 = unlimited
expiresAtstringRFC3339 expiry
notestringAdmin note
levelintToken level (default: 1)
PATCH /api/apps/:appId/tokens/:tokenId Update token

Update token properties.

ParameterTypeDescription
maxUsesintoptional
notestringoptional
enabledbooleanoptional
levelintoptional
DELETE /api/apps/:appId/tokens/:tokenId Delete token

Permanently removes the token.

Variables

Key-value configuration variables accessible by your application at runtime.

GET /api/apps/:appId/variables List variables

Returns all variables sorted by key.

POST /api/apps/:appId/variables Create variable
ParameterTypeDescription
keystringrequired
valuestringrequired
typestringSTRING, INT, FLOAT, BOOL, JSON (default: STRING)
POST /api/apps/:appId/variables/batch Batch upsert
ParameterTypeDescription
variablesarrayArray of {key, value, type} objects
PATCH /api/apps/:appId/variables/:varId Update variable
ParameterTypeDescription
valuestringoptional New value
typestringoptional STRING, INT, FLOAT, BOOL, JSON
DELETE /api/apps/:appId/variables/:varId Delete variable

Permanently removes the variable.

User Variables

Per-user key-value storage scoped to individual app users. Unlike app variables which are shared across all users, user variables store data specific to each user (preferences, progress, state, etc.).

GET /api/apps/:appId/users/:userId/variables List user variables

Returns all variables for the specified user, sorted by key.

POST /api/apps/:appId/users/:userId/variables Create user variable
ParameterTypeDescription
keystringrequired
valuestringrequired

Pushes a user_variable_update event to the user via WebSocket if connected.

PATCH /api/apps/:appId/users/:userId/variables/:varId Update user variable
ParameterTypeDescription
valuestringNew value for the variable
DELETE /api/apps/:appId/users/:userId/variables/:varId Delete user variable

Permanently removes the variable. Pushes a user_variable_delete event via WebSocket.

License Variables

Per-license key-value storage scoped to individual license keys. Attach custom data (configuration, metadata, feature flags) directly to a license. Pro+

GET /api/apps/:appId/licenses/:licenseId/variables List license variables

Returns all variables attached to the specified license, sorted by key.

POST /api/apps/:appId/licenses/:licenseId/variables Create license variable
ParameterTypeDescription
keystringrequired Unique variable key
valuestringVariable value
typestringSTRING, INT, FLOAT, BOOL, or JSON (default: STRING)

Value is validated against the specified type. Duplicate keys within the same license are rejected.

PATCH /api/apps/:appId/licenses/:licenseId/variables/:varId Update license variable
ParameterTypeDescription
valuestringNew value for the variable
typestringNew type (optional)
DELETE /api/apps/:appId/licenses/:licenseId/variables/:varId Delete license variable

Permanently removes the variable from the license.

Files

GET /api/apps/:appId/files List files

Returns all uploaded files for the application.

POST /api/apps/:appId/files/upload Upload file

Use multipart/form-data with field file. Optional fields: name, version.

GET /api/apps/:appId/files/:fileId/download Download file

Returns the file as a binary download with Content-Disposition header.

PATCH /api/apps/:appId/files/:fileId Update file metadata
ParameterTypeDescription
namestringoptional Display name
versionstringoptional File version
DELETE /api/apps/:appId/files/:fileId Delete file

Permanently removes the file from storage and database.

Rules

IP, HWID, and country blacklist/whitelist rules enforced during authentication.

GET /api/apps/:appId/rules List rules
Query ParamTypeDescription
typestringFilter by type (ip, hwid, country)
actionstringFilter by action (blacklist, whitelist)
POST /api/apps/:appId/rules Create rule
ParameterTypeDescription
typestringrequired ip, hwid, country
actionstringrequired blacklist or whitelist
valuestringrequired The value to match
notestringoptional
POST /api/apps/:appId/rules/batch Batch create rules

Create multiple rules at once.

ParameterTypeDescription
rulesarrayrequired Array of {type, action, value, note} objects
PATCH /api/apps/:appId/rules/:ruleId Update rule
ParameterTypeDescription
valuestringoptional
notestringoptional
enabledbooleanoptional
DELETE /api/apps/:appId/rules/:ruleId Delete rule

Permanently removes the rule.

Logs

GET /api/apps/:appId/logs List logs
Query ParamTypeDescription
eventstringFilter by event type
levelstringDEBUG, INFO, WARNING, ERROR, CRITICAL
usernamestringSearch by username (ILIKE)
startDatestringRFC3339 start date
endDatestringRFC3339 end date
limitintDefault: 50
offsetintDefault: 0
GET /api/apps/:appId/logs/stats Log statistics
Query ParamTypeDescription
hoursintLookback period (default: 24)
// Response
{
  "data": {
    "total": 1250, "byLevel": { "INFO": 900, "WARNING": 200, "ERROR": 150 },
    "byEvent": { "user.login": 500, "session.init": 300, ... }
  }
}
GET /api/apps/:appId/logs/events List event types

Returns all distinct event types that have been logged for this application.

// Response
{ "data": ["user.login", "user.register", "session.init", "license.activate", ...] }
DELETE /api/apps/:appId/logs/cleanup Clean up old logs

Deletes log entries older than the specified number of days.

Query ParamTypeDescription
daysintDelete logs older than N days (default: 30)
// Response
{ "data": { "deleted": 500 } }

Integrations

Configure webhook integrations for Discord, Telegram, Slack, and custom endpoints.

POST /api/apps/:appId/integrations Create integration
ParameterTypeDescription
namestringrequired
typestringrequired DISCORD, TELEGRAM, SLACK, CUSTOM
webhookUrlstringrequired
eventsarrayrequired Event types to listen for
GET /api/apps/:appId/integrations List integrations

Returns all integrations for the application. Webhook URLs are masked for security.

GET /api/apps/:appId/integrations/events List available events

Returns all event types that can be subscribed to via integrations.

// Response
{ "data": [
  "user.login", "user.login_failed", "user.register", "user.create", "user.update",
  "user.delete", "user.ban", "user.extend", "user.hwid_reset", "user.session_kill",
  "license.activate", "license.create", "license.update", "license.delete",
  "session.init", "session.end", "token.validate", "token.create", "token.delete",
  "file.upload", "file.download", "file.update", "file.delete",
  "variable.create", "variable.update", "variable.delete",
  "rule.create", "rule.update", "rule.delete", "rule.triggered",
  "integration.create", "integration.update", "integration.delete",
  "app.update", "app.secret_reset"
] }
PATCH /api/apps/:appId/integrations/:integrationId Update integration
ParameterTypeDescription
namestringoptional
webhookUrlstringoptional Must be HTTPS and public
eventsarrayoptional Event types to listen for
enabledbooleanoptional
DELETE /api/apps/:appId/integrations/:integrationId Delete integration

Permanently removes the integration.

POST /api/apps/:appId/integrations/:integrationId/test Test integration

Sends a test webhook to the integration's configured URL. Supports Discord embeds, Telegram messages, Slack attachments, and custom JSON payloads.

// Response
{ "success": true, "data": { "message": "Test webhook sent" } }
POST /api/apps/:appId/integrations/:integrationId/regenerate-secret Regenerate webhook secret

Generates a new signing secret for CUSTOM type integrations. The old secret is immediately invalidated.

// Response
{ "data": { "secret": "new_secret_32chars..." } }

Analytics

Application analytics endpoints providing usage metrics, activity trends, geographic data, and recent events. All endpoints require Bearer token and :appId.

GET /api/apps/:appId/analytics/overview Analytics overview

Returns aggregate metrics for users, licenses, sessions, and activity within the specified period.

Query ParamTypeDescription
periodstringTime period: "1h", "24h" (default), "7d", or "30d"
// Response
{
  "data": {
    "period": "24h",
    "users": { "total": 150, "new": 5, "active": 42, "banned": 3 },
    "licenses": { "total": 500, "unused": 200 },
    "sessions": { "active": 28 },
    "activity": { "logins": 85, "failedLogins": 12, "registrations": 5 }
  }
}
GET /api/apps/:appId/analytics/activity Activity timeline

Returns event counts bucketed by hour or day for charting activity trends.

Query ParamTypeDescription
periodstring"24h" (hourly buckets), "7d" (default, daily), or "30d" (daily)
eventstringEvent type to chart (default: "user.login")
// Response
{ "data": [
  { "bucket": "2025-01-15", "count": 42 },
  { "bucket": "2025-01-16", "count": 55 },
  ...
] }
GET /api/apps/:appId/analytics/countries Geographic breakdown

Returns login counts grouped by country code, based on IP geolocation data from log entries.

Query ParamTypeDescription
daysintLookback period in days (default: 30)
// Response
{ "data": [
  { "country": "US", "count": 250 },
  { "country": "GB", "count": 80 },
  ...
] }
GET /api/apps/:appId/analytics/recent Recent activity

Returns the most recent log entries for the application, useful for a live activity feed.

Query ParamTypeDescription
limitintNumber of entries (default: 20)
// Response
{ "data": [
  { "id": "...", "event": "user.login", "message": "User logged in",
    "username": "john", "ipAddress": "1.2.3.4", "level": "INFO",
    "createdAt": "2025-01-15T10:30:00Z" },
  ...
] }

Client API: Init & Nonce

The Client API is used by your application to authenticate users. All endpoints are under /api/client.

Nonce System: Mutating client endpoints (login, register, license, activate, heartbeat) require a single-use nonce in the X-Nonce header. Fetch a nonce via POST /api/client/nonce immediately before each mutating request.
POST /api/client/init Initialize session
ParameterTypeDescription
secretstringrequired Application secret key
// Response
{
  "data": {
    "sessionToken": "sess_abc123...",
    "app": { "name": "MyApp", "version": "1.0.0" }
  }
}
POST /api/client/nonce Get single-use nonce
ParameterTypeDescription
sessionTokenstringrequired
// Response
{ "data": { "nonce": "abc123..." } }

Client API: Login & Register

POST /api/client/login User login
ParameterTypeDescription
sessionTokenstringrequired
usernamestringrequired
passwordstringrequired
licenseKeystringoptional License key to attach on login
hwidstringoptional Hardware ID for device locking
pcNamestringoptional

Requires X-Nonce header.

POST /api/client/register User registration
ParameterTypeDescription
sessionTokenstringrequired
usernamestringrequired
passwordstringrequired
licenseKeystringoptional License to activate on registration

Requires X-Nonce header.

Client API: Licensing

POST /api/client/license License-only auth
ParameterTypeDescription
sessionTokenstringrequired
licenseKeystringrequired
hwidstringoptional

Authenticate using only a license key (no username/password). Requires X-Nonce header.

POST /api/client/activate Activate license
ParameterTypeDescription
sessionTokenstringrequired
licenseKeystringrequired

Activates a license key for the currently logged-in user. Requires X-Nonce header.

POST /api/client/check-license Check license validity
ParameterTypeDescription
sessionTokenstringrequired
licenseKeystringrequired License key to check

Checks if a license key is valid without activating it. Returns validity status, issues, and license details.

// Response
{
  "data": {
    "valid": true,
    "exists": true,
    "banned": false,
    "enabled": true,
    "issues": [],
    "license": {
      "level": 1,
      "duration": 2592000,
      "expiresAt": "2025-12-31T00:00:00Z",
      "usedCount": 1,
      "maxUses": 5,
      "usedBy": "user123"
    }
  }
}

Client API: Sessions

POST /api/client/heartbeat Session heartbeat
ParameterTypeDescription
sessionTokenstringrequired

Keep-alive ping. Must be called periodically to prevent session expiry. Requires X-Nonce header.

POST /api/client/check Check session

Validates if a session token is still active. Body: { "sessionToken": "..." }

POST /api/client/end End session

Gracefully ends the session. Body: { "sessionToken": "..." }

Client API: Data & Files

POST /api/client/variable Get variable
ParameterTypeDescription
sessionTokenstringrequired
keystringrequired
POST /api/client/variables Get all variables

Returns all variables for the application. Body: { "sessionToken": "..." }

POST /api/client/license-variable Get license variable
ParameterTypeDescription
sessionTokenstringrequired
keystringrequired

Returns the value of a variable attached to the user's active license. Returns { key, value, type }.

POST /api/client/license-variables Get all license variables

Returns all variables attached to the user's active license. Body: { "sessionToken": "..." }

Response is an array of { key, value, type } objects.

POST /api/client/user-variable Get user variable
ParameterTypeDescription
sessionTokenstringrequired
keystringrequired

Returns the value of a user-specific variable. Requires an authenticated (logged-in) session.

POST /api/client/user-variables Get all user variables

Returns all variables for the authenticated user. Body: { "sessionToken": "..." }

POST /api/client/set-user-variable Set user variable
ParameterTypeDescription
sessionTokenstringrequired
keystringrequired
valuestringrequired

Creates or updates a user variable. If the key already exists, its value is overwritten (upsert).

POST /api/client/delete-user-variable Delete user variable
ParameterTypeDescription
sessionTokenstringrequired
keystringrequired

Permanently deletes a user variable by key.

POST /api/client/file Download file
ParameterTypeDescription
sessionTokenstringrequired
fileNamestringrequired
POST /api/client/check-update Check for updates
ParameterTypeDescription
sessionTokenstringrequired
currentVersionstringrequired
fileNamestringrequired

Compares the current version against the latest file version. Returns download URL if update available.

POST /api/client/user Get user info

Returns the authenticated user's profile. Body: { "sessionToken": "..." }

POST /api/client/log Submit client log
ParameterTypeDescription
sessionTokenstringrequired
eventstringrequired Event name (e.g., "app.crash", "feature.used")
messagestringrequired Log message
dataobjectoptional Additional JSON data

Client API: Account & Tokens

POST /api/client/token Validate access token

Validates an application access token and increments its usage counter. Returns the token's level for permission checks.

ParameterTypeDescription
sessionTokenstringrequired
tokenstringrequired The access token to validate
// Response
{ "data": { "valid": true, "level": 1 } }
POST /api/client/change-password Change user password

Allows the logged-in app user to change their password.

ParameterTypeDescription
sessionTokenstringrequired
currentPasswordstringrequired
newPasswordstringrequired
// Response
{ "success": true, "data": { "message": "Password changed" } }
POST /api/client/request-reset Request device reset

Requests an HWID/IP reset for a user via their license key. Sends a confirmation email to the user's registered email. Respects per-user reset limits and cooldowns.

ParameterTypeDescription
sessionTokenstringrequired
licenseKeystringrequired License key linked to the user
hwidstringoptional New HWID to set after reset
// Response
{ "success": true, "data": { "message": "Reset confirmation email sent" } }
GET /api/client/confirm-reset/:token Confirm device reset

Confirms the HWID/IP reset using the token from the confirmation email. Returns an HTML success page. Token is single-use and time-limited.

ParameterTypeDescription
tokenstringrequired Reset confirmation token (URL param)

WebSocket API: Overview

The WebSocket API provides real-time bidirectional communication between your application dashboard, your server, and connected client SDK users. WebSocket features are available on the Business plan only.

Plan Requirement: WebSocket features require the Business plan. Attempting to connect on a lower plan will return a 403 PLAN_FEATURE error.

Connection Types

There are two WebSocket connection types:

Dashboard Connection — Authenticated via JWT token. Used by the app owner's dashboard to receive real-time events (user connects/disconnects, online counts, live sessions, chat, custom events).

Client Connection — Authenticated via session token. Used by end-user applications to receive messages, commands, force-logouts, and custom payloads from the dashboard.

Connection Limits

LimitValueDescription
Per app500Maximum client connections per application
Per user1Maximum WebSocket connections per user
Upgrade rate10/minMaximum upgrade requests per IP per minute
Message rate20/10sClient message rate limit (30/10s for dashboard)

Event Format

All messages are JSON with a type field and optional data field:

{
  "type": "event_name",
  "data": { ... }
}

WebSocket: Dashboard Connection

GET /api/apps/:appId/ws/connect?token=JWT Dashboard WebSocket upgrade

Upgrades the HTTP connection to a WebSocket. Authentication is done via the token query parameter (your JWT), since browsers cannot send custom headers during WebSocket upgrade.

ParameterTypeDescription
appIdstringrequired Application ID (URL param)
tokenstringrequired JWT token (query param)

On connect, the server automatically sends the current online_count and sessions list.

Sending Messages (Dashboard → Server)

TypeFieldsDescription
pingKeepalive ping (server replies with pong)
get_onlineRequest current online user count
get_sessionsRequest list of live sessions with metadata
chatuserId, messageSend a chat message to a specific user
push_jsonuserId?, payloadPush custom JSON to a user (or broadcast if no userId)
typinguserId, typingSend typing indicator to a user
kickuserId, reason?Kick a user with an optional reason
banuserId, reason?Ban a user and disconnect them
commandcommand, userId?, payload?Send a named command to a user or all clients
set_filterseventsSubscribe to specific event types only

Receiving Events (Server → Dashboard)

TypeDataDescription
pongResponse to ping
online_countcountCurrent online user count
sessionssessionsArray of live sessions
session_connectuserId, username, ipA user connected
session_disconnectuserId, usernameA user disconnected
chatuserId, username, messageChat message from a user
custom_eventevent, userId, username, dataCustom event sent by a client
errormessageError message (e.g. rate limited)
// Example: Connect to dashboard WebSocket
const ws = new WebSocket(
  `wss://swiftauth.net/api/apps/${appId}/ws/connect?token=${jwt}`
);

ws.onopen = () => {
  // Subscribe to specific events only
  ws.send(JSON.stringify({ type: "set_filters", events: ["chat", "session_connect"] }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  if (msg.type === "online_count") {
    console.log("Online users:", msg.data.count);
  }
};

// Send a chat message to a user
ws.send(JSON.stringify({ type: "chat", userId: "user_123", message: "Hello!" }));

WebSocket: Client Connection

GET /api/client/ws?token=SESSION_TOKEN Client SDK WebSocket upgrade

Upgrades the HTTP connection to a WebSocket for client SDK users. Authenticated via the token query parameter (session token from login). The server enforces IP pinning, user state validation, and rule checks before allowing upgrade.

ParameterTypeDescription
tokenstringrequired Session token (query param)

The server revalidates the session and user state every 30 seconds. If the session expires, user gets banned, or the app is paused/disabled, the server sends a force_logout event and closes the connection.

Sending Messages (Client → Server)

TypeFieldsDescription
pingKeepalive ping (server replies with pong)
set_statusstatusSet presence status (e.g. "online", "away", "busy")
chatmessageSend a chat message (forwarded to dashboard)
typingtypingSend typing indicator (boolean)
set_metadatametadataSet custom metadata (max 20 key-value pairs)
customdata?, message?Any other type triggers hook evaluation and is forwarded to the dashboard

Receiving Events (Server → Client)

TypeDataDescription
pongResponse to ping
variable_updatekey, value, typeAn app variable was created or updated
variable_deletekeyAn app variable was deleted
user_variable_updatekey, valueA per-user variable was created or updated
user_variable_deletekeyA per-user variable was deleted
messagemessage, typeBroadcast or targeted message from dashboard
chatmessageChat message from dashboard
commandcommand, payloadNamed command from dashboard
custom*Custom JSON payload pushed from dashboard
force_logoutreasonForced disconnect (session expired, kicked, etc.)
bannedreasonBanned by application owner
typingtypingTyping indicator from dashboard
errormessageError message (e.g. rate limited)
// Example: Connect as a client SDK user
const ws = new WebSocket(
  `wss://swiftauth.net/api/client/ws?token=${sessionToken}`
);

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  switch (msg.type) {
    case "variable_update":
      console.log("Variable changed:", msg.data.key, "=", msg.data.value);
      break;
    case "variable_delete":
      console.log("Variable removed:", msg.data.key);
      break;
    case "user_variable_update":
      console.log("User variable:", msg.data.key, "=", msg.data.value);
      break;
    case "message":
      console.log(`[${msg.data.type}] ${msg.data.message}`);
      break;
    case "force_logout":
      console.log("Disconnected:", msg.data.reason);
      ws.close();
      break;
    case "banned":
      console.log("Banned:", msg.data.reason);
      ws.close();
      break;
    case "command":
      handleCommand(msg.data.command, msg.data.payload);
      break;
  }
};

// Set presence status
ws.send(JSON.stringify({ type: "set_status", status: "online" }));

// Send a chat message
ws.send(JSON.stringify({ type: "chat", message: "Hello from client!" }));

// Send a custom event (triggers hooks)
ws.send(JSON.stringify({ type: "player_score", data: { score: 1500, level: 3 } }));

WebSocket: REST Endpoints

These REST endpoints allow you to interact with WebSocket-connected users from your server without maintaining a WebSocket connection yourself. All require dashboard JWT authentication and the :appId URL parameter.

GET /api/apps/:appId/ws/online Get online user count

Returns the number of currently connected client WebSocket users.

// Response
{ "success": true, "data": { "count": 42 } }
GET /api/apps/:appId/ws/sessions Get live sessions

Returns all currently connected WebSocket sessions with user details.

// Response
{
  "success": true,
  "data": {
    "count": 2,
    "sessions": [
      { "userId": "...", "username": "john", "ip": "1.2.3.4", "connectedAt": "..." },
      { "userId": "...", "username": "jane", "ip": "5.6.7.8", "connectedAt": "..." }
    ]
  }
}
POST /api/apps/:appId/ws/broadcast Broadcast message

Send a message to all connected client WebSocket users.

ParameterTypeDescription
messagestringrequired The message to broadcast
typestringoptional Message type: "info" (default), "warning", "alert"
// Response
{ "success": true, "data": { "sent": true, "onlineUsers": 42 } }
POST /api/apps/:appId/ws/force-logout/:userId Force-logout user

Send a force-logout event to a specific user, disconnecting them.

ParameterTypeDescription
userIdstringrequired Target user ID (URL param)
reasonstringoptional Reason shown to the user
POST /api/apps/:appId/ws/kick/:userId Kick user

Kick a user from the WebSocket connection with an optional reason.

ParameterTypeDescription
userIdstringrequired Target user ID (URL param)
reasonstringoptional Kick reason shown to the user
POST /api/apps/:appId/ws/ban/:userId Ban user

Ban a user (sets banned flag in database) and immediately disconnects them from WebSocket.

ParameterTypeDescription
userIdstringrequired Target user ID (URL param)
reasonstringoptional Ban reason
POST /api/apps/:appId/ws/chat Send chat message

Send a chat message to a specific connected user.

ParameterTypeDescription
userIdstringrequired Target user ID
messagestringrequired Chat message
POST /api/apps/:appId/ws/command Send command

Send a named command to a specific user or all connected clients. If userId is omitted, the command is broadcast to all clients.

ParameterTypeDescription
commandstringrequired Command name
userIdstringoptional Target user ID (omit to broadcast)
payloadobjectoptional Arbitrary JSON payload
POST /api/apps/:appId/ws/push Push JSON payload

Push a custom JSON payload to a specific user or all connected clients.

ParameterTypeDescription
payloadobjectrequired Arbitrary JSON payload to push
userIdstringoptional Target user ID (omit to broadcast to all)

WebSocket: Hooks

WebSocket hooks let you automate server-side responses to custom events sent by clients. When a client sends a message with a custom type, the hook engine evaluates matching hooks and executes their actions. Maximum 20 hooks per application.

Hook Actions

Each hook can have up to 5 actions. Supported action types:

Action TypeTargetDescription
respondsenderSend a response back to the user who triggered the event
send_messageuserIdSend a message to a specific user
broadcastallBroadcast a message to all connected clients
push_jsonuserId or allPush a custom JSON payload
kickuserId or senderKick a user
banuserId or senderBan a user
logCreate a log entry

Hook Conditions

Conditions (max 5 per hook) filter when a hook fires. All conditions must match (AND logic).

OperatorDescription
eqField equals value
neqField does not equal value
containsField contains value (substring)
existsField exists (is not empty)
GET /api/apps/:appId/ws/hooks List hooks

Returns all WebSocket hooks for the application, ordered by priority.

// Response
{
  "success": true,
  "data": {
    "count": 1,
    "hooks": [{
      "id": "...",
      "name": "Welcome Message",
      "event": "join_room",
      "conditions": [{ "field": "data.room", "operator": "eq", "value": "lobby" }],
      "actions": [{ "type": "respond", "message": "Welcome to the lobby!" }],
      "enabled": true,
      "priority": 0
    }]
  }
}
POST /api/apps/:appId/ws/hooks Create hook
ParameterTypeDescription
namestringrequired Hook name (max 100 chars)
eventstringrequired Custom event type to trigger on (max 50 chars, cannot be a system event)
actionsarrayrequired Array of action objects (max 5)
conditionsarrayoptional Array of condition objects (max 5)
descriptionstringoptional Hook description (max 500 chars)
priorityintegeroptional Execution priority, lower runs first (0-999, default 0)
// Example: Create a hook
POST /api/apps/:appId/ws/hooks
{
  "name": "Auto-welcome",
  "event": "join_room",
  "conditions": [
    { "field": "data.room", "operator": "eq", "value": "lobby" }
  ],
  "actions": [
    { "type": "respond", "message": "Welcome to the lobby!" },
    { "type": "log", "message": "User joined lobby" }
  ]
}
PATCH /api/apps/:appId/ws/hooks/:hookId Update hook

Update any field of an existing hook. Only include the fields you want to change.

ParameterTypeDescription
namestringoptional New name
eventstringoptional New trigger event
actionsarrayoptional New actions array
conditionsarrayoptional New conditions array
descriptionstringoptional New description
enabledbooleanoptional Enable or disable the hook
priorityintegeroptional New priority (0-999)
DELETE /api/apps/:appId/ws/hooks/:hookId Delete hook

Permanently deletes a WebSocket hook.

ParameterTypeDescription
hookIdstringrequired Hook ID (URL param)