Skip to main content

.NET SDK

Official typed .NET client for Posta.

Installation

dotnet add package Posta

Requires: .NET 10+

Quick Start

using Posta.Clients;
using Posta.Models.Emails;

using var client = new PostaClient(
"https://posta.example.com",
"your-api-key");

SendAnEmailResponse? response = await client.Emails.SendAnEmailAsync(
new SendAnEmailRequest
{
From = "Acme <hello@example.com>",
To = ["user@example.com"],
Subject = "Hello from Posta",
Html = "<h1>Hello!</h1>"
});

The client also provides typed API clients for templates, campaigns, subscribers, webhooks, workspaces, administration, and the other Posta API areas.

Aspire Integration

For applications using .NET Aspire, install the client integration package:

dotnet add package Posta.Aspire

Register the client using the Posta resource name from your AppHost:

builder.AddPostaClient("posta", settings =>
{
settings.ApiKey = builder.Configuration["Posta:ApiKey"];
});

Posta also has an official hosting integration in the Aspire Community Toolkit.

Error Handling

Non-successful HTTP responses throw PostaApiException, which exposes the HTTP status code, response body, and structured Posta error details.

using Posta.Transport;

try
{
await client.Emails.GetEmailDetailsAsync(
new GetEmailDetailsRequest { Id = emailId });
}
catch (PostaApiException exception)
{
Console.WriteLine(exception.StatusCode);
Console.WriteLine(exception.Error?.Message);
}

See the Posta .NET SDK repository for complete configuration, Aspire, and API coverage documentation.