| name | api-endpoints |
| description | API endpoint creation, OpenAPI configuration, Kiota client generation, and API security hardening. Use when creating Minimal API endpoints, setting up API projects, generating Kiota clients, configuring OpenAPI/Swagger, or hardening API security (rate limiting, CORS, validation, HTTPS). |
API Endpoints Skill
Expert for creating and configuring .NET Minimal API endpoints with full OpenAPI, Kiota client generation, and security hardening.
When to Use
- Creating a new API endpoint (CRUD, search, download, etc.)
- Setting up a new API project from scratch
- Generating or regenerating a Kiota client from an OpenAPI spec
- Adding OpenAPI configuration (transformers, document generation)
- Hardening API security (validation, rate limiting, CORS, HTTPS, auth)
- Auditing existing endpoints for compliance with patterns
Workflows
New API Endpoint
- Read
references/endpoints.md for the complete pattern
- Create the endpoint class with
MapGroup, version set, and auth
- Use named static methods (never inline lambdas) with
[FromServices], [FromBody], [FromRoute], [FromQuery]
- Return
Results<T1, T2> with TypedResults.* factory methods
- Declare all produces metadata:
.Produces<T>(statusCode) for success + .Produces(statusCode) for errors
- Add
.WithValidation<T>() on POST/PUT routes + .ProducesValidationProblem()
- Register the endpoint in Program.cs via
.Map{Entity}Endpoints("Bearer", "ApiKey")
New API Project
- Configure
.csproj with OpenAPI document generation properties and Kiota MSBuild target (see references/openapi.md)
- Add
Microsoft.Extensions.ApiDescription.Server package reference
- Set up
Program.cs with combined document + schema transformers in a single AddOpenApi() call (see references/openapi.md)
- Configure security middleware in order:
UseHttpsRedirection โ UseCors โ UseRateLimiter โ UseAuthentication โ UseAuthorization (see references/security.md)
- Pin Kiota version in
.config/dotnet-tools.json with rollForward: false
New Kiota Client
- Follow the naming convention:
{ApplicationName}.Clients.Api (single-app) or {ApplicationName}.Clients.{AppName} (multi-app)
- Create the client
.csproj with Microsoft.Kiota.Bundle and Microsoft.Extensions.Http (see references/kiota.md)
- Create the
Extensions/ServiceCollectionExtensions.cs for DI registration with IAuthenticationProvider + HttpClientRequestAdapter (see references/kiota.md)
- Commit all client source files:
Api/, Models/, ApiClient.cs, kiota-lock.json
- The API project's MSBuild
OpenAPI target regenerates the client on every build
Security Hardening
- Validation: Data Annotations on request models +
.WithValidation<T>() filter on every POST/PUT route (see references/security.md)
- Rate limiting:
AddRateLimiter with fixed window (1000 req/min) + UseRateLimiter middleware
- CORS: Explicit origins (never
AllowAnyOrigin in production), call UseCors before UseAuthorization
- HTTPS:
UseHttpsRedirection for all environments
- Auth: Group-level
RequireAuthorization with RequireAuthenticatedUser() and authentication schemes
Key Rules (non-negotiable)
- Named static methods โ never inline lambdas
TypedResults.* โ not Results.*
- Explicit
.Produces<T>() on every route (success + errors)
.WithValidation<T>() + .ProducesValidationProblem() on POST/PUT
[FromServices], [FromBody], [FromRoute], [FromQuery] on all parameters
CancellationToken cancellationToken = default on all async methods
- Individual command parameters โ never pass model objects to commands
- Document + schema transformers in a single
AddOpenApi() call โ no document name parameter
Microsoft.Kiota.Bundle โ not individual Kiota packages
- API
.csproj OpenAPI target runs on every build, not just Debug
- Rate limiting, CORS, HTTPS middleware must be present
- Middleware order: HTTPS โ CORS โ RateLimiter โ Auth
References
references/endpoints.md โ Complete endpoint code patterns, route metadata, TypedResults
references/openapi.md โ .csproj configuration, document/schema transformers, build-time generation
references/kiota.md โ Client naming, project setup, DI registration, MSBuild target
references/security.md โ Validation filter, rate limiting, CORS, HTTPS, auth patterns
Templates
.ai/reference/templates/endpoint.cs.txt โ Endpoint class template
.ai/reference/templates/command-handler.cs.txt โ Command handler template
.ai/reference/templates/query-handler.cs.txt โ Query handler template
Patterns
.ai/patterns/api-patterns.md โ Full API endpoint patterns reference
.ai/reference/critical-rules.md โ Non-negotiable critical rules (rules 16-21 for API)