Authenticating with DataDocks API
Before making API calls to DataDocks, you'll need to authenticate your requests using an API token. This page will guide you through the authentication process with clear examples.
Getting Your API Token
Your API token is unique to your organization and serves as your digital key to the DataDocks API. To obtain your token:
- Contact the DataDocks support team at support@datadocks.com
- Provide your organization name and the subdomain of your location
- Our team will generate an API user and provide you with an API token
Important: Keep your API token secure! Do not share it in public repositories or client-side code.
Using Your API Token
Include your API token in the Authorization
header of all requests as a Token
:
Authorization: Token YOUR_API_TOKEN
Request Format
All API requests must include:
- The
Authorization
header with your token - Your location subdomain in the URL
- The appropriate HTTP method (GET, POST, PUT, etc.)
- Content-Type header (for POST/PUT requests)
Authentication Examples
cURL Example
See cURL example
# Get all appointments
curl -H "Authorization: Token 12345abcde" https://toronto-acme.datadocks.com/api/v1/appointments
# Create a new appointment
curl -H "Authorization: Token 12345abcde" \
-H "Content-Type: application/json" \
-X POST \
-d '{"appointment": {"scheduled_at": "2023-10-01T09:00:00-04:00", "duration": 60}}' \
https://toronto-acme.datadocks.com/api/v1/appointments
JavaScript Example
See JavaScript example
// Using fetch API
const fetchAppointments = async () => {
const response = await fetch(
"https://toronto-acme.datadocks.com/api/v1/appointments",
{
method: "GET",
headers: {
Authorization: "Token 12345abcde",
"Content-Type": "application/json",
},
}
);
const data = await response.json();
return data;
};
Python Example
See Python example
import requests
# Configuration
api_token = '12345abcde'
location_subdomain = 'toronto-acme'
# Get all appointments
headers = {
'Authorization': f'Token {api_token}',
'Content-Type': 'application/json'
}
response = requests.get(
f'https://{location_subdomain}.datadocks.com/api/v1/appointments',
headers=headers
)
appointments = response.json()
Security Best Practices
When working with the DataDocks API, follow these security best practices:
- Store tokens securely — Never hard-code tokens in client-side code or public repositories
- Use environment variables — Store tokens in environment variables or secure credential stores
- Implement token rotation — Request a new token periodically (every 90 days)
- Apply the principle of least privilege — Only request the permissions you need
- Monitor token usage — Regularly review API logs for unusual activity
Troubleshooting Authentication
Error | Possible Cause | Solution |
---|---|---|
401 Unauthorized | Invalid or missing token | Verify your token is correct and properly formatted in the header |
403 Forbidden | Token doesn't have permission | Contact support to ensure your token has the necessary permissions |
429 Too Many Requests | Rate limit exceeded | Implement exponential backoff strategy |
If you continue to experience authentication issues, contact support@datadocks.com with details of your request and the error response.