Overview
The SundayPyjamas AI Suite API uses API keys for authentication. All API requests must include a valid API key in the Authorization header.API keys provide secure access to the API while maintaining workspace-level isolation and usage tracking.
API Key Format
API keys follow this specific format:Getting Your API Key
Follow these steps to generate your API key:1
Access Workspace Settings
Navigate to your workspace settings in the SundayPyjamas platform.
2
Go to API Tab
Click on the “API” tab in your workspace settings.
3
Generate Key
Click “Generate API Key” to create a new key.
4
Name Your Key (Optional)
Give your API key a descriptive name to help you identify it later.
5
Copy and Store
Copy the generated key immediately and store it securely. It won’t be shown again!
Making Authenticated Requests
Include your API key in theAuthorization header with the Bearer scheme:
Permissions and Access Control
API keys inherit the permissions of the user who created them:Workspace Access
Keys can only access the workspace they were created in
Role Requirements
Only workspace
owners and admins can create/manage API keysToken Limits
API usage counts toward your workspace token limit
Usage Tracking
Monitor API key usage through workspace analytics
Security Best Practices
✅ Do
Store API keys securely
Store API keys securely
- Use environment variables or secure key management systems
- Never hardcode API keys in your source code
- Use different API keys for different applications/environments
Rotate API keys regularly
Rotate API keys regularly
- Generate new API keys periodically
- Deactivate old keys after replacement
- Use descriptive names to track key usage
Monitor API key usage
Monitor API key usage
- Review usage analytics regularly
- Set up alerts for unusual activity
- Track token consumption patterns
❌ Don’t
Never expose API keys in client-side code
Never expose API keys in client-side code
API keys should never be included in frontend JavaScript, mobile apps, or any client-side code where users can access them.
Don't share API keys across multiple applications
Don't share API keys across multiple applications
Never commit API keys to version control
Never commit API keys to version control
Use
.gitignore to exclude files containing API keys and use environment variables instead.API Key Management
Creating API Keys
1
Navigate to Settings
Go to your workspace settings in the SundayPyjamas web interface.
2
Access API Tab
Click on the “API” tab to view key management options.
3
Generate New Key
Click “Generate API Key” and optionally provide a descriptive name.
4
Save Securely
Copy the generated key immediately and store it in your secure key management system.
Managing Existing Keys
In your workspace API settings, you can:- View all active API keys with their names and creation dates
- Delete keys you no longer need
- Monitor usage for each individual key
- Track token consumption per API key
API key creation and management is done exclusively through the web interface to ensure proper security and access control.
Rate Limits and Quotas
Per Workspace Limit
Maximum 10 active API keys per workspace
Token-based Usage
API usage counts toward workspace token quotas
Request Rate Limits
Standard rate limiting applies to all API endpoints
Fair Usage Policy
Usage monitoring to ensure fair access for all users
Error Responses
Invalid API Key (401)
- API key doesn’t exist or has been deleted
- Incorrect API key format
- Missing or malformed Authorization header
- Verify your API key is correct and active
- Check the Authorization header format:
Bearer spj_ai_... - Generate a new API key if necessary
Insufficient Permissions (403)
Token Limit Exceeded (403)
- Wait for your monthly token reset
- Upgrade your subscription plan
- Optimize prompts to reduce token usage
Environment Variables Best Practices
Local Development
Create a.env file for local development:
Production Deployment
Set environment variables in your deployment platform:- Vercel
- Netlify
- Heroku
- AWS Lambda

