Default Behavior
By default, the client retries requests up to 2 times with exponential back-off:Which Errors Are Retried
The SDK retries different error codes based on their characteristics:Always Retried
Rate Limits (429) - Retried for all HTTP methods:retry-after header when present.
Retried for Idempotent Methods
Server Errors (500, 503) - Only retried for GET and DELETE:Server errors are only retried for idempotent methods (GET, DELETE) to avoid duplicate side effects like creating the same page twice.
Never Retried
These errors indicate client problems and are never retried:unauthorized(401)object_not_found(404)validation_error(400)invalid_request(400)conflict_error(409)- Client-side errors (timeout, invalid path)
Retry Configuration
Customize retry behavior withRetryOptions:
RetryOptions
Maximum number of retry attempts. Set to
0 to disable retries.Initial delay between retries in milliseconds. Used as base for exponential back-off when
retry-after header is absent.Maximum delay between retries in milliseconds. Caps both exponential back-off and
retry-after values.Disabling Retries
Setretry: false to disable all automatic retries:
- You want full control over retry logic
- You’re implementing your own retry wrapper
- You need predictable request timing for testing
Retry Delay Calculation
The SDK uses two strategies to determine retry delays:1. Retry-After Header (Preferred)
When the API includes aretry-after header, the SDK waits for that duration:
retry-after header supports two formats:
- Delta-seconds:
retry-after: 120(wait 120 seconds) - HTTP-date:
retry-after: Wed, 21 Oct 2026 07:28:00 GMT
2. Exponential Back-off with Jitter
When noretry-after header is present, the SDK uses exponential back-off with jitter:
initialRetryDelayMs: 1000:
- Attempt 1: 750-1500ms (1000 * 1 * (0.5 to 1.5))
- Attempt 2: 1500-3000ms (1000 * 2 * (0.5 to 1.5))
- Attempt 3: 3000-6000ms (1000 * 4 * (0.5 to 1.5))
Examples
Aggressive Retries
Retry quickly with more attempts:Conservative Retries
Retry slowly with fewer attempts:No Retries
Disable retries completely:Custom Retry Logic
Implement your own retry wrapper:Retry Logging
SetlogLevel to INFO or DEBUG to see retry attempts:
Best Practices
- Use default retry settings - They work well for most use cases
- Don’t disable retries - Unless you have a specific reason
- Respect rate limits - The SDK handles this automatically
- Monitor retry patterns - Frequent retries may indicate API issues
- Set appropriate timeouts - Match
timeoutMsto your retry strategy