Authentication
Authenticate every 5centsCDN API request using your API key.
How it works
Add the X-API-KEY header to every request. Your key identifies your account and authorizes access to all resources on it.
GET https://api.5centscdn.com/v2/zones
X-API-KEY: YOUR_API_KEY
Get your API key
Log in to your dashboard
Go to 5centscdn.net/dashboard and sign in.
Open API Keys
Navigate to Settings → API Keys.
Copy or generate your key
Copy your existing key or click Generate New Key. Store it safely — it will not be shown again after creation.
Authenticated request examples
curl -X GET https://api.5centscdn.com/v2/zones \
-H "X-API-KEY: YOUR_API_KEY"
const response = await fetch('https://api.5centscdn.com/v2/zones', {
method: 'GET',
headers: {
'X-API-KEY': process.env.CDN_API_KEY
}
});
const data = await response.json();
import requests
response = requests.get(
'https://api.5centscdn.com/v2/zones',
headers={'X-API-KEY': 'YOUR_API_KEY'}
)
data = response.json()
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.5centscdn.com/v2/zones',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY']
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Authentication errors
{
"status": "error",
"errors": [
{
"code": 401,
"message": "API key is required. Include X-API-KEY in your request header."
}
]
}
{
"status": "error",
"errors": [
{
"code": 401,
"message": "Invalid API key. Check your key or generate a new one."
}
]
}
{
"status": "error",
"errors": [
{
"code": 403,
"message": "Your account does not have permission to perform this action."
}
]
}
| Code | Meaning | Fix |
|---|---|---|
401 | Missing or invalid API key | Check that the header name is X-API-KEY and the value is correct |
403 | Valid key, insufficient permissions | Contact support — your account may have restrictions |
Security best practices
Your key grants full access to your account. Keep it out of client-side code, public repos, and browser requests.
Store your key as an environment variable and reference it in code — never hardcode it.
# .env
CDN_API_KEY=your_actual_key_here
-
Separate keys per environment — use different keys for dev, staging, and production
-
Rotate regularly — regenerate after any team member with access leaves
-
Monitor usage — check your dashboard for unexpected API activity
-
Rotate immediately if you suspect your key has been compromised