All API requests to the DZconfig API require authentication. This page explains how to authenticate your requests.
Authentication is performed using API tokens. Each user has a unique API token that is used to identify and authorize their requests.
Your API token can be found in your user profile. To access your API token:
Important: Keep your API token secure. Do not share it with others or expose it in client-side code.
To authenticate your API requests, include your API token in the Authorization header of your HTTP requests using the Bearer token 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 => {
// Process the response data as needed
})
.catch(error => {
// Handle errors appropriately
});
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://dzconfig.com/api/user');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
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);
print_r($data);
You can test if your authentication is working correctly by making a request to the /api/validate
endpoint:
curl -X GET "https://dzconfig.com/api/validate" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
If your authentication is successful, you should receive a response with a 200 status code and a JSON object containing a success message:
If your authentication fails, you will receive a response with a 401 Unauthorized status code and an error message:
Common reasons for authentication failures include:
To keep your API token secure: