Amane.Mailer.Contracts 2.3.1

dotnet add package Amane.Mailer.Contracts --version 2.3.1
                    
NuGet\Install-Package Amane.Mailer.Contracts -Version 2.3.1
                    
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="Amane.Mailer.Contracts" Version="2.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Amane.Mailer.Contracts" Version="2.3.1" />
                    
Directory.Packages.props
<PackageReference Include="Amane.Mailer.Contracts" />
                    
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 Amane.Mailer.Contracts --version 2.3.1
                    
#r "nuget: Amane.Mailer.Contracts, 2.3.1"
                    
#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 Amane.Mailer.Contracts@2.3.1
                    
#: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=Amane.Mailer.Contracts&version=2.3.1
                    
Install as a Cake Addin
#tool nuget:?package=Amane.Mailer.Contracts&version=2.3.1
                    
Install as a Cake Tool

Amane.Mailer.Contracts

NuGet package containing the Mailer v2 HTTP contract DTOs and status constants for use by consumer applications and the Mailer service.

The C# root namespace is Amane.Mailer.Contracts.

Target Framework

This package targets .NET 8 (net8.0) on purpose. The Mailer runtime service targets a newer framework (currently net10.0), but the Contracts package stays on a broader consumer-compatible TFM so downstream applications on .NET 8 and later can reference it without upgrading their own target framework.

Package version numbers stay aligned with the Mailer service release (see the Versioning Policy section in docs/service-spec.md), but the target frameworks do not have to match. A newer runtime does not imply the Contracts package should move to the same TFM.

HTTP Contract Source of Truth

This package is the code-level source of truth for Mailer HTTP request/response DTOs, error code constants, acceptance status constants, delivery status constants, and JSON serialization context. The Mailer runtime references this package directly, and consumer applications should use the published NuGet package.

docs/api/openapi.yaml is the Consumer-facing HTTP reference / public schema. It is kept synchronized with this package and the runtime implementation, but it is not the source of truth. CI validates OpenAPI structure with scripts/validate-openapi.mjs, runs drift assertions with scripts/check-contract-drift.mjs, and compares MailRequestCreateRequest field inventories across Contracts / OpenAPI / SDKs with scripts/check-mail-request-field-inventory.mjs.

When changing the contract, review drift across this package, runtime behavior, OpenAPI, SDKs, and tests for DTO JSON property names, required / nullable fields, MailerErrorCodes, MailRequestAcceptanceStatus, MailRequestStatus, and JSON unknown / duplicate property behavior. The drift check derives DTO / constant expectations from Contracts, compares them to OpenAPI, and verifies the runtime/test coverage hooks for strict JSON and server-side hashing. If the contract intentionally changes, update the Contracts type/constant first, then update docs/api/openapi.yaml, runtime behavior, examples, Python / TypeScript SDK field inventories, and related tests in the same change. There is no separate generated snapshot to refresh today; the drift check derives expected DTO / constant shape from source. Validate with:

node scripts/validate-openapi.mjs docs/api/openapi.yaml
node scripts/check-contract-drift.mjs
node scripts/check-mail-request-field-inventory.mjs

Metadata policy

Mailer applies a docs-first policy for metadata values:

  • Keys are rejected when they contain token, password, secret, or url (case-insensitive). Oversized metadata returns INVALID_METADATA (422).
  • Values are stored exactly as sent. Mailer does not scan, scrub, or reject metadata values for secrets, URL query parameters, or token-like content.
  • Accepted metadata is persisted in SQLite (metadata_json), included in backups, and may be shown in the Admin UI when operators view stored mail request fields.
  • Do not place secrets, bearer tokens, passwords, or reset-link query secrets in metadata values even when the key name is allowed (for example "link": "https://example.test/reset?token=..." is accepted but unsafe).
  • subject, html_body, text_body, reply_to, and metadata may contain PII; treat the mail payload and Mailer SQLite database as sensitive data.

See also docs/api/openapi.yaml (metadata field), docs/service-spec.md, and SECURITY.md (Mail request metadata).

