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.API keys are powerful: They provide full access to your account via the API. Treat them like passwords and never share them publicly.
Creating API Keys
Generate Your First API Key
1
Navigate to API Keys
- Log in to app.smartbills.io
- Click your profile icon (top right)
- Select Settings
- Navigate to Developer > API Keys
2
Create New Key
- Click Create New API Key
- Enter a descriptive name for the key (e.g., “Production Server”, “Development Environment”)
- (Optional) Set an expiration date
- (Optional) Restrict to specific IP addresses
- Click Generate Key
3
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_ - Operates on 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
Key Permissions and 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 via thex-tenant-id header.
Available Scopes
Scopes follow aresource.action format. The complete, authoritative list is published at
/auth/.well-known/openid-configuration
under scopes_supported.
Business Scopes
Business Scopes
businesses.read - View business information, list businesses, get business detailsbusinesses.write - Create new businesses, update business information, modify settings
Expense Scopes
Expense Scopes
expenses.read - List expenses, get expense details, download attachments, export dataexpenses.write - Upload expenses, update expense information, add or remove attachments, categorize expensesreceipts.read / receipts.write - Access and modify the underlying receipts
Expense Report Scopes
Expense Report Scopes
expense-reports.read - List reports, get report details, view report timelineexpense-reports.write - Create reports, update report details, add or remove expensesexpense-reports.submit - Submit reports for approvalexpense-reports.approve / expense-reports.reject - Act on reports awaiting your approvalexpense-reports.reimburse - Mark reports as reimbursed
Accounts Payable Scopes
Accounts Payable Scopes
bills.read / bills.write - Access and modify billsvendors.read / vendors.write - Access and modify vendors
Identity Scopes
Identity Scopes
openid - Required for any OpenID Connect flowprofile, email, phone, address, full_name - Claims about the signed-in useroffline_access - Issue a refresh token alongside the access token
Platform Scopes
Platform Scopes
webhooks.read / webhooks.write - Manage webhook endpointsdevelopers.read / developers.write - Manage developer settingsnotifications.read / notifications.write - Access and manage notifications
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)
Revoking Keys
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 the organization
- Migrating to a new key
- No longer using an integration
- Suspected unauthorized use
Rotating Keys
Best practice: rotate keys regularly.1
Create New Key
Generate a new API key with the same permissions.
2
Update Your Application
Replace the old key with the new one in your application. Test thoroughly.
3
Monitor
Watch for any requests still using the old key. Check the “Last Used” timestamp.
4
Revoke Old Key
Once confident the new key is working, revoke the old one.
Security Best Practices
Store in Environment Variables
Use Different Keys per Environment
- Development: test key (
sk_test_...) - Staging: separate test key
- Production: live key (
sk_live_...)
What to Avoid
If a Key Is Exposed
1
Revoke Immediately
Go to Settings > API Keys and revoke the exposed key right away.
2
Generate New Key
Create a replacement key immediately.
3
Update Your Application
Replace the exposed key in your application.
4
Review Usage
Check the “Last Used” timestamp and recent activity for suspicious requests.
5
Contact Support
If you suspect unauthorized use, contact [email protected].
Troubleshooting
403 Forbidden Error
403 Forbidden Error
Possible causes:
- Insufficient permissions - Your user account lacks necessary permissions
- IP restriction - Request from an unauthorized IP address
- Business access - Trying to access a business you are not a member of
Cannot Create API Key
Cannot Create API Key
Possible causes:
- 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
Related Resources
Authentication
Complete authentication documentation
Environments
Sandbox and production environments
Rate Limits
Understand API rate limiting
Error Handling
Handle API errors effectively