Error Handling
Understanding and handling API errors
Overview
The Semaphor API uses standard HTTP status codes and provides detailed error information to help you understand and resolve issues. All error responses follow a consistent format and are common across the Dashboards, Visuals, and Tokens APIs.
Error Response Format
All API errors return a JSON response with the following structure:
HTTP Status Codes
Status Code | Description | Common Causes |
---|---|---|
200 | Success | Request completed successfully |
201 | Created | Resource created successfully |
400 | Bad Request | Invalid request parameters or body |
401 | Unauthorized | Missing or invalid authentication |
403 | Forbidden | Insufficient permissions |
404 | Not Found | Resource doesn't exist |
409 | Conflict | Resource conflict (e.g., duplicate) |
422 | Unprocessable Entity | Validation errors |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server-side error |
Common Error Codes
Authentication & Token Errors (All APIs)
Error Code | Status | Description | Solution |
---|---|---|---|
INVALID_CREDENTIALS | 401 | Dashboard/project ID or secret is incorrect | Verify credentials in Semaphor Console |
TOKEN_EXPIRED | 401 | Authentication token has expired | Generate a new token |
INVALID_TOKEN | 401 | Token format is invalid | Check token format and regenerate |
MISSING_AUTHORIZATION | 401 | Authorization header is missing | Include Authorization: Bearer {token} header |
INSUFFICIENT_PERMISSIONS | 403 | Token lacks required permissions | Check token configuration |
RATE_LIMIT_EXCEEDED | 429 | Too many authentication attempts | Wait before retrying |
Dashboards API Errors
Error Code | Status | Description | Solution |
---|---|---|---|
DASHBOARD_NOT_FOUND | 404 | Dashboard doesn't exist | Verify dashboard ID |
DASHBOARD_INACTIVE | 403 | Dashboard is not active | Activate dashboard in console |
DASHBOARD_ARCHIVED | 403 | Dashboard has been archived | Restore dashboard or use different one |
INVALID_DASHBOARD_ID | 400 | Dashboard ID format is invalid | Check ID format: d_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
EXPORT_FAILED | 500 | Export processing failed | Check export parameters and retry |
INVALID_EXPORT_FORMAT | 400 | Unsupported export format | Use supported formats: png , jpg , pdf |
EXPORT_TOO_LARGE | 400 | Export exceeds size limits | Reduce dimensions or filters |
EXPORT_NOT_FOUND | 404 | Export doesn't exist | Verify export ID |
EXPORT_EXPIRED | 410 | Export has expired | Generate new export |
Visuals API Errors
Error Code | Status | Description | Solution |
---|---|---|---|
VISUAL_NOT_FOUND | 404 | Visual doesn't exist | Verify visual ID |
INVALID_VISUAL_ID | 400 | Visual ID format is invalid | Check ID format |
VISUAL_DUPLICATE | 409 | Visual already exists | Use a unique title or ID |
Security Policy Errors (Dashboards & Visuals)
Error Code | Status | Description | Solution |
---|---|---|---|
INVALID_SECURITY_POLICY | 400 | Security policy configuration is invalid | Review policy syntax |
POLICY_NOT_FOUND | 404 | Referenced policy doesn't exist | Verify policy name |
POLICY_PARAMETER_MISMATCH | 400 | Policy parameters don't match expected format | Check parameter types and values |
POLICY_CONFLICT | 409 | Conflicting security policies | Resolve policy conflicts |
Validation Errors (All APIs)
Error Code | Status | Description | Solution |
---|---|---|---|
INVALID_PARAMETER | 400 | Request parameter is invalid | Check parameter format and values |
MISSING_REQUIRED_FIELD | 400 | Required field is missing | Include all required fields |
INVALID_JSON | 400 | Request body is not valid JSON | Check JSON syntax |
FIELD_TOO_LONG | 400 | Field value exceeds maximum length | Reduce field length |
INVALID_EMAIL_FORMAT | 400 | Email format is invalid | Use valid email format |
Error Handling Examples
See the Tokens API, Dashboards API, and Visuals API for endpoint-specific error examples and how to handle them in your code.
JavaScript/TypeScript
Best Practices
- Always check the
error.code
anderror.message
fields in error responses. - Implement retry logic for rate limiting and server errors.
- Log errors and monitor for recurring issues.
- Validate all request parameters and payloads before sending.
- Reference the Tokens API, Dashboards API, and Visuals API for more details on error handling in context.