Authentication¶
SubX API uses API keys for authentication. All API requests (except /api/health) require authentication.
Creating an API Key¶
To use the SubX API, you'll need to create an API key from the web interface.
Steps to Create an API Key¶
- Sign In to the SubX web application
- Navigate to Profile or API Keys section in your account settings
- Click "Create New API Key"
- Give your API key a descriptive name (e.g., "My App Production", "Testing")
- Optionally set an expiration date for added security
- Click "Generate Key"
Save Your API Key
The API key will only be displayed once when you create it. Make sure to copy it to a secure location immediately. If you lose it, you'll need to generate a new one.
Using Your API Key¶
Include your API key in the Authorization header of every protected API request:
For example:
Example Request¶
Managing Your API Keys¶
Viewing Your Keys¶
You can view all your active API keys in the web interface:
- Go to Profile → API Keys
- You'll see a list of all your keys with:
- Key name
- Creation date
- Last used date
- Expiration date (if set)
- Usage statistics
Revoking a Key¶
If you need to revoke an API key:
- Navigate to Profile → API Keys
- Find the key you want to revoke
- Click "Revoke" or the trash icon
- Confirm the action
Caution
Revoking an API key is permanent and immediate. Any applications using that key will stop working immediately.
Security Best Practices¶
Do's ✅¶
- Store keys securely - Use environment variables or secret management systems
- Use different keys for different applications or environments
- Set expiration dates for keys when possible
- Rotate keys periodically for enhanced security
- Monitor usage to detect unusual activity
Don'ts ❌¶
- Don't commit keys to version control (Git, etc.)
- Don't share keys publicly or via email
- Don't use the same key across multiple unrelated applications
- Don't hardcode keys in your source code
Environment Variables Example¶
Authentication Errors¶
401 Unauthorized¶
This error occurs when:
- No API key is provided
- The API key is invalid or malformed
- The API key has been revoked
Response:
Solution: Check that you're sending the correct API key in the Authorization header.
403 Forbidden¶
This error occurs when:
- The API key is valid but doesn't have permission for the requested resource
- The API key has expired
Response:
Solution: Verify that your API key hasn't expired and has the necessary permissions.
Rate Limiting¶
API keys are subject to rate limiting to ensure fair usage. See the Rate Limits Guide for details.
Next Steps¶
Now that you understand authentication, let's make your first API request! Continue to the Quickstart Guide.