Discord Activity Reference - Technical Documentation

Complete API reference and technical details for Discord Activity integration


Table of Contents


Discord SDK API

Initialization

import { DiscordSDK } from '@discord/embedded-app-sdk';

const discordSdk = new DiscordSDK(clientId: string, options?: {
  disableConsoleLogOverride?: boolean;
});

// Wait for SDK to be ready
await discordSdk.ready();

Authentication

authenticate()

Requests user authorization and returns an access token.

Available Scopes:

  • identify - Read user profile (id, username, avatar)

  • email - Read user email address

  • guilds - See servers user is in

  • guilds.members.read - Read user's guild member data

authorize()

Similar to authenticate() but doesn't return user data.

User Methods

Get Current User

User Object:

Guild (Server) Methods

Get User Guilds

Guild Object:

Activity Context

Get Instance Info

Information about the current Discord Activity session.

Get Participants

Get list of users currently in the Activity.


AeThex Discord Endpoints

These are the backend API endpoints provided by AeThex for Discord integration.

Authentication Endpoints

POST /api/discord/oauth/start

Initiates Discord OAuth flow.

Query Parameters:

  • action (optional): "login" or "link"

  • redirectTo (optional): URL to redirect after completion

Response:

GET /api/discord/oauth/callback

Handles OAuth callback from Discord.

Query Parameters:

  • code: Authorization code from Discord

  • state: State parameter (contains action and session info)

Behavior:

  • If action=login: Creates/logs in user, redirects to dashboard

  • If action=link: Links Discord to existing user, redirects to connections tab

Success Response:

  • Redirects to: /dashboard?tab=connections (link) or /dashboard (login)

Error Response:

  • Redirects to: /login?error=<code>&message=<details>

Account Linking Endpoints

POST /api/discord/create-linking-session

Creates a temporary session for Discord account linking.

Headers:

  • Authorization: Bearer <aethex_token>

Response:

Session Duration: 5 minutes

POST /api/discord/link

Links Discord account to authenticated user.

Headers:

  • Authorization: Bearer <aethex_token>

Body:

Response:

POST /api/discord/verify-code

Verifies a 6-digit linking code from Discord bot /verify command.

Body:

Response:

Activity Endpoints

POST /api/discord/activity-auth

Exchanges Discord access token for AeThex session.

Body:

Response:

GET /api/discord/token

Retrieves stored Discord tokens for a user.

Headers:

  • Authorization: Bearer <aethex_token>

Response:

Admin Endpoints

POST /api/discord/admin-register-commands

Registers Discord bot slash commands.

Headers:

  • Authorization: Bearer <admin_token>

Response:


Authentication Methods

Method 1: Discord Activity OAuth

For apps running inside Discord Activity.

Method 2: OAuth Redirect Flow

For standard web applications.

Method 3: Account Linking

For linking Discord to existing AeThex account.

Method 4: Bot Verify Command

For Discord bot users to link accounts.


Event Handling

Activity Events


Discord Bot Commands

If you have a Discord bot, register these commands for better user experience.

/verify Command

Links Discord account to AeThex.

Registration:

Handler (bot code):


Error Codes

OAuth Errors

Code
Description
Solution

invalid_request

Missing required parameter

Check OAuth URL parameters

unauthorized_client

Client not authorized

Verify client_id in Discord portal

access_denied

User denied authorization

User must authorize to continue

unsupported_response_type

Invalid response_type

Use response_type=code

invalid_scope

Invalid or unsupported scope

Check available scopes

redirect_uri_mismatch

Redirect URI not registered

Add URI to Discord OAuth2 settings

AeThex API Errors

Status
Error Code
Description

401

not_authenticated

User not logged in or session expired

403

discord_already_linked

Discord account linked to different user

404

user_not_found

User doesn't exist

409

email_exists

Email already registered (use link instead)

422

invalid_code

Verification code invalid or expired

500

server_error

Internal server error


Rate Limits

Discord API Rate Limits

  • Global: 50 requests per second

  • Per Route: Varies by endpoint (check headers)

  • OAuth Token: 1 request per 10 seconds per user

Response Headers:

AeThex API Rate Limits

  • Authentication endpoints: 10 requests per minute per IP

  • Account linking: 5 requests per minute per user

  • Activity auth: 30 requests per minute per user

Handling Rate Limits:


TypeScript Types

Discord Types

AeThex Types


Database Schema

Stores Discord account linkages.

discord_linking_sessions Table

Temporary sessions for OAuth linking flow.

verification_codes Table

6-digit codes for Discord bot /verify command.



Last Updated: January 7, 2026 Discord API Version: v10 AeThex SDK Version: 2.0+

Last updated