C# SDK

Install and start using the C# SDK.

Intro

The Decionis Policy Evaluation API SDK provides access to the Decionis Policy Evaluation API REST APIs.

Decionis evaluates captured execution intent against versioned policies before the caller performs the action. SDKs delegate policy judgment to this service and locally enforce the signed decision. New SDK API keys can be associated with an industry so Decionis provisions a starter encoded policy binding server-side; applications do not receive or implement policy logic.

Installation

Add the SDK as a project reference into your solution:

Terminal
dotnet add reference <path-to-sdk>/src/DecionisPolicyEvaluationApi/DecionisPolicyEvaluationApi.csproj

The project takes its build settings from the files around it, so reference it in place.

Quick Start

Dependency Injection

Register the client with IServiceCollection and resolve it from the container. The HttpClient is managed by IHttpClientFactory. Configure the client's behavior through DecionisPolicyEvaluationApiClientOptions.

C#
services.AddDecionisPolicyEvaluationApiClient(options =>
{
    options.ApiKeyAuth = "YOUR_BEARER_TOKEN";
    options.OperatorEntraAuth = "YOUR_BEARER_TOKEN";
    options.AccountSessionCookie = "YOUR_API_KEY";
    options.HostedGatewayTcpRouteCredential = "YOUR_BEARER_TOKEN";
    options.HostedGatewayTcpBrokerAuth = "YOUR_BEARER_TOKEN";
    options.HostedGatewayWorkerAuth = "YOUR_BEARER_TOKEN";
    options.ProtocolServiceAuth = "YOUR_BEARER_TOKEN";
    options.CommerceAccountsOAuth = "YOUR_BEARER_TOKEN";
    options.CommerceConnectedTransport = "YOUR_BEARER_TOKEN";
    options.AccountsWorkspaceCredentialService = "YOUR_BEARER_TOKEN";
    options.AccountsNativeEnrollmentService = "YOUR_BEARER_TOKEN";
    options.DrupalSiteKey = "YOUR_BEARER_TOKEN";
    options.Environment = ServerEnvironment.Production;
    // TODO: configure more client options here
});

Direct Instantiation

Create the client by passing an HttpClient you manage yourself. Configure the client's behavior through DecionisPolicyEvaluationApiClientOptions.

C#
var httpClient = new HttpClient();
// TODO: configure more client options here
var options = new DecionisPolicyEvaluationApiClientOptions
{
    ApiKeyAuth = "YOUR_BEARER_TOKEN",
    OperatorEntraAuth = "YOUR_BEARER_TOKEN",
    AccountSessionCookie = "YOUR_API_KEY",
    HostedGatewayTcpRouteCredential = "YOUR_BEARER_TOKEN",
    HostedGatewayTcpBrokerAuth = "YOUR_BEARER_TOKEN",
    HostedGatewayWorkerAuth = "YOUR_BEARER_TOKEN",
    ProtocolServiceAuth = "YOUR_BEARER_TOKEN",
    CommerceAccountsOAuth = "YOUR_BEARER_TOKEN",
    CommerceConnectedTransport = "YOUR_BEARER_TOKEN",
    AccountsWorkspaceCredentialService = "YOUR_BEARER_TOKEN",
    AccountsNativeEnrollmentService = "YOUR_BEARER_TOKEN",
    DrupalSiteKey = "YOUR_BEARER_TOKEN",
    Environment = ServerEnvironment.Production,
};
var client = new DecionisPolicyEvaluationApiClient(httpClient, options);

On this page