Skip to Content
v1.5Official documentation for the LX CloudPos API · stable in production

Client retries

When to retry

CodeRetry?Strategy
2xxNo (success)—
400NoFix the body
401NoCheck the API key
403NoRequest the scope
404NoCheck the document key
409NoConflicting Idempotency-Key
413NoReduce the body
429YesRespect Retry-After
500YesExponential backoff
502YesExponential backoff
503YesAggressive backoff (system down)
504YesExponential backoff
Client timeoutYesWith Idempotency-Key

Exponential backoff algorithm with jitter

async function backoff(intento) { const base = Math.min(1000 * Math.pow(2, intento), 30000); // max 30s const jitter = Math.random() * 1000; await sleep(base + jitter); } for (let i = 0; i < 5; i++) { try { return await llamarAPI(); } catch (err) { if (esTransitorio(err) && i < 4) { await backoff(i); continue; } throw err; } }