ASP.NET Core › Endpoint Metadata, Route Constraints & Templates

What is route grouping via MapGroup, and how does it let you apply shared route prefixes, metadata, and filters to a set of related minimal API endpoints?

Intermediate

Answer

MapGroup("/prefix") returns a RouteGroupBuilder that automatically prepends the given prefix to every endpoint mapped within it, and any metadata, authorization requirements, or filters applied to the group (via .RequireAuthorization(), .AddEndpointFilter(), .WithTags()) automatically apply to all endpoints in that group, reducing repetition for a cohesive set of related routes.
var productsGroup = app.MapGroup("/api/products")
    .RequireAuthorization()
    .WithTags("Products");

productsGroup.MapGet("/", GetAll);           // -> /api/products, requires auth
productsGroup.MapGet("/{id}", GetById);      // -> /api/products/{id}, requires auth
productsGroup.MapPost("/", Create);          // -> /api/products, requires auth
Real-world example A minimal API organizes all product-related endpoints under one MapGroup call, applying shared authorization and Swagger tagging once at the group level instead of repeating the same configuration on every individual endpoint registration.

Common follow-ups: Can route groups be nested for even finer-grained shared configuration?;How does grouping interact with API versioning's own grouping mechanisms?