Error Codes Reference
Complete list of MONCRENEAU API error codes.
Error Structure
All errors follow this format:
{
"error": {
"code": "INVALID_API_KEY",
"message": "La clé API fournie est invalide",
"details": {
"field": "Authorization",
"value": "Bearer mk_xxx"
}
}
}
HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
201 | Successfully created |
204 | Successfully deleted (no content) |
400 | Bad request |
401 | Unauthenticated |
402 | Insufficient credits |
403 | Forbidden |
404 | Resource not found |
409 | Conflict (duplicate) |
422 | Invalid data |
429 | Too many requests (rate limit) |
500 | Internal server error |
503 | Service temporarily unavailable |
Authentication Errors (401)
| Code | Description |
|---|---|
MISSING_API_KEY | Authorization header missing |
INVALID_API_KEY | Invalid or revoked API key |
EXPIRED_API_KEY | Expired API key |
INVALID_TOKEN_FORMAT | Invalid Bearer token format |
Authorization Errors (403)
| Code | Description |
|---|---|
INSUFFICIENT_SCOPE | Insufficient permissions |
ORGANIZATION_MISMATCH | Resource belongs to another organization |
DEPARTMENT_ACCESS_DENIED | Department access denied |
Payment Errors (402)
| Code | Description |
|---|---|
INSUFFICIENT_CREDITS | Insufficient credits for operation |
CREDIT_CHECK_FAILED | Credit verification failed |
PAYMENT_REQUIRED | Payment required to continue |
Validation Errors (400, 422)
| Code | Description |
|---|---|
INVALID_REQUEST | Malformed request |
MISSING_REQUIRED_FIELD | Required field missing |
INVALID_FIELD_VALUE | Invalid field value |
INVALID_DATE_TIME | Invalid date/time format |
INVALID_PHONE_NUMBER | Invalid phone number |
INVALID_EMAIL | Invalid email |
Resource Errors (404, 409)
| Code | Description |
|---|---|
APPOINTMENT_NOT_FOUND | Appointment not found |
DEPARTMENT_NOT_FOUND | Department not found |
USER_NOT_FOUND | User not found |
SLOT_NOT_AVAILABLE | Slot not available |
DUPLICATE_APPOINTMENT | Duplicate appointment |
Rate Limit Errors (429)
| Code | Description |
|---|---|
RATE_LIMIT_EXCEEDED | Request limit exceeded |
TOO_MANY_REQUESTS | Too many requests in time window |
Headers included in 429 response:
X-RateLimit-Limit: Limit per hourX-RateLimit-Remaining: Remaining requestsX-RateLimit-Reset: Reset timestamp
Server Errors (500, 503)
| Code | Description |
|---|---|
INTERNAL_SERVER_ERROR | Internal server error |
DATABASE_ERROR | Database error |
SERVICE_UNAVAILABLE | Service temporarily unavailable |
MAINTENANCE_MODE | Maintenance mode active |
Error Handling
try {
const response = await fetch('https://mc-prd.duckdns.org/api/v1/appointments', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify(appointmentData)
});
if (!response.ok) {
const error = await response.json();
if (error.code === 'INSUFFICIENT_CREDITS') {
// Redirect to payment page
window.location.href = '/credits/purchase';
} else if (error.code === 'SLOT_NOT_AVAILABLE') {
// Offer alternative slot
showAlternativeSlots();
} else {
// Display error to user
showError(error.message);
}
}
} catch (err) {
console.error('Network error:', err);
}
See also: Error Handling