Learn how to authenticate your requests to the SmartBills API.
Learn how to authenticate your requests to the SmartBills API.
The SmartBills API uses API keys for authentication. Include your API key in the Authorization
header of every request:
Authorization: Bearer YOUR_API_KEY
Your API key carries many privileges, so be sure to keep it secure! Do not share your API key in publicly accessible areas such as GitHub, client-side code, and so forth.
We recommend using different API keys for different environments:
curl -X GET https://api.smartbills.com/v1/invoices \
-H "Authorization: Bearer sk_live_abcd1234..."
const SmartBills = require('@smartbills/sdk');
const client = new SmartBills('sk_live_abcd1234...');
import smartbills
client = smartbills.Client('sk_live_abcd1234...')
SmartBills uses different key prefixes to identify the key type:
Prefix | Environment | Description |
---|---|---|
sk_test_ | Test | For development and testing |
sk_live_ | Live | For production use |
Store your API keys in environment variables, not in your code:
# .env file
SMARTBILLS_API_KEY=sk_live_abcd1234...
const client = new SmartBills(process.env.SMARTBILLS_API_KEY);
When creating API keys, you can restrict them to:
Webhooks use a different authentication method. See the Webhooks documentation for details on webhook signature verification.
401 Unauthorized
Bearer
prefix403 Forbidden
Invalid API Key Format
sk_test_
or sk_live_