API Authentication
Secure your API requests with API keys and learn best practices for authentication
Getting Your API Key
Generate and manage your API keys from your dashboard
- 1
Log in to your dashboard
Navigate to your account settings
- 2
Go to API Settings
Find the API section in your account
- 3
Generate a new API key
Click "Create API Key" and save it securely
Using Your API Key
Include your API key in the Authorization header of all requests
Header Format:
Authorization: Bearer YOUR_API_KEY_HERE
Example cURL Request:
curl -X GET "https://youraivoice.ai/api/entities" \ -H "Authorization: Bearer YOUR_API_KEY_HERE" \ -H "Content-Type: application/json"
Example JavaScript (Node.js):
const response = await fetch('https://youraivoice.ai/api/entities', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY_HERE',
'Content-Type': 'application/json'
}
});
const data = await response.json();Example Python:
import requests
headers = {
'Authorization': 'Bearer YOUR_API_KEY_HERE',
'Content-Type': 'application/json'
}
response = requests.get(
'https://youraivoice.ai/api/entities',
headers=headers
)
data = response.json()Security Best Practices
Keep your API keys secure and follow these guidelines
Store Keys Securely
Use environment variables or secret management services. Never hardcode keys in your application.
Server-Side Only
Never expose API keys in client-side code, mobile apps, or browser JavaScript.
Rotate Keys Regularly
Generate new API keys periodically and revoke old ones.
Monitor Usage
Regularly check your API usage logs for unusual activity.
Use HTTPS Only
Always use HTTPS to encrypt API requests and protect your keys in transit.
Authentication Error Responses
Common authentication errors and how to resolve them
401 Unauthorized
API key is missing or invalid. Verify your key and ensure it's included in the Authorization header.
403 Forbidden
Your API key doesn't have permission to access this resource. Check your subscription plan or upgrade to access this endpoint.
429 Too Many Requests
You've exceeded your rate limit. Wait before making additional requests or upgrade your plan.
Using Environment Variables
Best practice for storing API keys in your application
.env file example:
# .env YOURAIVOICE_API_KEY=your_api_key_here
Node.js usage:
require('dotenv').config();
const apiKey = process.env.YOURAIVOICE_API_KEY;
const response = await fetch('https://youraivoice.ai/api/entities', {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});