Skip to main content

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

CodeMeaning
200Success
201Successfully created
204Successfully deleted (no content)
400Bad request
401Unauthenticated
402Insufficient credits
403Forbidden
404Resource not found
409Conflict (duplicate)
422Invalid data
429Too many requests (rate limit)
500Internal server error
503Service temporarily unavailable

Authentication Errors (401)

CodeDescription
MISSING_API_KEYAuthorization header missing
INVALID_API_KEYInvalid or revoked API key
EXPIRED_API_KEYExpired API key
INVALID_TOKEN_FORMATInvalid Bearer token format

Authorization Errors (403)

CodeDescription
INSUFFICIENT_SCOPEInsufficient permissions
ORGANIZATION_MISMATCHResource belongs to another organization
DEPARTMENT_ACCESS_DENIEDDepartment access denied

Payment Errors (402)

CodeDescription
INSUFFICIENT_CREDITSInsufficient credits for operation
CREDIT_CHECK_FAILEDCredit verification failed
PAYMENT_REQUIREDPayment required to continue

Validation Errors (400, 422)

CodeDescription
INVALID_REQUESTMalformed request
MISSING_REQUIRED_FIELDRequired field missing
INVALID_FIELD_VALUEInvalid field value
INVALID_DATE_TIMEInvalid date/time format
INVALID_PHONE_NUMBERInvalid phone number
INVALID_EMAILInvalid email

Resource Errors (404, 409)

CodeDescription
APPOINTMENT_NOT_FOUNDAppointment not found
DEPARTMENT_NOT_FOUNDDepartment not found
USER_NOT_FOUNDUser not found
SLOT_NOT_AVAILABLESlot not available
DUPLICATE_APPOINTMENTDuplicate appointment

Rate Limit Errors (429)

CodeDescription
RATE_LIMIT_EXCEEDEDRequest limit exceeded
TOO_MANY_REQUESTSToo many requests in time window

Headers included in 429 response:

  • X-RateLimit-Limit: Limit per hour
  • X-RateLimit-Remaining: Remaining requests
  • X-RateLimit-Reset: Reset timestamp

Server Errors (500, 503)

CodeDescription
INTERNAL_SERVER_ERRORInternal server error
DATABASE_ERRORDatabase error
SERVICE_UNAVAILABLEService temporarily unavailable
MAINTENANCE_MODEMaintenance 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