PlatformXeDocs
Get API Key

Error Handling

Circuit breaker, retries, fail-open mode, and timeout handling.

The PlatformXe SDK includes built-in resilience features to handle transient failures gracefully.

Retry with exponential backoff

Transient failures (5xx errors, network timeouts) are automatically retried with exponential backoff and jitter.

const px = new PlatformXeClient({
  apiKey: process.env.PLATFORMXE_API_KEY!,
  retries: 3,      // Up to 3 retry attempts
  timeoutMs: 10000, // 10 second timeout per attempt
});

Retry delays follow this pattern:

AttemptBase delayWith jitter
1200ms150–250ms
2400ms300–500ms
3800ms600–1000ms

Client errors (4xx) are not retried — they indicate invalid requests that will fail again.

Fail-open mode (Python and Go)

The Python and Go SDKs can return a failure result instead of raising when PlatformXe cannot be reached at all. This keeps a network failure on your request path from crashing your application. It covers transport failures only (no connection, a timeout on the last attempt); an HTTP error response from the API always raises (Python PlatformXeAPIError) or returns an *APIError (Go).

client = PlatformXeClient(api_key=os.environ["PLATFORMXE_API_KEY"], fail_open=True)  # the default

me = client.whoami.get()
if me.get("_failed"):
    # PlatformXe unreachable: carry on with your fallback
    log.warning("PlatformXe call failed: %s", me["error"])
client := px.NewClient(px.ClientConfig{APIKey: os.Getenv("PLATFORMXE_API_KEY"), FailOpen: true})
// A transport failure on the last attempt returns {"_failed": true, "error": "..."} with a nil error.

The TypeScript SDK has no fail-open option: it throws, so wrap calls on your request path in try / catch.

const px = new PlatformXeClient({ apiKey: process.env.PLATFORMXE_API_KEY! });

try {
  const me = await px.whoami.get();
  console.log(me);
} catch (err) {
  // PlatformXe unreachable or the call failed: carry on with your fallback
  console.error('PlatformXe call failed:', err);
}

Error envelope format

Every API error response has this body:

interface ErrorResponse {
  success: false;
  error: {
    code: string;    // e.g., "RATE_LIMITED", "FORBIDDEN", "NOT_FOUND"
    message: string; // Human-readable description
  };
}

Circuit breaker

The SDK implements a circuit breaker that opens after consecutive failures, preventing cascading timeout delays.

StateBehavior
ClosedRequests flow normally
OpenRequests fail immediately, without a network request
Half-openOne probe request sent — if it succeeds, circuit closes

The circuit opens after 5 consecutive failures and resets after 30 seconds.

While the circuit is open, calls fail at once without a network request. Decide in advance what your application does when PlatformXe is unavailable, especially for calls on the request path.

Timeout handling

If a request exceeds timeoutMs, it is aborted. If retries remain, the SDK retries. Otherwise the TypeScript SDK throws a TimeoutError; the Python and Go SDKs with fail-open on return the failure result above.

try {
  const me = await px.whoami.get();
} catch (err) {
  if (err.code === 'TIMEOUT') {
    // All retries timed out
    return fallback();
  }
  throw err;
}

Error codes

CodeDescription
NETWORK_ERRORCould not connect to PlatformXe
TIMEOUTRequest timed out after all retries
RATE_LIMITEDRate limit exceeded (check Retry-After header)
EMAIL_RATE_LIMITEDHTTP 429 with Retry-After, on an email send: the sending limit for the recipient was reached. Nothing was sent or queued. Retry-After is the real wait (up to 24 hours); the Python and Go SDKs never send it again by themselves. See Send Messages
EMAIL_NOT_ACCEPTEDHTTP 503 with Retry-After, on an email send: every provider failed and the retry queue could not store the email. Nothing was sent. Send it again after Retry-After
EMAIL_PROVIDER_UNAVAILABLEHTTP 503 with Retry-After, on an email send: no email route is available. Nothing was sent or queued
BAD_REQUESTInvalid request parameters
FORBIDDENAPI key missing required scope
NOT_FOUNDResource does not exist
CIRCUIT_OPENCircuit breaker is open
IDEMPOTENCY_UNAVAILABLEHTTP 503 with Retry-After: a request sent with an idempotency key was refused because the duplicate check was temporarily unavailable. Nothing was executed — retry with the same key.