API Keys
API keys enable programmatic access to your botBrains projects, allowing you to build custom integrations, automate workflows, and embed AI capabilities directly into your applications. Each API key can be scoped with specific permissions to ensure secure, controlled access to exactly the resources and operations your integration needs.Why API Keys Matter
API keys unlock powerful automation and integration capabilities that extend botBrains beyond the dashboard:Build Custom Integrations
Connect botBrains to your existing tools and workflows. Use the API to sync customer data from your CRM, trigger AI responses from your application backend, or integrate conversation analytics into your business intelligence platform.Automate Operations
Programmatically manage knowledge sources, create conversations, and monitor AI performance without manual dashboard access. Schedule scripts to update data providers, export analytics reports, or sync user attributes from your authentication system.Embed AI Capabilities
Power your application’s features with botBrains AI. Generate responses to user questions, retrieve knowledge snippets, or analyze conversation sentiment - all from your own codebase. Your users never need to know botBrains is powering their experience.Secure Third-Party Access
Grant controlled access to external systems, contractors, or partners without sharing login credentials. API keys provide granular permission control and can be revoked instantly if compromised or no longer needed.Support CI/CD Workflows
Integrate botBrains into your deployment pipeline. Use API keys in GitHub Actions, Jenkins, or other automation tools to update knowledge bases when documentation changes, test AI responses, or validate configurations before production deployment.How API Keys Work
Authentication and Security
API keys authenticate requests to the botBrains API using a bearer token scheme:Example API Request
- Prefix (
sk_live_orsk_test_) - Indicates environment and key type - Secret - A cryptographically secure random string (43 characters)
- Permissions - Specific operations this key can perform
Permission-Based Access Control
Unlike login credentials that grant full access, API keys use granular permissions to limit what operations they can perform. When you create an API key, you select exactly which actions it should be allowed to execute. Principle of Least Privilege: Grant only the minimum permissions required for your use case. If you’re building a read-only analytics dashboard, your API key only needs read permissions - not write or delete capabilities.Project-Level Scope
API keys are scoped to a specific project. An API key created in your “Production Support Bot” project cannot access conversations, knowledge, or any other resources from your “Sales Bot” project. This isolation ensures security and prevents accidental cross-project operations. To access multiple projects programmatically, create separate API keys in each project with appropriate permissions for that specific use case.Creating API Keys
Generate new API keys from your project’s settings:1
Navigate to API Keys
Go to Project → Settings → API Keys in your project
2
Create New Key
Click Create API Key to open the creation dialog
3
Name Your Key
Enter a descriptive name indicating the key’s purpose (e.g., “GitHub Actions CI”, “Analytics Dashboard”, “CRM Sync Script”)
4
Select Permissions
Choose the specific permissions this key needs (see Permission Reference below)
5
Generate and Copy
Click Create Key and immediately copy the secret - you won’t see it again
6
Store Securely
Save the key in your password manager, environment variables, or secrets management system
First-Time Secret Display
When you create an API key, botBrains displays the full secret exactly once in a dialog:- Never stored in plain text
- Never displayed again after initial creation
- Masked in the API keys table (shown as
•••••••••••) - Can be viewed later (requires explicit action) but should be rotated if exposed
Managing Existing Keys
View Your API Keys
The API Keys page displays all keys for your project in a table showing: Name - The descriptive name you provided when creating the key Secret - Masked by default (•••••••••••••••••••••••••••••••••••••••••). Click the eye icon to reveal the full secret, or click the copy icon to copy it directly to your clipboard without revealing it.
Permissions - All permissions granted to this key, displayed as badges (e.g., project:read, conversation:read, knowledge:write)
Actions - Edit or delete buttons for managing the key
Secret Visibility: The full secret can be retrieved after creation by clicking the eye icon, but this requires your authentication. Treat any revealed secret as potentially compromised and consider rotating the key if it was displayed in an insecure environment.
Edit Key Permissions
You can modify a key’s permissions at any time without regenerating the secret:1
Click Edit Icon
Find the key in your API Keys table and click the edit (pencil) icon
2
Update Permissions
Add or remove permissions using the permission picker
3
Save Changes
Click Update Permissions - changes take effect immediately
- Grant additional access as your integration evolves
- Remove permissions that are no longer needed (permission reduction)
- Temporarily elevate access for troubleshooting, then reduce
- Align permissions with updated role requirements
Delete API Keys
Remove API keys that are no longer needed or have been compromised:- Find the key in the API Keys table
- Click the delete (trash) icon
- Confirm deletion
- All requests using this key will fail immediately with 401 Unauthorized
- The key cannot be recovered - you’ll need to create a new one
- Any running scripts or integrations will stop working
- When decommissioning an integration or script
- If a key is exposed or compromised
- When a team member leaves who had access to the key
- During security audits to remove unused keys
- After migrating to a new key as part of rotation
Permission Reference
API key permissions map directly to the permission system used for user roles. Each permission grants access to specific operations within a functional area.Core Permissions Structure
Permissions follow aresource:action naming pattern:
resource- The functional area (e.g., knowledge, conversation, deployment)action- The operation type (typically read, write, create, update, delete)
knowledge:write automatically includes knowledge:read. The UI handles these dependencies when you select permissions.
Common Permission Patterns
Read-Only Access
For analytics dashboards, reporting scripts, or monitoring tools:Knowledge Management
For content sync scripts, documentation updates, or CRM data imports:Full Conversation Access
For custom support interfaces, chatbot integrations, or conversation management tools:Complete Permission List
You can find the up to date permission list in the Roles an Permissions documentation: Roles and Permissions.Organization vs Project Permissions: API keys only support project-level permissions. Organization-level operations (billing, team management, organization settings) cannot be performed via API keys and require authenticated user sessions.
Using API Keys
Environment Variables
Store API keys in environment variables, never hardcode them in source files:Client Libraries
Use official or community client libraries for type-safe, convenient API access:Common Integration Patterns
Sync User Data from CRM
Keep botBrains user profiles synchronized with your CRM:CRM Sync Script
userpool:read, userpool:update
Update Knowledge When Docs Change
Automatically sync knowledge base when documentation is updated:GitHub Actions Workflow
knowledge:read, knowledge:write
Export Analytics for BI Tools
Pull conversation analytics into your business intelligence platform:Analytics Export
metric:read, conversation:read, export:read
Generate AI Responses in Your App
Embed botBrains AI directly in your application:Custom Support Interface
conversation:read, conversation:generate, userpool:read
Rate Limits
API keys are subject to rate limits to ensure platform stability and fair usage:Current Limits
- Standard Plan: 100 requests per minute, 10,000 per day
- Professional Plan: 300 requests per minute, 50,000 per day
- Enterprise Plan: Custom limits based on agreement
Rate Limit Headers
Every API response includes rate limit information:- X-RateLimit-Limit - Maximum requests allowed per minute
- X-RateLimit-Remaining - Requests remaining in current window
- X-RateLimit-Reset - Unix timestamp when limit resets
Handling Rate Limits
When you exceed the rate limit, the API returns 429 Too Many Requests:Rate Limit Handling
Best Practices
Rotate Keys Regularly
Implement a key rotation schedule to minimize exposure risk: Recommended Rotation Schedule:- Production keys: Every 90 days
- Development keys: Every 180 days
- Contractor/partner keys: When access ends or every 30 days
- Compromised keys: Immediately
1
Generate New Key
Create a new API key with identical permissions
2
Update Systems
Deploy the new key to all systems using the old key (update environment variables, secrets managers, CI/CD configs)
3
Monitor
Watch for errors indicating systems still using the old key
4
Delete Old Key
After confirming all systems migrated (typically 24-48 hours), delete the old key
Use Separate Keys per Integration
Create dedicated API keys for each integration or use case: Why This Matters:- Easier Auditing - Track which integration is making which requests
- Simpler Revocation - Decommission one integration without affecting others
- Granular Permissions - Grant only what each integration needs
- Clearer Naming - “CRM Sync” vs “Analytics Export” vs “CI Pipeline”
Secure Storage
Never expose API keys in insecure locations: Secure Storage Options: Environment Variables - For local development and simple deployments- AWS Secrets Manager
- Google Secret Manager
- Azure Key Vault
- HashiCorp Vault
- GitHub Secrets
- GitLab CI/CD Variables
- CircleCI Environment Variables
- Jenkins Credentials
- 1Password
- LastPass
- Bitwarden
Monitor Key Usage
Track API key activity to detect anomalies: What to Monitor:- Unusual request volumes (sudden spikes may indicate compromise)
- Failed authentication attempts (wrong key being used)
- Permission errors (integration trying unauthorized actions)
- Geographic anomalies (requests from unexpected locations)
- Off-hours activity (requests when systems should be idle)
Environment Separation
Use different API keys for different environments:- Prevent production data exposure in development
- Enable testing without affecting real users
- Simplify troubleshooting (clear separation of logs)
- Reduce risk of accidental production modifications
Respond to Compromises Quickly
If an API key is exposed or compromised:1
Immediate Revocation
Delete the compromised key immediately from the API Keys page
2
Generate Replacement
Create a new key with the same permissions but a new secret
3
Update Systems
Deploy the new key to all systems that were using the old one
4
Audit Activity
Review API logs to determine what actions were taken with the compromised key
5
Assess Impact
Check if any unauthorized data access or modifications occurred
6
Notify if Necessary
If customer data was accessed, follow your incident response procedures
- Committed to public GitHub repository
- Posted in public Slack channel or forum
- Included in screenshot or screen share
- Accidentally logged to monitoring service
- Left in developer laptop that was lost/stolen
Troubleshooting
401 Unauthorized Errors
Symptom: API requests return401 Unauthorized
Possible Causes:
- Invalid API key - Key was deleted or never existed
- Incorrect format - Missing “Bearer” prefix or malformed key
- Wrong environment - Using test key in production or vice versa
403 Forbidden Errors
Symptom: API requests return403 Forbidden or “Insufficient permissions”
Possible Causes:
- Missing permission - Key doesn’t have required permission for the operation
- Wrong project - Using key from Project A to access Project B resources
- Permission recently removed - Key permissions were updated
- Review the permission requirements for the endpoint you’re calling
- Check key permissions in the API Keys dashboard
- Verify you’re using the correct project ID in the request
- Update key permissions if your integration needs changed
Rate Limit Exceeded
Symptom: Getting429 Too Many Requests responses
Solutions:
- Implement exponential backoff (see Rate Limits section)
- Reduce request frequency
- Cache responses when appropriate
- Use batch endpoints instead of individual requests
- Consider upgrading to a higher-tier plan
Key Not Working After Creation
Symptom: Newly created key returns 401 errors Solutions:- Verify you copied the complete secret from the creation dialog
- Check for whitespace or newline characters in your stored key
- Ensure you’re using the key in the correct project
- Wait 1-2 minutes - keys may take a moment to propagate
Can’t View Full Secret
Symptom: Need to retrieve API key secret but only see masked version Solutions:- Click the eye icon to reveal the full secret (requires authentication)
- If secret was compromised during reveal, rotate the key
- If you lost the secret and can’t retrieve it securely, create a new key
Permission Errors After Updating Key
Symptom: Integration stopped working after modifying key permissions Solutions:- Review what permissions were removed
- Check application logs for specific permission error messages
- Add back required permissions or update integration to not use removed capabilities
- Consider creating a new key with correct permissions instead of modifying
Security Considerations
Scope Keys Appropriately
Grant the minimum permissions required: Bad Practice:Never Use in Client-Side Code
API keys must only be used in server-side code: Why: Anyone can inspect client-side code and extract the API key. Instead, create a backend API that uses the key server-side. Safe Pattern:Audit Key Usage
Regularly review which keys exist and what they’re used for: Quarterly Audit Checklist:- List all active API keys
- Verify each key is still needed
- Confirm permissions are still appropriate
- Check key names are descriptive and accurate
- Delete keys for decommissioned integrations
- Rotate keys that haven’t been rotated in 90+ days
- Review API logs for unusual patterns
Compliance Considerations
API keys and data export permissions have compliance implications: GDPR/Privacy Regulations:- Keys with
full_export:readcan access PII - restrict carefully - Document which systems have API access to customer data
- Include API integrations in your data processing records
- Ensure third-party API key holders have data processing agreements
- Maintain inventory of all API keys and their permissions
- Document key rotation procedures
- Implement monitoring and alerting for key usage
- Include API keys in security incident response plans
Next Steps
Now that you understand API key management, explore related topics:- Roles and Permissions - User access control system
- Triggers - Automate actions with event-based webhooks
- Data Export - Export conversation data programmatically
- Team Management - Manage team member access