API Key Authentication
All requests sent to the ByByBG API must include a valid API key inside the request headers.
Your API key identifies your account, request limits, and subscription plan securely.
Generate Your API Key
Login to your dashboard and generate a private API key from the developer settings section.
Send API Key in Request Headers
Include your API key using the X-API-KEY header in every API request.
X-API-KEY: YOUR_API_KEY
PHP Authentication Example
Basic PHP example showing how to include your API key in request headers.
<?php
$apiKey = "YOUR_API_KEY";
$headers = [
"X-API-KEY: ".$apiKey
];
cURL Authentication Example
Simple authenticated cURL request example for testing the API quickly.
curl -X POST https://api.bybybg.com/v1/remove-bg \
-H "X-API-KEY: YOUR_API_KEY" \
-F "file=@image.png"
Security Best Practices
- Never expose API keys in frontend JavaScript code.
- Store API keys securely in environment variables.
- Rotate your API keys periodically for better security.
- Use backend proxy systems for frontend applications.
- Restrict unauthorized access to your backend systems.
Common Authentication Mistakes
- Using an invalid or expired API key.
- Sending requests without authentication headers.
- Exposing secret API keys publicly on websites.
- Using incorrect header names or formatting.
Authentication Errors
Ready for API Integration?
Continue to the Web / HTML integration guide and build your first AI background remover application.