API 1.0.0REST APIStable
Error Handling
Understand and handle API errors gracefully
Note
All errors follow a consistent JSON schema. Use error codes for programmatic handling; messages are human-readable.
Error Response Format
JSON
1{2 "success": false,3 "error": "Error message",4 "code": "ERROR_CODE",5 "statusCode": 4006}
HTTP Status Codes
| Status | Description |
|---|---|
| 400 Bad Request | Invalid request parameters or malformed body |
| 401 Unauthorized | Missing or invalid API key |
| 403 Forbidden | API key lacks required permissions |
| 404 Not Found | Requested resource not found |
| 429 Too Many Requests | Rate limit exceeded |
| 500 Server Error | Internal server error |
Error Handling Example
JavaScript
1async function postStats(stats) {2 try {3 const response = await fetch(4 'https://labs.conscherry.com/api/v1/stats',5 {6 method: 'POST',7 headers: {8 'Authorization': 'Bearer YOUR_API_KEY',9 'Content-Type': 'application/json'10 },11 body: JSON.stringify(stats)12 }13 );1415 if (!response.ok) {16 const error = await response.json();1718 if (response.status === 429) {19 console.log('Rate limited, retry after:',20 response.headers.get('Retry-After'));21 } else if (response.status === 401) {22 console.error('Invalid API key');23 } else {24 console.error('API Error:', error.error);25 }2627 return null;28 }2930 const data = await response.json();31 console.log('Stats updated:', data);32 return data;33 } catch (error) {34 console.error('Network error:', error);35 return null;36 }37}
Need more help?
Ask in our Discord or email support@conscherry.com.