Overview
This guide will walk you through creating a bot account and making your first authenticated API request to Fluxer. You’ll learn how to:- Create an OAuth2 application with a bot user
- Obtain a bot token for authentication
- Make authenticated API requests
- Understand response formats
This quickstart uses the hosted Fluxer instance at
api.fluxer.app. If you’re self-hosting, replace the base URL with your instance.Prerequisites
Before starting, you need:- A Fluxer account (create one at web.fluxer.app)
curlor another HTTP client (examples use curl)- A text editor for storing your bot token
Step 1: Create an OAuth2 Application
Bot accounts in Fluxer are created through OAuth2 applications. Each application automatically gets an associated bot user.Navigate to User Settings
- Open Fluxer (web or desktop)
- Click your avatar in the bottom-left
- Select User Settings
- Navigate to Applications in the sidebar
Create New Application
Click New Application and provide:
- Name: Your bot’s display name (e.g., “My First Bot”)
- Redirect URIs: Leave empty for now (only needed for OAuth2 flows)
Application Structure
When you create an application, Fluxer automatically provisions:- OAuth2 Application - Used for authorization flows
- Bot User Account - A special user account for programmatic access
- Client Credentials - ID and secret for OAuth2 client authentication
Step 2: Make Your First API Call
Let’s verify your bot token by fetching the bot’s user information.Fetch Current User
Example Response
Example Response
id: Snowflake ID of your bot userusername: Bot’s usernamebot: Alwaystruefor bot accountsverified: Email verification status (always true for bots)
Understanding Authentication Headers
Bot authentication uses theAuthorization header with the format:
- Prefix: Must be
Bot(case-sensitive) - Token: Your bot token from the application settings
- Separator: Single space between prefix and token
Step 3: Send a Message
Now let’s send a message to a channel. You’ll need a channel ID where your bot has access.Bot accounts can only access channels in guilds where they’ve been added. Initially, your bot won’t be in any guilds.
Add Bot to a Guild
Before sending messages, add your bot to a guild (server):Generate OAuth2 URL
Use this URL format (replace You can specify permissions as a bitfield. For basic message sending, use
CLIENT_ID with your Application ID):2048 (Send Messages).Send a Message
Once your bot is in a guild, send a message to a channel:Example Response
Example Response
Step 4: Handle Errors
API requests can fail for various reasons. Always check the response status and handle errors gracefully.Common Error Codes
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
Cause: Bot lacks permissions for the requested actionSolutions:
- Check bot has required permissions in the guild
- Verify bot is a member of the guild
- Review channel-specific permission overrides
429 Too Many Requests
429 Too Many Requests
Cause: Rate limit exceededSolutions:See Rate Limits for detailed information.
- Respect the
Retry-Afterheader (in seconds) - Implement exponential backoff
- Cache responses when possible
Error Handling Example
Step 5: Connect to the Gateway (Optional)
For real-time events (new messages, reactions, presence updates), connect to the WebSocket Gateway.The Gateway is optional. If you only need to make API calls (e.g., send messages on a schedule), the REST API is sufficient.
Gateway Overview
- Connect to
wss://gateway.fluxer.app - Send identification with your bot token
- Receive events as they happen
- Send heartbeats to maintain the connection
Quick Gateway Example
Next Steps
Congratulations! You’ve created a bot and made your first API calls. Here’s what to explore next:Authentication Deep Dive
Learn about OAuth2, user tokens, and session management
API Reference
Browse all available endpoints and resources
Gateway Guide
Connect to real-time events via WebSocket
Bot Examples
Explore bot patterns and best practices
Best Practices
Store Tokens Securely
Store Tokens Securely
- Use environment variables (never hardcode)
- Use secret management in production (AWS Secrets Manager, HashiCorp Vault)
- Rotate tokens if compromised
- Never commit tokens to version control
Handle Rate Limits
Handle Rate Limits
- Respect
Retry-Afterheaders - Implement exponential backoff
- Cache responses when possible
- Use global rate limit buckets per resource
Validate Input
Validate Input
- Sanitize user input before sending to API
- Validate message content length (max 2000 characters)
- Check file sizes before upload
- Handle invalid IDs gracefully
Monitor Your Bot
Monitor Your Bot
- Log API errors with context
- Track rate limit hits
- Monitor Gateway disconnections
- Set up alerts for critical failures
Troubleshooting
Bot token not working
Bot token not working
Symptoms: 401 Unauthorized errorsSolutions:
- Verify token is copied correctly (no extra spaces)
- Ensure using
Botprefix, notBearer - Check token hasn’t been regenerated
- Confirm application still exists
Bot can't send messages
Bot can't send messages
Symptoms: 403 Forbidden errorsSolutions:
- Verify bot is in the guild
- Check bot has SEND_MESSAGES permission
- Review channel-specific permission overrides
- Ensure channel exists and bot can see it
Rate limits constantly hit
Rate limits constantly hit
Symptoms: 429 Too Many RequestsSolutions:
- Implement request queuing
- Add delays between bulk operations
- Cache responses to reduce API calls
- Review your bot’s request patterns
Support
Need help? Here are your options:- Documentation: Browse docs.fluxer.app
- GitHub Issues: Report bugs at github.com/fluxerapp/fluxer
- Email: Contact [email protected]
- Community: Join the Fluxer community server