01
NuGet
Install one package.
Terminalbash
dotnet add package Apirelio.AspNetCore --version 0.2.0Program.cscsharp
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApirelio(builder.Configuration);
var app = builder.Build();
app.UseApirelio();
app.MapControllers();
app.Run();02
Options binding
Set project properties.
Standard ASP.NET Core configuration applies. Environment variables use names such as Apirelio__ApiKey.
appsettings.jsonjson
{
"Apirelio": {
"ApiKey": "apr_live_your_key",
"Endpoint": "https://apirelio.com",
"Service": "billing-api",
"Environment": "production",
"Release": "2026.08.07.1",
"IncludeRoutes": ["/api/**"],
"ExcludeRoutes": ["/api/health"],
"MetadataKeys": ["region"]
}
}03
B2B context
Resolve a stable customer.
Resolvers may be scoped and run after the endpoint. Prefer stable internal IDs and omit personal data.
Customer resolvercsharp
builder.Services.AddScoped<IApirelioCustomerResolver, CustomerResolver>();
sealed class CustomerResolver : IApirelioCustomerResolver
{
public ApirelioCustomer? Resolve(HttpContext context)
{
var account = context.Items["account"] as Account;
return account is null ? null : new(
account.Id.ToString(), account.Name, account.Plan);
}
}04
Optional context
Add applications, metadata and error codes.
Optional resolverscsharp
builder.Services.AddScoped<IApirelioApplicationResolver, ApplicationResolver>();
builder.Services.AddScoped<IApirelioMetadataResolver, MetadataResolver>();
// MetadataResolver may return only configured scalar keys.
// Error-code and resolver failures are isolated from the response.05
Request lifecycle
Endpoint routes, hosted delivery.
The middleware reads the matched RouteEndpoint after downstream execution. Capture only enqueues; the hosted worker batches, retries transient failures and drains during shutdown.
Privacy boundary
Bodies, query strings, credentials, cookies, email addresses and client IP addresses are never included.