UniOne.AspNetCore 2.3.2

dotnet add package UniOne.AspNetCore --version 2.3.2
                    
NuGet\Install-Package UniOne.AspNetCore -Version 2.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UniOne.AspNetCore" Version="2.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UniOne.AspNetCore" Version="2.3.2" />
                    
Directory.Packages.props
<PackageReference Include="UniOne.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UniOne.AspNetCore --version 2.3.2
                    
#r "nuget: UniOne.AspNetCore, 2.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UniOne.AspNetCore@2.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UniOne.AspNetCore&version=2.3.2
                    
Install as a Cake Addin
#tool nuget:?package=UniOne.AspNetCore&version=2.3.2
                    
Install as a Cake Tool

UniOne ASP.NET Core

ASP.NET Core License: MIT

ASP.NET Core integration of the UniOne .NET (C#) SDK (UniOne): the API client in the DI container (IServiceCollection), a webhook endpoint with signature check.

API reference · Docs for LLMs: llms.txt

Install

dotnet add package UniOne.AspNetCore

Requirements: .NET 8, ASP.NET Core 8+.

Configuration

Get an API key in the control panel and keep it in the environment, never in code:

export UNIONE_API_KEY="your-api-key"

Settings are read from the environment by default:

// appsettings.json (or the environment: UNIONE_API_KEY, UNIONE_HOST, ...)
{
  "UniOne": {
    "ApiKey": "YOUR_API_KEY",
    "Host": "us1.unione.io",
    "Webhook": { "Path": "/unione/webhook" }
  }
}

us1.unione.io in the example is for an account on another datacenter; without the host setting the package uses api.unione.io.

Option Environment variable Default Description
UniOne:ApiKey UNIONE_API_KEY User or project API key (required).
UniOne:Host UNIONE_HOST api.unione.io API host (datacenter: api.unione.io, eu1.unione.io, us1.unione.io) or a full base URL.
UniOne:Timeout UNIONE_TIMEOUT 30 Request timeout, seconds.
UniOne:Webhook:Key UNIONE_WEBHOOK_KEY API key the webhooks are signed with (the key of the user/project of the webhook), if it differs from the API key.
UniOne:Webhook:Path UNIONE_WEBHOOK_PATH /unione/webhook Path of the webhook endpoint.

AddUniOne() returns a builder: AddWebhookHandler<T>() registers a scoped IUniOneWebhookHandler; every registered handler gets the whole notification (HandleAsync) and each of its events (HandleEventAsync), both methods have empty default implementations. MapUniOneWebhook(path) maps the endpoint (path from the options by default) and returns its convention builder (.RequireHost(...), .DisableAntiforgery()...). There is no mail transport: ASP.NET Core has no mailer, send with client.Email.SendAsync(...). The webhook endpoint allows anonymous requests (AllowAnonymous(), also under a fallback authorization policy): the notifications are checked by their signature. UNIONE_TIMEOUT and UNIONE_WEBHOOK_PATH are used only when the timeout / the path is not set in the configuration.

Webhooks

The endpoint answers GET with 200 OK (the URL check of webhook/set) and accepts the POST notifications: it checks the auth field (MD5 of the request body in which the auth value is replaced by the API key), answers 401 to a wrong signature, and passes the notification and each of its events to the application.

using UniOne.Wrapper;
using UniOne.Api.Webhook.Model;

builder.Services.AddUniOne(builder.Configuration).AddWebhookHandler<EmailEvents>();
// ...
app.MapUniOneWebhook(); // /unione/webhook

public class EmailEvents(ILogger<EmailEvents> logger) : IUniOneWebhookHandler
{
    public Task HandleEventAsync(WebhookCallbackEventsByUserItemEventsItem e, WebhookCallbackEventsByUserItem user, CancellationToken cancellationToken)
    {
        logger.LogInformation("UniOne event {Name}: {Email}", e.EventName, e.EventData?.Email);
        return Task.CompletedTask;
    }
}

Register the URL of the endpoint with webhook/set, e.g. https://example.com/unione/webhook.

Answer 200 within 3 seconds and process the events in the background (a queue): otherwise UniOne repeats the request every 10 minutes for 24 hours (retry_count grows), and a handler that failed every request for at least 10 events of a day is turned inactive. The handler must take at least 5 parallel requests of up to 100 events each; deduplicate, a repeat delivers the same events again.

API client

Every section of the API is available on the client, see the SDK docs.

using UniOne.Wrapper;
using UniOne;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddUniOne(builder.Configuration);
var app = builder.Build();

app.MapGet("/usage", async (UniOneClient client) =>
    (await client.System.InfoAsync()).Accounting?.EmailsSent);

Sending through the API

The client calls email/send with all of its options: templates, substitutions, metadata, tracking. Fields of the request and other examples: .NET (C#) SDK docs.

using UniOne;
using UniOne.Api.Email.Model;
using UniOne.Common.Model;
using Recipient = UniOne.Api.Email.Model.MessageObjectRecipientsItem;

app.MapPost("/send", async (UniOneClient client) =>
{
    var response = await client.Email.SendAsync(new EmailSendRequest
    {
        Message = new MessageObject
        {
            Recipients = [Recipient.FromAddress("Alex <alex@example.com>")],
            FromEmail = "shop@example.com",
            FromName = "Shop",
            Subject = "Your order",
            Body = BodyObject.FromHtml("<p>Hello, {{to_name}}! Your order has shipped.</p>"),
        },
    });
    Console.WriteLine(response.JobId);
});

Errors

The API client throws the SDK ApiException: Kind tells what failed (api, network, timeout, invalid_response, invalid_request), IsRetryable whether a repeat may succeed (network, timeout, HTTP 429 and 5xx), Hint how to fix an API error and ApiMessage the message of the API.

No domain yet: the test sandbox domain

Until your domain is verified, send from the sandbox domain: a test domain every account has, already verified, with DKIM and SPF set. It delivers only to addresses you confirm (the confirmation link comes by email, valid 48 hours), up to 100 emails a day. The sandbox domain is deleted 31 days after it was created, but you can get it again: the next domain/get-sandbox-domain call creates a new one (with a new name, so read it from the call, do not hardcode it).

The examples use the API client of the package (see the configuration above).

using UniOne;
using UniOne.Api.ConfirmedEmail.Model;
using UniOne.Api.Email.Model;
using UniOne.Common.Model;
using Recipient = UniOne.Api.Email.Model.MessageObjectRecipientsItem;

app.MapPost("/sandbox", async (UniOneClient client) =>
{
    // 1. Your sandbox domain: created on the first call, the same one afterwards
    var sandbox = await client.Domain.GetSandboxDomainAsync();

    // 2. Confirm your inbox: UniOne sends a link, click it within 48 hours
    await client.ConfirmedEmail.CreateAsync(new ConfirmedEmailRequest { Email = "you@example.com" });

    // 3. Send from any address on the sandbox domain to the confirmed one
    await client.Email.SendAsync(new EmailSendRequest
    {
        Message = new MessageObject
        {
            Recipients = [Recipient.FromAddress("you@example.com")],
            FromEmail = $"noreply@{sandbox.Domain}",
            Subject = "Hello from UniOne",
            Body = BodyObject.FromHtml("<p>It works!</p>"),
        },
    });
});

<details> <summary>Sandbox limits</summary>

  • Sends only to confirmed addresses: up to 10 per account.
  • Up to 100 emails a day.
  • The sandbox domain expires after 31 days; call domain/get-sandbox-domain again to get a new one.
  • Works only with the account API key, not a project key.
  • Not listed in domain/list; the other domain/* methods do not apply to it.

The sandbox is for development and testing. Do not use a sandbox domain as the sender in production.

</details>

<details> <summary>The same with curl</summary>

BASE=https://api.unione.io/en/transactional/api/v1

curl -s -X POST $BASE/domain/get-sandbox-domain.json \
  -H "Content-Type: application/json" -H "X-API-KEY: $UNIONE_API_KEY" -d '{}'

curl -s -X POST $BASE/confirmed-email/create.json \
  -H "Content-Type: application/json" -H "X-API-KEY: $UNIONE_API_KEY" \
  -d '{"email": "you@example.com"}'

curl -s -X POST $BASE/email/send.json \
  -H "Content-Type: application/json" -H "X-API-KEY: $UNIONE_API_KEY" \
  -d '{
        "message": {
          "recipients": [
            {
              "email": "you@example.com"
            }
          ],
          "from_email": "noreply@<sandbox-domain>",
          "subject": "Hello from UniOne",
          "body": {
            "html": "<p>It works!</p>"
          }
        }
      }'

</details>

Going to production

1. Verify your sending domain. domain/get-dns-records returns the verification record, the DKIM key and the DMARC target; add the records at your DNS provider, then domain/validate-verification-record and domain/validate-dkim.

Type Host Value Where it comes from
TXT @ unione-validate-hash=… verification-record of the response, as is
TXT <selector>._domainkey (the selector is on the domain page of the control panel, e.g. us) v=DKIM1; k=rsa; p=<dkim> dkim of the response after v=DKIM1; k=rsa; p=
TXT @ v=spf1 include:spf.unione.io ~all not in the response; add the include to your SPF record if you have one
CNAME _dmarc <domain>.dmarc.… dmarc of the response (UniOne publishes the DMARC policy); keep your own DMARC TXT record instead if the domain has one

2. Make sending reliable.

Retries 429 and 5xx with backoff and the same idempotence_key; fix other errors instead of retrying
Limits 500 recipients and 10 MB per request, attachments included: base64 makes a file about a third larger
Body always html or plaintext (a template can supply it)
Delivery status a webhook, not polling
Queue send from a background job, not inside the web request
Config from_email from config, so the sandbox → production switch needs no code change
Defaults keep the unsubscribe footer and tracking; changing them needs UniOne support

Help

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.2 101 11/5/2026
2.2.4 106 10/23/2026
2.1.3 107 10/20/2026