Configure network retries
masterThe library automatically retries failed requests that are safe to retry. You can control this behavior using the maxNetworkRetries option.
- Disable retries: Set
maxNetworkRetries: 0. - Custom retries: Set a higher integer to attempt multiple retries with exponential backoff. Idempotency keys are automatically added where appropriate.
Retries can be configured globally during initialization or overridden on a per-request basis.
// Disable retries globally
const stripeClient = Stripe('sk_test_...', {
maxNetworkRetries: 0,
});
// Retry twice globally
const stripeClient = Stripe('sk_test_...', {
maxNetworkRetries: 2,
});
// Override for a specific request
stripeClient.customers.create(
{
email: 'customer@example.com',
},
{
maxNetworkRetries: 2,
}
);