Qube Logo

Error Handling

Complete guide to API error codes, status codes, and troubleshooting

Error Handling

All API errors follow a standardized response format with a success: false flag and detailed error information.

Error Response Format

{
  "success": false,
  "error": {
    "code": "device_not_found",
    "detail": "You are not allowed to access the specified device. Or the specified device does not exist."
  },
  "timestamp": "2025-01-01T12:00:00.000Z"
}

Error Codes

Authentication & Authorization Errors

authentication_error

Status Code: 401
Meaning: Invalid or missing API key, or malformed Authorization header
Example Detail: "Invalid Authorization header. Bearer authorization is required."

Common Causes:

  • Missing X-Qube-API-Key header
  • Invalid API key format
  • Expired or revoked API key

Resolution:

  • Verify your API key is correct
  • Ensure proper header format: X-Qube-API-Key: your-api-key

Device Access Errors

device_not_found

Status Code: 400
Meaning: Device doesn't exist or you don't have access to it
Example Detail: "You are not allowed to access the specified device. Or the specified device does not exist."

Common Causes:

  • Invalid device ID
  • Device belongs to different user/account
  • Device has been removed or deactivated

Resolution:

  • Verify device ID is correct
  • Check device belongs to your account
  • Use GET /spaces/ to list accessible devices

device_not_in_space

Status Code: 417
Meaning: Device exists but is not associated with any space
Example Detail: "Device is not associated with any space"

Common Causes:

  • Device setup incomplete
  • Device removed from space but still exists

Resolution:

  • Contact support to associate device with a space
  • Verify device setup is complete

Space Access Errors

not_your_space

Status Code: 400
Meaning: The specified space doesn't belong to your account
Example Detail: "The space does not belong to you."

Common Causes:

  • Invalid space ID
  • Attempting to access another user's space
  • Space permissions changed

Resolution:

  • Use GET /spaces/ to list your accessible spaces
  • Verify space ID is correct

Validation Errors

validation_error

Status Code: 422
Meaning: Request body validation failed
Example Detail:

[
  {
    "loc": ["ssid"],
    "msg": "ensure this value has at most 32 characters"
  }
]

Common Causes:

  • Missing required fields
  • Invalid data types
  • Values exceeding length limits
  • Invalid enum values

Resolution:

  • Check API documentation for required fields
  • Verify data types match schema
  • Ensure string lengths are within limits

Device Operation Errors

Network/Connectivity Issues

Status Code: 400
Meaning: Device is offline or network operation failed
Example Detail: "Network details not found. Device might not be online."

Common Causes:

  • Device is offline
  • Network connectivity issues
  • Device not responding

Resolution:

  • Check device online status with GET /api/v2/devices/{device_id}/
  • Verify device connectivity
  • Retry operation after device comes online

Property Access Issues

Status Code: 400
Meaning: Unable to read device properties
Example Detail: "Unable to read device properties"

Common Causes:

  • Device communication failure
  • Invalid property access
  • Device firmware issues

Resolution:

  • Retry the operation
  • Check device is online
  • Contact support if persistent

HTTP Status Codes

200 OK

Successful request with data returned

400 Bad Request

  • Invalid request parameters
  • Business logic validation failures
  • Device operation errors

401 Unauthorized

  • Missing or invalid authentication
  • API key issues

403 Forbidden

  • Valid authentication but insufficient permissions
  • Account limitations

417 Expectation Failed

  • Device configuration issues
  • Setup incomplete

422 Unprocessable Entity

  • Request body validation errors
  • Schema validation failures

Troubleshooting Guide

Authentication Issues

  1. Verify API Key: Ensure you're using the correct API key
  2. Check Headers: Use X-Qube-API-Key header (not Authorization)
  3. Key Status: Confirm API key is active and not expired

Device Access Issues

  1. List Devices: Use GET /spaces/ to see accessible devices
  2. Check Ownership: Verify device belongs to your account
  3. Device Status: Check if device is online and properly configured

Validation Issues

  1. Review Schema: Check API documentation for field requirements
  2. Data Types: Ensure correct data types (string, integer, boolean)
  3. Constraints: Verify length limits and value ranges

Network Issues

  1. Device Connectivity: Verify device is online
  2. Retry Logic: Implement exponential backoff for transient failures
  3. Status Monitoring: Regularly check device online status

Common Error Patterns

  • Device Not Found: Always verify device ID before operations
  • Permission Denied: Check space ownership before device operations
  • Validation Errors: Validate input data before API calls
  • Network Errors: Implement retry logic for device operations