.NET SDK
Sentriq is a server-only SDK — it holds a secret key and must never run in browser-facing (Blazor WebAssembly) or mobile (MAUI) code. For browser-side tracking, see the Browser SDK. Targets .NET 8, built on System.Net.Http.HttpClient and System.Text.Json — zero third-party dependencies. Not yet published to NuGet.org — install via a project reference or a locally-packed .nupkg against a checked-out commit until a release process exists.
Install
dotnet add package SentriqNot yet resolvable from NuGet.org — see § Publication status below for the real, current install path.
Initialize
using Sentriq;
using var client = new SentriqClient(new SentriqClientOptions
{
SecretKey = Environment.GetEnvironmentVariable("SENTRIQ_SECRET_KEY")!,
// Optional. Defaults to the hosted Sentriq API.
ApiUrl = Environment.GetEnvironmentVariable("SENTRIQ_API_URL"),
// Optional. Defaults to 10 seconds.
Timeout = TimeSpan.FromSeconds(10),
// Optional. Automatic retries for idempotent GET requests only. Default 2.
MaxRetries = 2,
});Resources
await client.Events.RetrieveAsync(eventId, cancellationToken);
await client.Events.ListAsync(environmentId, new ListEventsParams(), cancellationToken);
await client.Events.SubmitOutcomeAsync(eventId, new SubmitOutcomeRequest { Label = OutcomeLabel.Legitimate }, cancellationToken);
await client.Events.ListOutcomesAsync(eventId, page, cancellationToken);
await client.Devices.RetrieveAsync(deviceId, cancellationToken);
await client.Devices.ListAsync(environmentId, page, cancellationToken);
await client.Devices.ListEventsAsync(deviceId, page, cancellationToken);
await client.Devices.ListAccountsAsync(deviceId, page, cancellationToken);
await client.Devices.ListSignalsAsync(deviceId, cancellationToken);
await client.Devices.ListResolutionsAsync(deviceId, page, cancellationToken);
await client.Devices.TrustAsync(environmentId, externalAccountId, deviceId, cancellationToken);
await client.Devices.RevokeTrustAsync(environmentId, externalAccountId, deviceId, cancellationToken);
await client.Accounts.ListDevicesAsync(environmentId, externalAccountId, page, cancellationToken);
await client.Risk.ListAsync(environmentId, new ListRiskAssessmentsParams(), cancellationToken);
await client.Network.ListAsync(environmentId, page, cancellationToken);
client.Webhooks.VerifySignature(rawBody, timestamp, signature, secret);client.Policies, no client.Webhooks.CreateAsync()/ListAsync()/UpdateAsync()/DeleteAsync(), and no event ingestion method: POST /v1/events only accepts a public key, which this server SDK never holds. Trust methods are always Account+Device-scoped — there is no device-global TrustAsync(deviceId) form. See the Node.js SDK docs for the full explanation.Async-first, cancellation-aware
Every network operation is async Task<T> and accepts a trailing CancellationToken — the idiomatic .NET convention. There is no synchronous/blocking wrapper. Cancellation is honored before the request is built, during the in-flight HTTP call, and during a retry backoff wait — cancelling mid-backoff stops immediately rather than sleeping out the remaining schedule first.
Errors
try
{
await client.Events.RetrieveAsync(eventId);
}
catch (SentriqAuthenticationException e)
{
// 401
}
catch (SentriqNotFoundException e)
{
// 404
}
catch (SentriqValidationException e)
{
// 422 — e.Fields
}
catch (SentriqRateLimitException e)
{
// 429 — e.RetryAfterSeconds
}
catch (SentriqApiException e)
{
// any other 4xx/5xx — e.StatusCode, e.RequestId
}
catch (SentriqTransportException e)
{
// network failure — e.IsTimeout
}A real exception hierarchy rooted at SentriqException, matching Node/PHP/Java's own convention rather than Go's flat sentinel-error style. A genuine caller cancellation is never wrapped — it always propagates as a plain OperationCanceledException, so ordinary catch (OperationCanceledException) handling keeps working exactly as it would for any other .NET async API.
Retries
A GET request retries automatically (bounded exponential backoff) on a network error, timeout, 429, or 5xx, honoring Retry-After (seconds or an HTTP-date). Mutations (POST/DELETE) are never automatically retried — this API has no generic idempotency-key mechanism today, so blindly retrying a mutation could double-apply it.
Webhook signatures
bool valid = client.Webhooks.VerifySignature(rawBody, timestamp, signature, webhookSecret);HMAC-SHA256 over the same canonical string as every other SDK, compared with CryptographicOperations.FixedTimeEquals — constant-time, not a plain byte-array equality check.
Version compatibility
.NET 8. Zero third-party dependencies.
Publication status
Not published to NuGet.org — no release process exists for this package yet. Reference the project directly from a checkout of this repository, or pack and consume a local .nupkg. dotnet add package Sentriq above is this package's real, intended install command once published — not a claim that it resolves today.