API Keys
Programmatic access with API keys
Respondeo provides API keys for programmatic access to the REST API. API keys are managed through the web interface and inherit permissions dynamically from the user's role.
Creating API Keys
Only administrators can create and manage API keys.
- Sign in as an admin user
- Navigate to Settings (
/settings) - Click "Create API Key"
- Optionally set an expiration date
- Copy the API key (it won't be shown again)
Using API Keys
Include the API key in the x-api-key header with every request:
curl -H "x-api-key: your_api_key_here" \
https://respondeo.example.com/api/quizzesJavaScript Example
const response = await fetch("https://respondeo.example.com/api/quizzes", {
headers: {
"x-api-key": "your_api_key_here",
"Content-Type": "application/json",
},
});
const quizzes = await response.json();Python Example
import requests
headers = {
'x-api-key': 'your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.get('https://respondeo.example.com/api/quizzes', headers=headers)
quizzes = response.json()Permissions
API keys inherit permissions from the user's current role dynamically. This means:
- No stored permissions: API keys don't have a fixed set of permissions
- Real-time updates: If a user's role permissions change, all their API keys reflect those changes immediately
- No regeneration needed: No need to recreate API keys when permissions change
Available Scopes
| Scope | Description |
|---|---|
quizzes:read | List and view quizzes, view leaderboards |
quizzes:write | Create, update, and delete quizzes (requires admin role) |
attempts:read | View quiz attempts |
attempts:write | Submit quiz attempts |
The effective permissions of an API key are determined by the user's role at request time. See RBAC Guide for role configuration.
Rate Limiting
API keys are rate-limited to 100 requests per minute by default.
When rate-limited, the API returns:
{
"error": "Rate limit exceeded. Please try again later."
}With HTTP status 429 Too Many Requests.
Rate Limit Headers
The API includes rate limit information in response headers:
X-RateLimit-Limit— Total requests allowed per windowX-RateLimit-Remaining— Remaining requests in current windowX-RateLimit-Reset— Unix timestamp when the limit resets
Security Best Practices
- Keep keys secret — Never commit API keys to version control
- Use environment variables — Store keys in
.envfiles (git-ignored) - Rotate regularly — Delete old keys and create new ones periodically
- Set expiration — Use expiration dates when creating keys
- Limit scope — Ensure users only have necessary permissions
- Monitor usage — Review API key usage regularly in admin panel
Deleting API Keys
To delete an API key:
- Navigate to Settings (
/settings) - Find the key in the list
- Click "Delete"
- Confirm the action
Deleted keys are immediately revoked and cannot be recovered.
Troubleshooting
"Invalid API key"
- Verify the key is correct (no extra spaces or characters)
- Check that the key hasn't been deleted
- Ensure you're using the
x-api-keyheader (notAuthorization)
"Insufficient permissions"
- Check the user's role associated with the API key
- Verify the role has the required permissions
- See RBAC Guide for permission configuration
"Rate limit exceeded"
- Wait for the rate limit window to reset
- Check the
X-RateLimit-Resetheader for reset time - Consider implementing request batching or caching
Next Steps
- API Reference — Explore available endpoints
- RBAC Guide — Configure role permissions
- OpenAPI Documentation — Interactive API docs