Errors
The Sentisnap API uses conventional HTTP status codes and returns errors in a consistent JSON format.
| Code | Description |
|---|---|
200 | Success |
201 | Created (resource successfully created) |
204 | No Content (successful deletion) |
400 | Bad Request (invalid parameters) |
401 | Unauthorized (invalid or missing API key) |
403 | Forbidden (insufficient permissions) |
404 | Not Found |
429 | Too Many Requests (rate limit exceeded) |
500 | Internal Server Error |
Error Response Format
All errors follow this structure:
{
"error": {
"code": "error_code",
"message": "Human-readable error message",
"details": {}
}
}Error Codes
Authentication Errors
| Code | HTTP | Description |
|---|---|---|
unauthorized | 401 | Missing Authorization header |
invalid_api_key | 401 | Invalid API key format or key not found |
expired_api_key | 401 | API key has expired |
revoked_api_key | 401 | API key has been revoked |
Authorization Errors
| Code | HTTP | Description |
|---|---|---|
forbidden | 403 | General permission denied |
insufficient_scope | 403 | API key lacks required scope |
Request Errors
| Code | HTTP | Description |
|---|---|---|
validation_error | 400 | Invalid request parameters |
not_found | 404 | Resource not found |
rate_limit_exceeded | 429 | Rate limit exceeded |
Server Errors
| Code | HTTP | Description |
|---|---|---|
internal_error | 500 | Internal server error |
Validation Error Details
For validation errors, the details field contains specific field errors:
{
"error": {
"code": "validation_error",
"message": "Validation failed",
"details": [
{
"path": [
"url"
],
"message": "Invalid url"
},
{
"path": [
"events"
],
"message": "Required"
}
]
}
}Example Error Handling
async function makeApiRequest(endpoint) {
const response = await fetch(
`https://public-api.sentisnap.com/v1${endpoint}`,
{
headers: {
'Authorization': `Bearer ${API_KEY}`
}
}
);
if (!response.ok) {
const error = await response.json();
switch (error.error.code) {
case 'invalid_api_key':
throw new Error('Please check your API key');
case 'rate_limit_exceeded':
const retryAfter = response.headers.get('Retry-After');
throw new Error(`Rate limited. Retry after ${retryAfter} seconds`);
case 'not_found':
return null;
default:
throw new Error(error.error.message);
}
}
return response.json();
}