Skip to main content

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

  1. Log in to app.smartbills.io
  2. Click your profile icon (top right)
  3. Select Settings
  4. Navigate to DeveloperAPI Keys
2

Create New Key

  1. Click Create New API Key
  2. Enter a descriptive name for the key
    • Example: “Production Server”
    • Example: “Development Environment”
    • Example: “Mobile App Integration”
  3. (Optional) Set an expiration date
  4. (Optional) Restrict to specific IP addresses
  5. Click Generate Key
3

Copy Your Key

  1. Your API key will be displayed once
  2. Copy it immediately to a secure location
  3. Store it in your password manager or environment variables
  4. Click I’ve saved my key to confirm
Important: API keys are only shown once at creation. If you lose a key, you must delete it and create a new one.

API Key Types

Smartbills provides two types of API keys for different environments:

Test Keys

Use for:
  • Development and testing
  • Staging environments
  • Integration testing
  • Learning the API
Characteristics:
  • Prefix: sk_test_
  • Separate test data
  • Higher rate limits for testing
  • No real charges or transactions
  • Safe to share with your development team
Test keys are perfect for development. They work with all endpoints but operate on separate test data.

Live Keys

Use for:
  • Production environments
  • Live applications
  • Real expense processing
  • Production integrations
Characteristics:
  • Prefix: sk_live_
  • Real production data
  • Standard rate limits
  • Processes real expenses
  • Must be kept highly secure
Security: Never commit live keys to version control or expose them in client-side code.

Using API Keys

Authentication Header

Include your API key in the Authorization header of every request:

Complete Example

Managing API Keys

View All Keys

See all your API keys in the dashboard:
  1. Navigate to SettingsDeveloperAPI Keys
  2. 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:
  1. Find the key in your API keys list
  2. Click Edit or the pencil icon
  3. Enter a new name
  4. Click Save
Naming convention: Use descriptive names that indicate the key’s purpose and environment, like “Production-WebApp-v2” or “Dev-Mobile-Testing”.

Revoke a Key

Immediately disable an API key:
  1. Navigate to your API keys list
  2. Find the key to revoke
  3. Click Revoke or the trash icon
  4. Confirm the action
Immediate effect: Revoking a key immediately stops all requests using that key. Ensure you have a replacement key in place first.
When to revoke:
  • 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 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 to ensure everything works
3

Monitor

Watch for any requests still using the old key Check “Last Used” timestamp on the old key
4

Revoke Old Key

Once confident the new key is working, revoke the old one This ensures no requests slip through
Rotation schedule: Rotate API keys every 90 days for production environments, or whenever team members with access change.

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

read:businesses - View business information
  • List businesses
  • Get business details
  • View business settings
write:businesses - Create and modify businesses
  • Create new businesses
  • Update business information
  • Modify business settings
delete:businesses - Remove businesses
  • Delete businesses (with confirmation)
read:expenses - View expenses
  • List all expenses
  • Get expense details
  • Download attachments
  • Export expense data
write:expenses - Create and modify expenses
  • Upload new expenses
  • Update expense information
  • Add/remove attachments
  • Categorize expenses
delete:expenses - Remove expenses
  • Delete individual expenses
  • Bulk delete operations
read:reports - View expense reports
  • List reports
  • Get report details
  • View report timeline
  • Access audit logs
write:reports - Create and modify reports
  • Create new reports
  • Update report details
  • Add/remove expenses
  • Submit reports
approve:reports - Approval permissions
  • Approve reports
  • Reject reports
  • Require changes
  • Add comments
read:user - View user information
  • Get own user details
  • View user settings
write:user - Modify user information
  • Update profile
  • Change settings
manage:users - Manage team members (admin only)
  • Invite users
  • Remove users
  • Update permissions

Security Best Practices

Do’s ✅

1

Store in Environment Variables

2

Use Different Keys per Environment

  • Development: test key
  • Staging: separate test key
  • Production: live key
Never use the same key across environments.
3

Rotate Regularly

Set a calendar reminder to rotate keys every 90 days.
4

Use HTTPS Only

Always make API requests over HTTPS to encrypt your key in transit.
5

Implement IP Restrictions

Restrict keys to specific IP addresses when possible.
6

Set Expiration Dates

For temporary integrations or testing, set keys to auto-expire.
7

Monitor Usage

Regularly review which keys are being used and when.

Don’ts ❌

Never do these:
  • ❌ Commit API keys to version control (Git, SVN, etc.)
  • ❌ Expose keys in client-side code (JavaScript, mobile apps)
  • ❌ Share keys in emails, Slack, or other messaging
  • ❌ Hardcode keys in source code
  • ❌ Use production keys in development
  • ❌ Store keys in unencrypted files
  • ❌ Include keys in URLs or query parameters
  • ❌ Log API keys in application logs

Accidental Exposure

If you accidentally expose an API key:
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].

Advanced Features

IP Address Restrictions

Limit API key usage to specific IP addresses:
  1. Edit your API key
  2. Click Add IP Restriction
  3. Enter allowed IP addresses (one per line)
  4. Supports both IPv4 and IPv6
  5. Use CIDR notation for ranges: 192.168.1.0/24
  6. Click Save
Production tip: For production servers, always restrict to your server’s IP addresses.

Key Expiration

Set automatic expiration dates:
  1. When creating or editing a key
  2. Enable Set Expiration Date
  3. Choose expiration date and time
  4. Key will automatically be revoked after this time
Use cases:
  • 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
See Rate Limits for details.

Troubleshooting

Possible causes:
  1. Missing Authorization header
  2. Incorrect format
    • Include “Bearer ” prefix
    • No extra spaces
    • Full key string
  3. Revoked or expired key
    • Check if key is still active
    • Create a new key if needed
  4. Wrong key type
    • Ensure using live key for production
    • Test key for testing environments
Reasons:
  1. Insufficient permissions
    • Your user account lacks necessary permissions
    • Contact your administrator
  2. IP restriction
    • Request from unauthorized IP
    • Check IP restrictions on the key
  3. Business access
    • Trying to access a business you’re not a member of
    • Verify businessId parameter
Possible issues:
  1. Reached key limit
    • Free plan: 2 keys max
    • Professional: 10 keys max
    • Enterprise: Unlimited
    Solution: Delete unused keys or upgrade plan
  2. Insufficient permissions
    • Only account owners and admins can create API keys
    • Request access from your administrator
What to do:API keys cannot be retrieved after creation. You must:
  1. Revoke the lost key (for security)
  2. Create a new API key
  3. Update your application with the new key
  4. Test thoroughly
For security reasons, Smartbills never stores the full API key after creation.

Testing API Keys

Verify Your Key Works

Quick test to verify your API key:
Expected response (success):
Expected response (error):

Test Environment

Use test keys in development:
  1. Create a test API key
  2. Set it in your development environment
  3. Run your integration tests
  4. Verify all functionality works
  5. Switch to live key only for production

Migration Guide

Moving from Test to Production

1

Create Live Key

Generate a live API key from your dashboard.
2

Update Environment Variables

3

Update Base URL (if different)

Ensure you’re pointing to production endpoint:
4

Test Thoroughly

Run integration tests in staging with live key before going to production.
5

Deploy

Deploy your application with the live key.
6

Monitor

Watch logs and error rates closely after deployment.

Authentication Guide

Complete authentication documentation

Rate Limits

Understand API rate limiting

Error Handling

Handle API errors effectively

Webhooks

Set up webhook authentication

Need Help?