Overview
API keys are the primary method of authenticating with the Smartbills API. Each key is tied to your user account and inherits your permissions. This guide covers everything you need to know about creating, using, and managing API keys securely.Creating API Keys
Generate Your First API Key
Navigate to API Keys
- Log in to app.smartbills.io
- Click your profile icon (top right)
- Select Settings
- Navigate to Developer → API Keys
Create New Key
- Click Create New API Key
- Enter a descriptive name for the key
- Example: “Production Server”
- Example: “Development Environment”
- Example: “Mobile App Integration”
- (Optional) Set an expiration date
- (Optional) Restrict to specific IP addresses
- Click Generate Key
Copy Your Key
- Your API key will be displayed once
- Copy it immediately to a secure location
- Store it in your password manager or environment variables
- Click I’ve saved my key to confirm
API Key Types
Smartbills provides two types of API keys for different environments:Test Keys
- Development and testing
- Staging environments
- Integration testing
- Learning the API
- Prefix:
sk_test_ - Separate test data
- Higher rate limits for testing
- No real charges or transactions
- Safe to share with your development team
Live Keys
- Production environments
- Live applications
- Real expense processing
- Production integrations
- Prefix:
sk_live_ - Real production data
- Standard rate limits
- Processes real expenses
- Must be kept highly secure
Using API Keys
Authentication Header
Include your API key in theAuthorization header of every request:
Complete Example
Managing API Keys
View All Keys
See all your API keys in the dashboard:- Navigate to Settings → Developer → API Keys
- View list of all active keys with:
- Key name
- Key prefix (first/last 4 characters)
- Creation date
- Last used timestamp
- Expiration date (if set)
Rename a Key
Update the name for better organization:- Find the key in your API keys list
- Click Edit or the pencil icon
- Enter a new name
- Click Save
Revoke a Key
Immediately disable an API key:- Navigate to your API keys list
- Find the key to revoke
- Click Revoke or the trash icon
- Confirm the action
- Key has been compromised or exposed
- Employee with access has left
- Migrating to a new key
- No longer using an integration
- Suspected unauthorized use
Rotate Keys
Best practice: Rotate keys regularlyCreate New Key
Update Your Application
Monitor
Revoke Old Key
Key Permissions & Scopes
Permission Inheritance
API keys inherit the permissions of the user who created them. If you have access to multiple businesses, your key will work with all of them.Available Scopes
Business Scopes
Business Scopes
- List businesses
- Get business details
- View business settings
- Create new businesses
- Update business information
- Modify business settings
- Delete businesses (with confirmation)
Expense Scopes
Expense Scopes
- List all expenses
- Get expense details
- Download attachments
- Export expense data
- Upload new expenses
- Update expense information
- Add/remove attachments
- Categorize expenses
- Delete individual expenses
- Bulk delete operations
Report Scopes
Report Scopes
- List reports
- Get report details
- View report timeline
- Access audit logs
- Create new reports
- Update report details
- Add/remove expenses
- Submit reports
- Approve reports
- Reject reports
- Require changes
- Add comments
User Scopes
User Scopes
- Get own user details
- View user settings
- Update profile
- Change settings
- Invite users
- Remove users
- Update permissions
Security Best Practices
Do’s ✅
Store in Environment Variables
Use Different Keys per Environment
- Development: test key
- Staging: separate test key
- Production: live key
Rotate Regularly
Use HTTPS Only
Implement IP Restrictions
Set Expiration Dates
Monitor Usage
Don’ts ❌
Accidental Exposure
If you accidentally expose an API key:Revoke Immediately
Generate New Key
Update Your Application
Review Usage
Contact Support
Advanced Features
IP Address Restrictions
Limit API key usage to specific IP addresses:- Edit your API key
- Click Add IP Restriction
- Enter allowed IP addresses (one per line)
- Supports both IPv4 and IPv6
- Use CIDR notation for ranges:
192.168.1.0/24 - Click Save
Key Expiration
Set automatic expiration dates:- When creating or editing a key
- Enable Set Expiration Date
- Choose expiration date and time
- Key will automatically be revoked after this time
- Temporary contractor access
- Time-limited integrations
- Testing periods
- Project-based access
Rate Limits per Key
Each API key has its own rate limit tracking:- View current usage in API keys dashboard
- Track requests per hour/day
- Monitor against your plan limits
- Alerts when approaching limits
Troubleshooting
403 Forbidden Error
403 Forbidden Error
-
Insufficient permissions
- Your user account lacks necessary permissions
- Contact your administrator
-
IP restriction
- Request from unauthorized IP
- Check IP restrictions on the key
-
Business access
- Trying to access a business you’re not a member of
- Verify businessId parameter
Can't create API key
Can't create API key
-
Reached key limit
- Free plan: 2 keys max
- Professional: 10 keys max
- Enterprise: Unlimited
-
Insufficient permissions
- Only account owners and admins can create API keys
- Request access from your administrator
Lost my API key
Lost my API key
- Revoke the lost key (for security)
- Create a new API key
- Update your application with the new key
- Test thoroughly
Testing API Keys
Verify Your Key Works
Quick test to verify your API key:Test Environment
Use test keys in development:- Create a test API key
- Set it in your development environment
- Run your integration tests
- Verify all functionality works
- Switch to live key only for production
Migration Guide
Moving from Test to Production
Create Live Key
Update Environment Variables
Update Base URL (if different)
Test Thoroughly
Deploy
Monitor
Related Resources
Authentication Guide
Rate Limits
Error Handling
Webhooks
Need Help?
- Security Issues: [email protected]
- General Support: [email protected]
- Documentation: docs.smartbills.io
- Community: community.smartbills.io