# NexusEndpointRouteBuilderExtensions Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable.http/microsoft.aspnetcore.builder.nexusendpointroutebuilderextensions/)

## MapNexusOperation(IEndpointRouteBuilder, string, Delegate) {#mapnexusoperation-this-microsoft-aspnetcore-routing-iendpointroutebuilder-string-b93f4f74}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.http/microsoft.aspnetcore.builder.nexusendpointroutebuilderextensions/methods/mapnexusoperation-this-microsoft-aspnetcore-routing-iendpointroutebuilder-string-b93f4f74/)

[Source](https://github.com/dotnet/orleans/blob/4e887e9c914a2f2647fb3c81de963511521dd9cb/src/Orleans.Durable.Http/NexusEndpointRouteBuilderExtensions.cs#L103-L147)

```csharp
public static RouteGroupBuilder MapNexusOperation(this IEndpointRouteBuilder service, string operation, Delegate handler)
```

Maps the Nexus operation `operation`, whose handler returns durable work, such as `grain.ChargeAsync(input)`, which a start request starts as an operation.

### Parameters

- `service` (`IEndpointRouteBuilder`): The group which [NexusEndpointRouteBuilderExtensions](/orleans/docs/api/csharp/microsoft.orleans.durable.http/microsoft.aspnetcore.builder.nexusendpointroutebuilderextensions/) returns.
- `operation` (`string`): The operation name, such as `charge`, of URL-unreserved characters.
- `handler` (`Delegate`): A delegate which binds the operation's input, such as from the JSON request body, and other parameters like a Minimal API handler, and returns a durable grain call or a reference to an existing task, which `grain.GetDurableTask<T>(id)` returns, directly or through a `System.Threading.Tasks.Task-1` or `System.Threading.Tasks.ValueTask-1`. It runs for each start request, including retries, and only creates the work.

### Returns

A group builder which configures the operation's start and cancel endpoints.

### Exceptions

- `System.ArgumentException`: `operation` is empty or has characters other than URL-unreserved ones, or `handler` doesn't return durable work.

## MapNexusService(IEndpointRouteBuilder, string, string?) {#mapnexusservice-this-microsoft-aspnetcore-routing-iendpointroutebuilder-string-s-df73d914}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable.http/microsoft.aspnetcore.builder.nexusendpointroutebuilderextensions/methods/mapnexusservice-this-microsoft-aspnetcore-routing-iendpointroutebuilder-string-s-df73d914/)

[Source](https://github.com/dotnet/orleans/blob/4e887e9c914a2f2647fb3c81de963511521dd9cb/src/Orleans.Durable.Http/NexusEndpointRouteBuilderExtensions.cs#L46-L48)

```csharp
public static RouteGroupBuilder MapNexusService(this IEndpointRouteBuilder endpoints, string service, string? scope = null)
```

Maps the Nexus service `service`, whose operations [NexusEndpointRouteBuilderExtensions](/orleans/docs/api/csharp/microsoft.orleans.durable.http/microsoft.aspnetcore.builder.nexusendpointroutebuilderextensions/) maps.

### Parameters

- `endpoints` (`IEndpointRouteBuilder`): The endpoint route builder, whose prefix is the Nexus endpoint, such as `/nexus`.
- `service` (`string`): The service name, such as `payments.v1`, of URL-unreserved characters.
- `scope` (`string?`): The scope of the service's operations, or `null` for `nexus/{service}`.

### Returns

A group builder which maps the service's operations and configures its endpoints.

### Exceptions

- `System.ArgumentException`: `service` is empty or has characters other than URL-unreserved ones.
