Skip to main content

Support & Integration Endpoints

These endpoints provide integration with external services for monetization and user authentication. They are only available when USE_BACKEND=true is configured.
These endpoints require backend integration to be enabled. Set USE_BACKEND=true in your environment configuration.

GET /getSupportPackages

Fetches available support packages from the Tebex platform. Results are cached for 10 minutes to reduce API calls.

Configuration Required

USE_BACKEND
string
required
Must be set to "true"
TEBEX_BASE_URL
string
required
Base URL for the Tebex API
TEBEX_STORE_ID
string
required
Your Tebex store identifier
TEBEX_EXTENSION_ID
string
required
Tebex extension identifier for the integration

Response

packages
array
Array of package objects from Tebex

Example Request

curl https://your-server.com:5101/getSupportPackages

Example Response

[
  {
    "id": "pkg_123",
    "name": "Supporter Package",
    "price": 9.99,
    "checkoutUrl": "https://tebex.io/checkout/store123/pkg_123?extensionId=ext123"
  },
  {
    "id": "pkg_456",
    "name": "Premium Package",
    "price": 19.99,
    "checkoutUrl": "https://tebex.io/checkout/store123/pkg_456?extensionId=ext123"
  }
]

Error Responses

502 Bad Gateway
object
Failed to fetch packages from Tebex API
{
  "error": "Failed to fetch packages"
}
500 Internal Server Error
object
Server error during package fetch
{
  "error": "Internal server error, [error details]"
}

Caching Behavior

  • Packages are cached for 10 minutes after first fetch
  • Subsequent requests within 10 minutes return cached data
  • Cache automatically clears after timeout
The checkoutUrl field is dynamically generated by the server using the configured Tebex base URL, store ID, package ID, and extension ID.

GET /client/oauth-callback

Handles the OAuth callback from Discord authentication. This endpoint receives the authorization code, exchanges it for an access token, fetches user information, and redirects to the Spectra Client via deeplink.

Configuration Required

USE_BACKEND
string
required
Must be set to "true"
DISCORD_CLIENT_ID
string
required
Discord application client ID
DISCORD_CLIENT_SECRET
string
required
Discord application client secret
DISCORD_REDIRECT_URI
string
required
OAuth redirect URI (must match Discord app configuration)
DISCORD_OAUTH_URL
string
required
Discord OAuth token endpoint URL
DISCORD_USER_URL
string
required
Discord user information endpoint URL
Deeplink protocol URL for launching the Spectra Client

Query Parameters

code
string
required
Authorization code from Discord OAuth flow

Response

Returns an HTML page that:
  1. Displays a success message with the user’s Discord username
  2. Automatically redirects to the Spectra Client after 2 seconds
  3. Provides a manual button to open the client if auto-redirect fails
The deeplink URL includes:
  • userId - Discord user ID
  • username - Discord username
  • avatar - Discord avatar hash
spectra-client://auth?userId=123456789&username=PlayerName&avatar=a_abc123def456

HTML Response

The endpoint returns a styled HTML page with:
  • Success message with user’s display name
  • Auto-redirect script (2 second delay)
  • Manual “Open Spectra Client” button
  • Gradient background styling

Error Responses

4xx/5xx Errors
object
Failed to fetch Discord user data
{
  "error": "Failed to fetch user data"
}
500 Internal Server Error
object
Error during OAuth flow
{
  "error": "Internal server error"
}

OAuth Flow

1

User initiates Discord login

User clicks “Login with Discord” in the Spectra Client
2

Discord authorization

User authorizes the application on Discord
3

Callback to server

Discord redirects to /client/oauth-callback?code=...
4

Token exchange

Server exchanges authorization code for access token
5

Fetch user data

Server fetches user information from Discord API
6

Generate deeplink

Server creates deeplink with user data
7

Return HTML page

Server returns HTML page with auto-redirect to Spectra Client
8

Client receives user data

Spectra Client receives user ID, username, and avatar via deeplink
This endpoint is designed specifically for the Spectra Client’s Discord integration. The deeplink protocol must be registered with the operating system to launch the client application.

Implementation Reference

Both endpoints are implemented in src/util/SupportService.ts and conditionally registered in src/index.ts:
// From src/index.ts:86-93
if (process.env.USE_BACKEND === "true") {
  app.get("/getSupportPackages", async (req, res) => {
    handlePackageRequest(res);
  });
  app.get("/client/oauth-callback", async (req, res) => {
    handleDiscordAuth(req, res);
  });
}

Configuration Guide

Configure Tebex and Discord environment variables

Integrations

Learn about backend integration setup

REST API Overview

View all available REST endpoints

Build docs developers (and LLMs) love