Skip to main content

Error Handling

How to handle errors when integrating with the Distribution Hub XML API.

Error Types​

DH returns errors at two levels:

1. HTTP Status Codes​

Transport-level errors from the HTTP layer.

Status CodeMeaningRetry?Action
200 OKRequest acceptedN/AParse XML for business status
400 Bad RequestMalformed XML❌ NoFix request format
401 UnauthorizedInvalid API key❌ NoVerify the AccessKey / SecretKey pair
404 Not FoundInvalid endpoint❌ NoCheck API URL
429 Too Many RequestsRate limit exceeded✅ YesBack off; prefer Retry-After if present
500 Internal Server ErrorServer error✅ YesExponential backoff (stop after 3–4 attempts)
502 Bad GatewayGateway error✅ YesRetry with backoff
503 Service UnavailableTemporarily unavailable✅ YesRetry with backoff
504 Gateway TimeoutRequest timeout✅ YesRetry with backoff; consider a longer timeout

2. XML Business Logic Status​

Even with HTTP 200, check the XML Status block. When Success is false, use ErrorCode and ErrorMessage to decide what to do:

<Pull_ListProp_RS>
<Status>
<Success>false</Success>
<ErrorCode>PropertyNotFound</ErrorCode>
<ErrorMessage>Property with ID 12345 not found</ErrorMessage>
</Status>
</Pull_ListProp_RS>

Common Business Logic Errors​

Error CodeMeaningRetry?Action
PropertyNotFoundProperty doesn't exist❌ NoRemove from local cache
PropertyNotActiveProperty not available❌ NoMark as inactive
InvalidDatesDate range invalid❌ NoValidate date logic
NotAvailableProperty not available for dates❌ NoShow as unavailable
MinStayNotMetStay too short❌ NoEnforce minimum stay
PriceChangedPrice changed since quote❌ NoGet a fresh quote
ReservationNotFoundReservation doesn't exist❌ NoCheck reservation ID
InvalidOwnerIDOwner doesn't exist❌ NoCheck owner ID
AuthenticationFailedAPI key invalid❌ NoCorrect or rotate the API key

Retry Strategy​

Retry only transient failures: rate limits (429), server errors (500, 502, 503, 504), timeouts, and connection errors. Do not retry client errors such as 400, 401, 403, or 404 — fix the request instead.

Use exponential backoff: wait longer between each retry so you don’t hammer the API while it recovers. A simple schedule is:

  1. First attempt — immediate
  2. Second attempt — wait ~1 second
  3. Third attempt — wait ~2 seconds
  4. Fourth attempt — wait ~4 seconds

Then stop (typically after 3–4 attempts) and surface the error. Double the wait each time (1 → 2 → 4…). For 429 responses, prefer any Retry-After value the API returns over your own backoff interval.

Error Handling by Operation Type​

Dictionary operations​

Failures are rare and usually transient. Keep a local cache of dictionary data and fall back to it if a sync fails. Schedule a later retry (for example within the hour) rather than blocking other work.

Property operations​

PropertyNotFound and PropertyNotActive are common. Treat them as definitive: deactivate or mark the listing inactive in your system and stop syncing it until it becomes available again. Do not keep retrying the same property indefinitely.

Availability and pricing operations​

Validate date ranges before calling the API. On InvalidDates, fix the request and do not cache the failed result. On PropertyNotFound, deactivate locally as above. On transient HTTP failures, use the retry schedule.

Booking operations​

Treat booking errors as critical. Always obtain a fresh price quote immediately before creating a reservation. If the property is unavailable, the price changed, or minimum stay is not met, show a clear message to the guest and let them adjust dates or accept the new price — do not silently retry create. On server errors during booking, alert your operations team and ask the guest to try again or contact support. Avoid blind retries of create calls, which can produce duplicate reservations.

Error Logging​

Retain API request and response details for at least 30 days to support troubleshooting. For each failure, log enough context to reproduce the call:

  • Timestamp and duration
  • HTTP status and business ErrorCode / ErrorMessage
  • Operation name
  • Full request and response XML
  • Property ID and reservation ID when present
  • Retry attempt number
  • A correlation ID so you can trace one guest or sync job across systems

Circuit Breaker​

If the API is repeatedly failing, stop calling it for a short period so you don’t amplify the outage.

  1. Closed (normal) — calls go through. Count consecutive failures.
  2. Open — after a threshold (for example 5 failures), pause outbound calls for a cooldown (for example 60 seconds) and alert ops.
  3. Half-open — after the cooldown, allow a limited probe call. Success closes the breaker; failure opens it again.

Use this for sync and quote traffic. Be especially careful with booking flows: when the breaker is open, fail fast with a clear guest-facing message rather than queuing ambiguous creates.

Best Practices​

Do

  • Retry transient errors with exponential backoff and a hard attempt limit
  • Prefer Retry-After on 429 responses
  • Log full request/response context (30+ days)
  • Use a circuit breaker for resilience
  • Alert on booking failures and breaker trips
  • Map business error codes to clear guest or operator actions

Don’t

  • Retry 400, 401, or 404
  • Retry forever without a stop condition
  • Ignore XML Success=false when HTTP status is 200
  • Expose raw API error text to guests
  • Blindly retry reservation create (duplicate risk)

Next Steps​