Gracefully handle transient API failures by retrying with increasing delays. Essential for any workflow that calls external services.
Rendering diagram…
Use retry with backoff when:
This pattern only helps with transient failures. If the API requires different credentials or the endpoint URL is wrong, retrying won't help. Always check the error type before retrying.
On failure, wait an increasing amount of time before each retry. This prevents hammering a struggling service and respects rate limits.
| Attempt | Wait Time | Cumulative Time | Action |
|---|---|---|---|
| 1 | 0s | 0s | Initial request |
| 2 | 2s | 2s | First retry |
| 3 | 4s | 6s | Second retry |
| 4 | 8s | 14s | Third retry |
| 5 | 16s | 30s | Fourth retry |
| — | — | 30s | Give up → error handling |
The formula: wait = base_delay × 2^(attempt - 1)
Add jitter (random ±20%) to prevent multiple workflows from retrying at the exact same moment (thundering herd problem).
max_retries = 4
base_delay = 2 seconds
attempt = 0
LOOP while attempt < max_retries:
result = call_api()
IF result.success:
BREAK → continue workflow
IF result.error is NOT retryable:
BREAK → go to error handler
wait_time = base_delay × 2^attempt + random(-20%, +20%)
PAUSE for wait_time
attempt = attempt + 1
IF attempt >= max_retries:
→ Circuit breaker / error notification
Not all errors are worth retrying:
| Error Type | Retryable? | Example |
|---|---|---|
| Timeout (408, ETIMEDOUT) | Yes | Server was busy |
| Rate limited (429) | Yes | Too many requests — respect Retry-After header |
| Server error (500, 502, 503) | Yes | Transient server issue |
| Bad request (400) | No | Your data is wrong — fix it |
| Unauthorized (401, 403) | No | Credentials are wrong |
| Not found (404) | No | Endpoint or resource doesn't exist |
Workflow Cloud approach:
RPA approach:
retryCount < maxRetries AND NOT successAfter max retries are exhausted:
Never retry without a delay. Immediate retries create a tight loop that can overwhelm the target service and get your IP blocked.
Retry-After: 60, wait 60 seconds regardless of your backoff schedule.Stop calling a failing dependency before it drags you down with it. After a threshold of errors, open the circuit, fail fast for a cooldown period, then cautiously let traffic back in.
Capture workflow items that fail processing after all retry attempts are exhausted. Store them safely for investigation, manual correction, and replay — never silently lose data.