# DurableHttpServiceCollectionExtensions.AddDurableHttpClient(IServiceCollection, string, Action&lt;DurableHttpClientOptions&gt;)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable.http/microsoft.extensions.dependencyinjection.durablehttpservicecollectionextensions/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.durable.http/microsoft.extensions.dependencyinjection.durablehttpservicecollectionextensions/methods/)

[Source](https://github.com/dotnet/orleans/blob/4e887e9c914a2f2647fb3c81de963511521dd9cb/src/Orleans.Durable.Http/DurableHttpServiceCollectionExtensions.cs#L62-L78)

```csharp
public static IHttpClientBuilder AddDurableHttpClient(this IServiceCollection services, string name, Action<DurableHttpClientOptions>? configureOptions = null)
```

Adds an [IDurableHttpClient](/orleans/docs/api/csharp/microsoft.orleans.durable.http/orleans.durable.http.idurablehttpclient/), which durable tasks inject as a keyed service named `name`, and returns the builder of the named `System.Net.Http.HttpClient` which it sends requests with.

### Parameters

- `services` (`IServiceCollection`): The silo's service collection.
- `name` (`string`): The client's name, which keys the service and names the `System.Net.Http.HttpClient`.
- `configureOptions` (`Action<DurableHttpClientOptions>`): Configures the client, or `null` for the defaults.

### Returns

The builder of the named client, whose first handler is a [DurableIdempotencyKeyHandler](/orleans/docs/api/csharp/microsoft.orleans.durable.http/orleans.durable.http.durableidempotencykeyhandler/), so handlers which the builder adds, such as a resilience handler, retry requests with their keys.

### Examples

```csharp
services.AddDurableHttpClient("payments")
                 .ConfigureHttpClient(client => client.BaseAddress = new("https://payments.example"))
                 .AddStandardResilienceHandler();
            
             public sealed class OrderGrain([FromKeyedServices("payments")] IDurableHttpClient payments) : DurableGrain, IOrderGrain
```
