Error Handling

The NXSYS API uses conventional HTTP response codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information, and codes in the 5xx range indicate an error with NXSYS's servers.

HTTP Status Codes

Status CodeDescription
200OK - The request was successful
201Created - The resource was successfully created
400Bad Request - The request was invalid or cannot be served
401Unauthorized - Authentication credentials are missing or invalid
403Forbidden - The authenticated user doesn't have access to the requested resource
404Not Found - The requested resource doesn't exist
422Unprocessable Entity - The request was well-formed but had semantic errors
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Something went wrong on our end

Error Response Format

When an error occurs, the API returns a JSON response with the following structure:

{
  "error": {
    "code": "error_code",
    "message": "Human readable error message",
    "details": {
      // Additional error details if available
    }
  }
}

Common Error Codes

Authentication Errors

  • invalid_credentials: The provided API key is invalid or expired
  • missing_credentials: No API key was provided in the request
  • insufficient_permissions: The API key doesn't have the required permissions

Validation Errors

  • invalid_request: The request payload is malformed or missing required fields
  • invalid_parameter: One or more parameters in the request are invalid
  • resource_not_found: The requested resource doesn't exist

Example Error Handling

Here's an example of how to handle errors in different programming languages:

// JavaScript/Node.js
try {
  const response = await fetch('https://dev-api.nxsys.tech/v1/resource');
  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error.message);
  }
  const data = await response.json();
} catch (error) {
  console.error('API Error:', error.message);
}