All API requests to DZconfig require authentication using a Bearer token. This page explains how to obtain and use your API token for secure access.
Authentication uses API tokens unique to each user account. Your token identifies and authorizes your requests, granting access to your instances and resources. Include the token in the Authorization header of every API request using the Bearer scheme.
Your API token is available in your account settings. Follow these steps to locate it:
Security Notice: Keep your API token secure. Never share it with others, expose it in client-side code, or commit it to version control. Treat it like a password.
Include your token in the Authorization header using the Bearer scheme:
Authorization: Bearer YOUR_API_TOKEN
curl -X GET "https://dzconfig.com/api/user" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
fetch('https://dzconfig.com/api/user', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://dzconfig.com/api/user');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_TOKEN',
'Accept: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
Verify your token works by calling the validation endpoint. A successful response confirms your authentication is configured correctly.
GET /api/validate
Success response:
{ "result": "success" }
Failed authentication returns a 401 status code. Common causes include invalid tokens, missing headers, or incorrect header format.
HTTP/1.1 401 Unauthorized
Error response:
{
"error": "Unauthorized",
"message": "Invalid API token"
}
Use a dedicated API client library or HTTP wrapper in your application to centralize authentication logic. This makes it easier to update tokens and handle authentication errors consistently across your codebase. Consider implementing automatic retry logic for transient authentication failures.