What are API Keys?
API keys are long-lived credentials that allow your server to authenticate with SnackBase without requiring a user login flow. They’re ideal for:- Backend services and cron jobs
- Webhook endpoints
- Server-side data processing
- Automated scripts
Setting Up API Keys
Generate an API Key
- Log in to your SnackBase admin panel
- Navigate to API Keys
- Click + New API Key
- Enter a description (e.g., “Production API”)
- Copy the generated key
API keys are only shown once at creation. Store them securely in your
environment variables.
Using API Keys
Basic Usage
Environment Variables
Store your API key in environment variables:Different Keys for Different Environments
Use different API keys for different environments:API Key vs User Authentication
Server-Side Operations
Express.js Example
Next.js Example
Background Jobs
Webhook Handling
Admin Operations
API keys have full access to account operations:Error Handling
Security Best Practices
1. Environment Variables
Never hardcode API keys:2. Use Different Keys for Different Services
Create separate API keys for different services:3. Rotate API Keys Regularly
Periodically rotate your API keys:- Create a new API key
- Update your environment variables
- Deploy the changes
- Delete the old API key
4. Use Key Prefixes
API keys include prefixes to identify their type:sbak_live_- Production keyssbak_test_- Test/development keys
5. Monitor Usage
Monitor your API key usage in the SnackBase admin panel to detect unauthorized access.Rate Limits
API keys have higher rate limits than user authentication:Actual rate limits depend on your SnackBase plan. Contact support for
custom limits.
Testing
Use test API keys during development:Next Steps
- Email/Password Auth - User authentication
- OAuth Guide - Social login
- Error Handling - Handle errors gracefully