API Authentication
The Kinbox API uses Bearer token authentication to identify and authorize API requests. This guide explains how to obtain your API token, use it in requests, and follow security best practices.Overview
Kinbox uses API tokens to authenticate requests. Your API token carries the same permissions as the operator (user) who generated it, so it’s crucial to keep it secure and treat it like a password.Getting Your API Token
Follow these steps to obtain your API token from the Kinbox platform:Access your Kinbox account
Log in to your Kinbox account at app.kinbox.com.br
Navigate to API settings
Go to Settings > Integrations > APIDirect link: https://app.kinbox.com.br/settings/integrations/apps
Using Your API Token
Once you have your token, include it in theAuthorization header of all API requests using the Bearer authentication scheme.
Request Format
Authentication Header Format
The authorization header must follow this exact format:- Include the word “Bearer” followed by a space
- Then add your complete API token
- No quotes or additional characters
Token Permissions
Your API token inherits all permissions from the operator account that generated it. This means:Permission Inheritance: If the operator doesn’t have permission to create contacts, the API token won’t be able to create contacts either.
Common Permission Examples
| Action | Required Permission |
|---|---|
| View conversations | Read conversations |
| Send messages | Send messages |
| Create contacts | Create/edit contacts |
| Manage deals | Access CRM |
| View reports | View reports |
| Manage team members | Admin access |
Security Best Practices
Follow these security guidelines to protect your API token and account:1. Use HTTPS Only
Always connect to the Kinbox API using HTTPS. Never send your token over an unencrypted connection.Good ✓
Bad ✗
2. Store Tokens Securely
Never hardcode tokens in your source code. Use environment variables or secure configuration management:3. Rotate Tokens Regularly
For enhanced security, regenerate your API tokens periodically:- Every 90 days for production environments
- Immediately if you suspect a token has been compromised
- When team members with token access leave your organization
4. Use Different Tokens for Different Environments
Create separate Kinbox workspaces and tokens for:- Development: For testing and development
- Staging: For pre-production testing
- Production: For live operations
5. Never Expose Tokens Client-Side
Instead, proxy API requests through your backend server:Client → Your Backend → Kinbox API
6. Monitor API Usage
Regularly review your API usage in the Kinbox dashboard:- Go to Settings > Integrations > API
- Check the API Logs section
- Look for unusual patterns or unauthorized access
7. Implement Rate Limiting
Implement rate limiting in your application to avoid hitting API limits:Rate Limiting Example
Error Handling
Properly handle authentication errors in your application:Common Authentication Errors
| Status Code | Error | Cause | Solution |
|---|---|---|---|
| 401 | Unauthorized | Missing or invalid token | Check token format and validity |
| 403 | Forbidden | Insufficient permissions | Verify operator permissions |
| 429 | Too Many Requests | Rate limit exceeded | Implement backoff strategy |
Example Error Response
Handling Authentication Errors
Testing Your Authentication
Verify your authentication is working correctly:Next Steps
Now that you understand authentication, explore the Kinbox API:List Contacts
Retrieve and manage contact information
Get Conversations
Access conversation data and history
Manage Campaigns
Create and manage bulk messaging campaigns
Webhooks
Receive real-time notifications for events
Need Help?
If you encounter authentication issues:- Check that your token is correctly copied (no extra spaces)
- Verify you’re using HTTPS, not HTTP
- Ensure the operator who generated the token has the required permissions
- Try regenerating your token
- Contact support at [email protected]