API Authentication
Learn how to authenticate your API requests to the Branded Barber API.
Authentication Methods
The Branded Barber API currently supports API key authentication for protected endpoints. Public endpoints (like content retrieval) may not require authentication depending on your configuration.
API Key Authentication
For authenticated requests, include your API key in the request headers:
Authorization: Bearer YOUR_API_KEY
YOUR_API_KEY with your actual API key. Contact your administrator to obtain an API key.Example Request
Here's an example of making an authenticated request using curl:
curl -X GET \ https://your-api-domain.com/api/v1/tenant-1/barbers \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json"
Or using JavaScript fetch:
const response = await fetch(
'https://your-api-domain.com/api/v1/tenant-1/barbers',
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
}
);
const data = await response.json();Public Endpoints
Some endpoints are designed to be publicly accessible and don't require authentication:
/api/v1/:tenantId/contentRetrieve public content configuration for a tenant. No authentication required.
/api/v1/:tenantId/galleryRetrieve gallery items. Public endpoint, no authentication required.
Protected Endpoints
Endpoints that modify data (POST, PUT, DELETE) typically require authentication:
/api/v1/:tenantId/galleryCreate a new gallery item. Requires authentication.
/api/v1/:tenantId/barbersCreate a new barber profile. Requires authentication.
Error Responses
If authentication fails, you'll receive a 401 Unauthorized response:
{
"success": false,
"error": {
"message": "Unauthorized",
"code": "UNAUTHORIZED"
}
}Common authentication errors:
- 401 Unauthorized: Missing or invalid API key
- 403 Forbidden: Valid key but insufficient permissions
- 429 Too Many Requests: Rate limit exceeded
Security Best Practices
Follow these security best practices:
- Store API keys in environment variables
- Use HTTPS for all API requests
- Rotate API keys regularly
- Use different keys for development and production
- Never log or expose API keys in error messages
Getting an API Key
To obtain an API key for your tenant:
- Contact your platform administrator
- Provide your tenant ID
- Specify the permissions you need
- Receive your API key securely