# `Daraja.HTTP.Retry`
[🔗](https://github.com/okothkongo/daraja/blob/v0.1.1/lib/daraja/http/retry.ex#L1)

Opt-in HTTP retry with exponential backoff and jitter.

Disabled by default. Enable for idempotent operations such as OAuth token
fetches:

    config :daraja, :http_retry,
      enabled: true,
      max_attempts: 3,
      base_ms: 100,
      max_ms: 2_000,
      jitter: true

`Daraja.Auth.fetch_token/1` respects this config. Payment POST endpoints
do **not** retry automatically — wrap your own calls with `run/2` when you
have explicit idempotency guarantees.

# `config`

```elixir
@type config() :: %{
  enabled: boolean(),
  max_attempts: pos_integer(),
  base_ms: pos_integer(),
  max_ms: pos_integer(),
  jitter: boolean()
}
```

# `run`

```elixir
@spec run(
  (-&gt; term()),
  keyword()
) :: term()
```

Runs `fun/0`, retrying `{:error, reason}` results when retry is enabled and
`reason` is retryable.

Pass `enabled: true` in `opts` to force retries for a single call regardless
of application config.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
