HTTP Status Codes

CodeMeaningDescription
200SuccessRequest completed successfully
400Bad RequestInvalid request parameters or format
401UnauthorizedMissing or invalid authentication
404Not FoundFile or resource doesn’t exist
409ConflictFile already exists (write operation)
422Unprocessable EntityBusiness rule violation
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer-side error

Error Response Format

All errors return a consistent JSON structure:
{
  "success": false,
  "error": {
    "code": "FILE_NOT_FOUND",
    "message": "File not found at path: documents/report.pdf"
  },
  "operation": "read_file",
  "details": {
    "path": "documents/report.pdf",
    "timestamp": "2025-01-15T10:30:00Z"
  }
}

Common Error Codes

Authentication Errors

File Operation Errors

Error Handling Best Practices

Retry Logic

Implement exponential backoff for transient errors:
async function apiCallWithRetry(apiCall, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await apiCall()
    } catch (error) {
      if (error.status === 429 || error.status >= 500) {
        const delay = Math.min(1000 * Math.pow(2, attempt), 30000)
        await new Promise(resolve => setTimeout(resolve, delay))
        continue
      }
      throw error // Don't retry client errors
    }
  }
  throw new Error('Max retries exceeded')
}

Logging and Monitoring

Track error patterns to improve reliability:
function logApiError(error, operation, context) {
  console.error('OpenFiles API Error', {
    operation,
    errorCode: error.error?.code,
    message: error.error?.message,
    statusCode: error.status,
    context,
    timestamp: new Date().toISOString()
  })
  
  // Send to monitoring service
  if (error.status >= 500) {
    monitoring.reportServerError(error)
  }
}

Getting Help

If you encounter persistent errors:

Check API Status

Visit status.openfiles.ai for service status

Email Support

Contact our team at support@openfiles.ai