Skip to main content

Error Handling

Overview

The Covolt API uses standard HTTP status codes and structured response bodies to communicate success or error conditions. This consistent approach makes error handling predictable across all API endpoints.

HTTP Status Codes

Our API follows RESTful conventions for status codes:

Status Code RangeCategoryDescription
200 - 299SuccessThe request was successfully received, understood, and processed
400 - 499Client ErrorThe request contains errors or cannot be fulfilled due to client-side issues
500 - 599Server ErrorThe server encountered an error while processing the request

Common Status Codes

Status CodeDescriptionTypical Causes
200 OKRequest succeededStandard success response for GET requests
201 CreatedResource createdSuccessful POST request that created a new resource
204 No ContentSuccess, no content to returnSuccessful DELETE or certain PUT requests
400 Bad RequestInvalid request formatMalformed JSON, invalid parameters
401 UnauthorizedAuthentication requiredMissing or invalid API token
403 ForbiddenPermission deniedValid authentication but insufficient permissions
404 Not FoundResource not foundInvalid endpoint or resource ID
422 Unprocessable EntityValidation errorRequest data failed validation rules
429 Too Many RequestsRate limit exceededToo many requests in a given time frame
500 Internal Server ErrorServer errorUnexpected error on the server
503 Service UnavailableService temporarily unavailableServer is overloaded or under maintenance

Error Response Format

Non-Validation Errors

For most errors, responses include a detail field:

{
"detail": "Authentication credentials were not provided."
}

Validation Errors

For validation errors (400 Bad Request), responses include field-specific messages:

{
"name": ["This field is required."],
"email": ["Enter a valid email address."]
}

Common Error Codes

The API uses standard HTTP status codes to communicate error types:

Status CodeDescriptionExample Situation
400 Bad RequestThe request was malformed or contains invalid parametersField validation errors, invalid JSON
401 UnauthorizedNo valid authentication credentials providedMissing or invalid API token
403 ForbiddenUser lacks permission for the requested operationAttempting to access restricted resource
404 Not FoundThe requested resource does not existInvalid endpoint or resource ID
405 Method Not AllowedThe HTTP method is not supported for this endpointUsing POST on a GET-only endpoint
429 Too Many RequestsAPI rate limit has been exceededToo many requests in given timeframe
500 Internal Server ErrorAn unexpected error occurred on the serverServer-side exception

Best Practices

  • Implement retry logic with exponential backoff for 429 and 5xx errors
  • Cache responses where appropriate to reduce request volume
  • Use batch endpoints for bulk operations when available

Best Practices for Error Handling

  1. Always check status codes: Never assume a request will succeed.

  2. Parse error details: Extract detailed error information from the response body.

  3. Implement retry logic: For 429 or 5xx errors, implement backoff and retry.

  4. Log comprehensive details: Log the full error response for troubleshooting.

  5. Present user-friendly messages: Translate API error messages into actionable user feedback.

Validation Errors

For validation errors, each invalid field is included as a key with an array of error messages:

{
"name": ["This field is required."],
"email": ["Enter a valid email address."],
"age": ["Ensure this value is greater than or equal to 18."]
}