Error Codes
When interacting with the Selling.com API, you may encounter various error responses. These errors are returned with an appropriate HTTP status code and a message that describes the issue. Understanding these error codes will help you diagnose problems and implement proper error handling in your application.
Understanding Error Responses
    Each error response from the API will include:
  • HTTP Status Code: A standard code that indicates the type of error (e.g., 400 for a bad request, 401 for unauthorized access).
  • Error Message: A brief description of the error.
Example Error Response
{
    "status": 400,
    "error": "Bad Request",
    "message": "The email field is required."
}
Common HTTP Status Codes
Here are the most common HTTP status codes you may encounter while using the API, along with explanations and possible solutions:
4xx Client Errors
These errors indicate that the client (your application) has made a mistake in the request.
400 Bad Request
The server could not understand the request due to invalid syntax or missing required parameters.
    Possible Causes:
  • Missing required fields in the request body.
  • Invalid JSON format.
  • Incorrect data types for fields.
Solution: Check the request body and ensure that all required fields are included and correctly formatted.
Example
{
    "status": 400,
    "error": "Bad Request",
    "message": "Required fields are missing in the request: {'first_name', 'last_name', 'website'} or {'first_name', 'last_name', 'company_name'} or 'linkedin_url' or 'business_email'"
}
401 Unauthorized
The request requires authentication, but the API key is missing, invalid, or expired.
    Possible Causes:
  • API key not included in the request.
  • Incorrect API key.
  • Expired or revoked API key.
Solution: Ensure that the Authorization header is present and contains a valid API key.
Example
{
    "status": 401,
    "error": "Unauthorized",
    "message": "Invalid API key. Please check your credentials."
}
403 Forbidden
The client does not have the necessary permissions to access the resource.
    Possible Causes:
  • Attempting to access a restricted endpoint or resource.
  • Insufficient API key permissions.
Solution: Verify that your API key has the correct permissions. Contact support if you believe you should have access.
Example
{
    "status": 403,
    "error": "Forbidden",
    "message": "Your account is inactive. Please contact support to reactivate your account."
}
404 Not Found
The requested resource could not be found.
    Possible Causes:
  • Incorrect endpoint URL.
  • The resource does not exist.
Solution: Double-check the URL and the resource identifiers in the request.
Example
{
    "status": 404,
    "error": "Not Found",
    "message": "The requested endpoint could not be found."
}
429 Too Many Requests
The client has sent too many requests in a given amount of time (rate limit exceeded).
    Possible Causes:
  • Exceeding the rate limits set by the API.
Solution: Reduce the frequency of your requests. Implement retry logic with exponential backoff to handle rate limiting.
Example
{
    "status": 429,
    "error": "Too Many Requests",
    "message": "Rate limit exceeded. Please try again later."
}
5xx Server Errors
These errors indicate that something went wrong on the server side. In most cases, these are temporary issues.
500 Internal Server Error
The server encountered an unexpected condition that prevented it from fulfilling the request.
    Possible Causes:
  • Temporary server issues.
  • Unhandled exceptions on the server.
Solution: Retry the request after some time. If the issue persists, contact support.
Example
{
    "status": 500,
    "error": "Internal Server Error",
    "message": "An unexpected error occurred. Please try again later."
}
Tips for Handling Errors
  • Log Errors: Ensure that your application logs errors with relevant details to help with troubleshooting.
  • Retry Logic: Implement retry logic with exponential backoff for transient errors, such as 500, 502, 503, and 504.
  • Graceful Degradation: If an API call fails, consider how your application can degrade gracefully, such as retrying or using cached data.
  • Contact Support: If you're encountering persistent issues or unclear errors, contact our support team with details about the request and response.