Skip to main content
Use this page to standardize how your M2M client handles non-2xx responses, network failures, polling timeouts, and user-facing fallbacks. The API Reference shows endpoint-level response schemas. This page focuses on client behavior.

Error response model

For failed requests, treat the HTTP status code as the primary contract. The response body may include an error field or a small JSON object with details:
Do not build production logic around exact error text. Exact wording can change. Use:
  • HTTP status
  • endpoint name
  • request context you own
  • retry count
  • latency
  • request_id when the response includes one

Status code handling

Retry decision table

JavaScript error class

Use a custom error type so application code can make decisions without parsing strings.

JavaScript client with timeout and retry

This example retries only retryable failures and applies a total timeout per request attempt.

Safe user-facing fallback

Do not expose raw API errors to end users. Map integration failures to a small set of safe messages in your product.
Keep detailed error information in server-side logs only.

Async polling failure handling

For async chat, distinguish submit failures from polling failures.
Recommended behavior after polling timeout:
  • Mark the local job as timed out
  • Store the request_id
  • Avoid endless polling
  • Let the user retry through your own product flow
  • Review timeout frequency in monitoring

Logging checklist

Log enough to debug without leaking sensitive data. Recommended fields:
  • Integration name
  • Environment
  • Endpoint path template
  • HTTP status
  • Tenant ID and site ID
  • Session ID
  • Request ID when available
  • Retry count
  • Latency
  • Timeout flag
Do not log:
  • API keys
  • Authorization headers
  • Full secret configuration
  • Raw private customer records
  • Full document content in normal production logs

Incident routing

Use these routing rules when alerts fire:
  • Repeated 401: check key rotation, deployment configuration, and revoked keys
  • Repeated 403: check plan level, tenant access, site access, and enabled capability
  • Repeated 404: check configured tenant_id, site_id, request_id, or document ID
  • Repeated 429: reduce concurrency, add backoff, and inspect traffic spikes
  • Repeated 5xx: keep bounded retries, monitor recovery, and pause non-critical bulk jobs if needed
  • Polling timeouts: check async job volume, user timeout budget, and worker concurrency

Production checklist

  • All HTTP calls have timeout settings
  • Retries are bounded
  • Retryable and non-retryable failures are separated
  • 401 and 403 create operational alerts instead of retry storms
  • Async polling has an overall timeout
  • User-facing errors are safe and non-technical
  • Server logs exclude API keys and sensitive customer records
  • Bulk document sync jobs can pause when error rate increases