API Keys
The Bila API uses API keys to authenticate requests. You can view and manage your API keys in the merchant dashboard.Key Types
| Key Type | Prefix | Environment | Description |
|---|---|---|---|
| Live Secret Key | sk_live_ | Production | Use for live transactions |
| Test Secret Key | sk_test_ | Sandbox | Use for testing and development |
Making Authenticated Requests
Include your API key in thex-api-key header with every request:
Authentication Errors
If authentication fails, you’ll receive a401 Unauthorized response:
Common Authentication Issues
| Error | Cause | Solution |
|---|---|---|
| Missing API key | No x-api-key header | Add the header to your request |
| Invalid API key | Key doesn’t exist or is malformed | Check your key in the dashboard |
| Expired API key | Key has been revoked | Generate a new key |
| Wrong environment | Using test key in production | Use the correct key type |
Best Practices
Store keys securely
Store keys securely
Use environment variables or a secrets manager to store your API keys. Never hardcode them in your source code.
Use different keys for different environments
Use different keys for different environments
Use test keys (
sk_test_) for development and live keys (sk_live_) for production.Rotate keys periodically
Rotate keys periodically
Regularly rotate your API keys as a security best practice.
Restrict key permissions
Restrict key permissions
If available, create keys with only the permissions your application needs.