Service release versions, Docker image tags, NuGet package versions, and OpenAPI info.version are all kept in sync under the same X.Y.Z. During the 0.x series, backward compatibility is not guaranteed; breaking changes are documented in CHANGELOG release notes. See the Versioning Policy section in docs/service-spec.md for full details.

NuGet source

The package is published to nuget.org. No custom package source or package-read authentication is required when the default nuget.org source is enabled.

Install

dotnet add package Amane.Mailer.Contracts

Key Types

Type Namespace Purpose
MailRequestCreateRequest Amane.Mailer.Contracts.MailRequests POST request DTO (optional scheduled_at)
MailRequestCreateResponse Amane.Mailer.Contracts.MailRequests 202 response DTO
MailRequestStatusResponse Amane.Mailer.Contracts.MailRequests GET / cancel / reschedule status response DTO
MailRequestRescheduleRequest Amane.Mailer.Contracts.MailRequests Reschedule request body
MailRequestScheduleLimits Amane.Mailer.Contracts.MailRequests Max schedule horizon (MaxScheduledAhead)
MailRecipientDto Amane.Mailer.Contracts.MailRequests Recipient DTO used by to, cc, and bcc arrays
MailRequestAcceptanceStatus Amane.Mailer.Contracts.MailRequests Response status constants
MailRequestStatus Amane.Mailer.Contracts.MailRequests Worker delivery status constants
MailerErrorCodes Amane.Mailer.Contracts.MailRequests HTTP acceptance error code constants
MailDeliveryErrorCodes Amane.Mailer.Contracts.MailRequests Delivery attempt / last_error_code constants

Minimal Example

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using Amane.Mailer.Contracts.Json;
using Amane.Mailer.Contracts.MailRequests;

var request = new MailRequestCreateRequest
{
    MailRequestId = Guid.NewGuid(),   // UUIDv7 recommended
    Purpose = "FormResponseNotification",
    To = [new MailRecipientDto { Email = "user@example.com" }],
    Subject = "Subject line",
    TextBody = "Plain text body",
};

var requestJson = JsonSerializer.Serialize(
    request,
    MailerContractsJsonContext.Default.MailRequestCreateRequest);

using var httpClient = new HttpClient { BaseAddress = new Uri("http://mailer:8080") };
using var message = new HttpRequestMessage(HttpMethod.Post, "/api/mail-requests")
{
    Content = new StringContent(requestJson, Encoding.UTF8, "application/json"),
};
message.Headers.Authorization = new AuthenticationHeaderValue(
    "Bearer",
    "MANAGED_API_KEY_VALUE");

using var httpResponse = await httpClient.SendAsync(message);
httpResponse.EnsureSuccessStatusCode();

await using var responseStream = await httpResponse.Content.ReadAsStreamAsync();
var accepted = await JsonSerializer.DeserializeAsync(
    responseStream,
    MailerContractsJsonContext.Default.MailRequestCreateResponse);

if (accepted is null)
{
    throw new InvalidOperationException("Mailer returned an empty response.");
}

if (accepted.Status == MailRequestAcceptanceStatus.AlreadyAccepted)
{
    // The same Sender, mail_request_id, and canonical payload were already accepted.
}

The bundled JSON context omits null optional properties. The managed API key selects the Sender and Mailer computes the canonical payload hash server-side; tenant_id, source_service, and payload_hash are not v2 contract fields.

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

    • No dependencies.

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.1 90 9/22/2026
2.3.0 117 9/22/2026
2.2.0 180 9/20/2026
2.1.0 113 9/19/2026
2.0.2 135 9/10/2026
2.0.0 211 9/6/2026
1.3.8 131 9/4/2026
1.3.7 195 9/2/2026
1.3.6 143 8/30/2026
1.3.5 130 8/28/2026
1.3.4 142 8/24/2026
1.3.0 140 8/21/2026
1.2.0 311 8/3/2026
1.1.0 131 7/27/2026
1.0.1 123 7/26/2026
1.0.0 118 7/25/2026
0.9.2 127 7/24/2026
0.9.1 462 7/22/2026
0.9.0 121 7/21/2026
0.4.0 126 7/21/2026
Loading failed