Skip to main content
Error Handling

Error Handling

Understand error responses and implement robust error handling in your WMS integration.

Error Response Format

All API errors return a consistent JSON structure.

Error Response
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid SKU format",
    "details": [
      {
        "field": "sku",
        "message": "SKU must be alphanumeric"
      }
    ],
    "request_id": "req_abc123",
    "documentation_url": "https://docs.synaptis.com/wms/errors#VALIDATION_ERROR"
  }
}

HTTP Status Codes

CodeNameDescriptionRetry
400Bad RequestInvalid request parameters or malformed JSON
401UnauthorizedMissing or invalid API key
403ForbiddenInsufficient permissions for this operation
404Not FoundResource does not exist
409ConflictResource conflict (e.g., duplicate SKU)
422UnprocessableValidation error in request data
429Rate LimitedToo many requests
500Server ErrorInternal server error
503UnavailableService temporarily unavailable

Retry Strategy

Implement exponential backoff for retryable errors (429, 500, 503).

Exponential Backoff
async function fetchWithRetry(url, options, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      const response = await fetch(url, options);
      if (response.ok) return response;
      
      if (![429, 500, 503].includes(response.status)) {
        throw new Error(`Non-retryable error: ${response.status}`);
      }
      
      const delay = Math.pow(2, attempt) * 1000;
      await new Promise(r => setTimeout(r, delay));
    } catch (error) {
      if (attempt === maxRetries - 1) throw error;
    }
  }
}

Next Steps