API Key Scopes Reference
API key scopes control what operations your API key can perform. Use minimal scopes for security.
Scope Format
Scopes follow the format: {resource}.{capability}
Example: product.read, order.write
All Available Scopes
Products
product.read— List and view productsproduct.write— Create and update productsproduct.delete— Delete products
Orders
order.read— View orders (read-only in v1.7)
Note: order.write and order.delete scopes are deprecated as orders are now created exclusively via payment provider webhooks.
Customers
customer.read— List and view customerscustomer.write— Create and update customerscustomer.delete— Delete customers
Categories
category.read— View categoriescategory.write— Create and update categoriescategory.delete— Delete categories
Pages
page.read— View pagespage.write— Create and update pagespage.delete— Delete pages
Media
media.read— List and view media filesmedia.write— Upload mediamedia.delete— Delete media files
Webhooks
webhook.read— View webhook subscriptionswebhook.write— Create and update webhook subscriptionswebhook.delete— Delete webhook subscriptions
API Keys
apiKey.read— View API keys (shows prefix only, never full key)apiKey.write— Create API keysapiKey.delete— Revoke API keys
Audit Logs
auditLog.read— View audit log entries
Recommended Scope Combinations
Public Storefront
For a headless storefront fetching products and creating orders:
product.read
category.read
customer.writeWhy:
product.read- Display productscategory.read- Show categoriescustomer.write- Create customers from signup
Inventory Sync
For syncing products from an external system:
product.read
product.write
media.writeWhy:
product.read- Fetch existing productsproduct.write- Create/update productsmedia.write- Upload product images
Order Fulfillment
For reading orders to ship:
order.read
customer.readWhy:
order.read- View orders to fulfillcustomer.read- Get customer details for shipping label
Analytics Integration
For syncing data to analytics:
order.read
product.read
customer.readWhy:
order.read- Fetch ordersproduct.read- Fetch productscustomer.read- Fetch customers
Full Store Management
For a management dashboard with all operations:
product.read
product.write
product.delete
order.read
customer.read
customer.write
customer.delete
category.read
category.write
category.delete
page.read
page.write
page.delete
media.read
media.write
media.delete
webhook.read
webhook.write
webhook.delete
auditLog.read
apiKey.readCreating an API Key with Scopes
Via Dashboard
- Go to Settings → API Keys
- Click Create New Key
- Enter a name (e.g., "Inventory Sync")
- Check the scopes you need
- Click Create
- Copy the full key (shown only once)
Principle of Least Privilege
Always use the minimum scopes needed:
❌ WRONG - Over-permissive
apiKey with: product.*, order.*, customer.*, webhook.*, ...
✅ CORRECT - Minimal scopes
apiKey with: product.read, category.read
✅ CORRECT - Specific to use case
apiKey for inventory sync: product.read, product.write, media.write
apiKey for storefront: product.read, customer.write
apiKey for order fulfillment: order.read, customer.readChecking Key Permissions
API keys are stored as hashes, so you can never see the full key again. To manage keys:
- Go to Settings → API Keys
- You'll see the prefix (first 12 chars) and creation date
- Click to see:
- Scope list
- Last used date
- Creation date
Revoking Keys
To revoke a key immediately:
- Go to Settings → API Keys
- Find the key (by prefix)
- Click Delete
- The key is revoked instantly (no requests will work)
Note: This is permanent. The revoked key cannot be recovered.
Rotating Keys
Best practice: Rotate API keys periodically.
1. Create new key with same scopes as old key
2. Update your app to use new key
3. Test that everything works
4. Revoke old key
5. Monitor logs for any failuresKey Security Tips
✅ DO:
- Store keys in environment variables (
.env, secrets manager) - Use minimal scopes for each key
- Rotate keys every 90 days
- Create separate keys for different integrations
- Monitor "Last Used" dates for unused keys
- Revoke keys immediately if compromised
❌ DON'T:
- Commit keys to Git
- Share keys in Slack/email
- Use one key for everything
- Store keys in client-side code
- Use placeholder/demo keys in production
Using Scopes in Requests
When you make API requests with your key, scopes are automatically checked:
# This works if your key has product.read
curl https://api.barecommercecore.com/api/stores/{storeId}/products \
-H "X-API-Key: sk_live_your_key"
# This fails if your key doesn't have product.write
curl -X POST https://api.barecommercecore.com/api/stores/{storeId}/products \
-H "X-API-Key: sk_live_your_key" \
-d '{"title": "New Product", ...}'
# Error: FORBIDDEN - Insufficient permissionsError: "FORBIDDEN - Insufficient permissions"
If you get this error:
- Check which scope the endpoint needs (see endpoint documentation)
- Get your API key prefix (first 12 chars of your key)
- Go to Settings → API Keys
- Click your key to view its scopes
- Either:
- Add the missing scope (edit key), OR
- Create a new key with the required scope