UniOne.AspNetCore 2.1.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package UniOne.AspNetCore --version 2.1.3
                    
NuGet\Install-Package UniOne.AspNetCore -Version 2.1.3
                    
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.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UniOne.AspNetCore" Version="2.1.3" />
                    
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.1.3
                    
#r "nuget: UniOne.AspNetCore, 2.1.3"
                    
#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.1.3
                    
#: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.1.3
                    
Install as a Cake Addin
#tool nuget:?package=UniOne.AspNetCore&version=2.1.3
                    
Install as a Cake Tool

UniOne ASP.NET Core 2.1.3

Web API 1.90

Quickstart guide: Send emails with .NET (C#) · Docs for LLMs: llms.txt · API reference

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.

Install

dotnet add package UniOne.AspNetCore

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

Get an API key

  1. Sign up at cp.unione.io.
  2. Copy your API key from Settings → Security → API.
  3. Put it in an environment variable:
export UNIONE_API_KEY="your-api-key"

The package reads it from UNIONE_API_KEY (see the configuration below).

Server-side only. Use this package in backend code: API routes, server functions, workers. Never ship the API key to a browser or a mobile app, and never commit it.

Configuration

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" }
  }
}
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(...).

Send your first email — no DNS setup

Every account can send test email right away from a sandbox domain: pre-verified, DKIM and SPF already set. It delivers only to addresses you confirm.

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

1. Get your sandbox domain (domain/get-sandbox-domain). The call creates the domain on first use and returns the same one afterwards.

using UniOne;

app.MapPost("/sandbox-domain", async (UniOneClient client) =>
{
    var response = await client.Domain.GetSandboxDomainAsync();
    return response.Domain;
});

2. Confirm your inbox (confirmed-email/create). UniOne sends a confirmation email; click the link in it within 48 hours.

using UniOne.Api.ConfirmedEmail.Model;
using UniOne;

app.MapPost("/confirm-email", async (UniOneClient client) =>
{
    var response = await client.ConfirmedEmail.CreateAsync(new ConfirmedEmailRequest
    {
        Email = "you@example.com",
    });
    return response.Status;
});

Check the status with confirmed-email/list — your address should show "status": "confirmed".

3. Send the email (email/send) from any address on the sandbox domain to the confirmed address.

using System.Collections.Generic;
using UniOne.Api.Email.Model;
using UniOne.Common.Model;
using UniOne;

app.MapPost("/send", async (UniOneClient client) =>
{
    var response = await client.Email.SendAsync(new EmailSendRequest
    {
        Message = new MessageObject
        {
            Recipients = new List<MessageObjectRecipientsItem>
            {
                new MessageObjectRecipientsItem
                {
                    Email = "you@example.com",
                },
            },
            Body = new BodyObject
            {
                Html = "<p>It works!</p>",
            },
            Subject = "Hello from UniOne",
            FromEmail = "noreply@<sandbox-domain>",
        },
    });
    return response.JobId;
});

What you get back

{
  "status": "success",
  "job_id": "1ZymBc-00041N-9X",
  "emails": [
    "you@example.com"
  ]
}

On error the API returns status: "error", a message and a numeric code:

{
  "status": "error",
  "code": 102,
  "message": "Error ID:83274F98-C7D5-11F1-B221-6214FF8707B1. Can not decode key wrongkey"
}

Same flow with curl

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>"
          }
        }
      }'

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.

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 System.Collections.Generic;
using UniOne.Api.Email.Model;
using UniOne.Common.Model;
using UniOne;

app.MapPost("/send", async (UniOneClient client) =>
{
    var response = await client.Email.SendAsync(new EmailSendRequest
    {
        Message = new MessageObject
        {
            Recipients = new List<MessageObjectRecipientsItem>
            {
                new MessageObjectRecipientsItem
                {
                    Email = "user@example.com",
                    Substitutions = new Dictionary<string, string>
                    {
                        ["CustomerId"] = "12452",
                        ["to_name"] = "John Smith",
                    },
                },
            },
            Body = new BodyObject
            {
                Html = "<b>Hello, {{to_name}}</b>",
                Plaintext = "Hello, {{to_name}}",
            },
            Subject = "UniOne test email ",
            FromEmail = "email@example.com",
            FromName = "John Smith",
        },
    });
    return response.JobId;
});

Sandbox limits

  • 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.

Before production: verify your domain

  1. domain/get-dns-records — returns the values for your DNS records.

  2. Add these records at your DNS provider (the domain page of the control panel shows them too):

    Type Host Value
    TXT @ the verification-record value (unione-validate-hash=…)
    TXT <selector>._domainkey (the selector is on the domain page of the control panel, e.g. us) v=DKIM1; k=rsa; p=<dkim>
    TXT @ v=spf1 include:spf.unione.io ~all
    CNAME _dmarc the dmarc value
  3. domain/validate-verification-record, then domain/validate-dkim.

  4. domain/list — wait until the verification record is confirmed and DKIM is active.

  5. Read from_email from your config, so switching from the sandbox needs no code change.

Sending reliably

  • Retries: set message.idempotence_key on sends that may be retried, so a repeated request does not send twice.
  • Limits: up to 500 recipients and 10 MB per request; each attachment up to 7 MB.
  • Body: always include body.html or body.plaintext.
  • Delivery status: register a webhook (webhook/set) with a fast, idempotent HTTPS handler instead of polling.
  • Defaults: keep the default unsubscribe footer and tracking; changing them requires UniOne support.
  • Errors: retry 429 and 5xx with backoff; do not retry other errors unchanged.

For package contributors

See AGENTS.md: how this package is generated from the OpenAPI spec, built, tested and released.

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 102 11/5/2026
2.2.4 107 10/23/2026
2.1.3 108 10/20/2026