Migadu 0.1.0

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

Migadu

English | 繁體中文版:README.zh-tw.md

A typed .NET client for the Migadu REST API: manage domains, mailboxes, identities, forwardings, aliases and rewrites.

Unofficial package: this project is not affiliated with, endorsed by or supported by Migadu. Migadu is a trademark of its owner. The official Migadu documentation is authoritative for API behavior.

  • Covers all 34 endpoints in the official documentation
  • Sends requests through IHttpClientFactory and registers with DI via AddMigadu
  • Turns every non-success status code into a MigaduException, so you never parse Migadu's error format yourself
  • Update requests send only the fields you set, so a partial update never clears the fields you left out
  • The only dependency is Microsoft.Extensions.Http

Requirements

  • .NET 10
  • A Migadu account and API key, created in the admin panel under "My Account → API Keys". A key belongs to the user who created it

Installation

dotnet add package Migadu

Versions below 1.0 may still change the public API between minor versions.

Configuration

services.AddMigadu(delegate (MigaduOptions options)
{
    options.Email = configuration["Migadu:Email"]!;
    options.ApiKey = configuration["Migadu:ApiKey"]!;
});
Option Description Default
Email Email of the Migadu user who created the API key (the Basic auth user name) Required
ApiKey API key Required
BaseAddress API base address https://api.migadu.com/v1/
Timeout Timeout for a single request 30 seconds

The API key is only ever sent in the Authorization header and never appears in exception messages. Keep it in user secrets, environment variables or a key vault, not in configuration files or source code.

MigaduClient is a thread-safe singleton; resolve it from DI:

var migadu = serviceProvider.GetRequiredService<MigaduClient>();

Examples

List mailboxes:

var mailboxes = await migadu.ListMailboxesAsync("example.com", cancellationToken);

Create a mailbox by invitation (the user sets their own password):

var mailbox = await migadu.CreateMailboxAsync(
    domain: "example.com",
    request: new CreateMailboxRequest
    {
        LocalPart = "alice",
        Name = "Alice",
        PasswordMethod = MailboxPasswordMethods.Invitation,
        PasswordRecoveryEmail = "alice@personal.example",
    },
    cancellationToken: cancellationToken);

Partial update: only the fields you set are sent; everything else keeps its value:

await migadu.UpdateMailboxAsync(
    domain: "example.com",
    localPart: "alice",
    request: new UpdateMailboxRequest { MaySend = false },
    cancellationToken: cancellationToken);

Create an alias:

await migadu.CreateAliasAsync(
    domain: "example.com",
    request: new CreateAliasRequest
    {
        LocalPart = "team",
        Destinations = ["alice@example.com", "bob@example.com"],
    },
    cancellationToken: cancellationToken);

Handle errors:

try
{
    await migadu.ActivateDomainAsync("example.com", cancellationToken);
}
catch (MigaduException exception) when (exception.Error == "dns_check_failed")
{
    // DNS is not set up yet: call GetDomainRecordsAsync to get the records to configure
}

MigaduException carries StatusCode (the HTTP status code) and Error (the error field of Migadu's response).

For an example of every endpoint, see examples/Migadu.Examples in the repository: one file per resource, one method per endpoint. The program runs only the read-only examples; the examples that create, update or delete are there to read and are never called:

dotnet run --project examples/Migadu.Examples -- example.com

It needs the same MIGADU_EMAIL and MIGADU_API_KEY environment variables as the live tests. Without a domain argument it uses MIGADU_DOMAIN, then the first domain on the account.

Endpoints

Resource Methods
Domains ListDomainsAsync, GetDomainAsync, CreateDomainAsync, UpdateDomainAsync, GetDomainRecordsAsync, GetDomainDiagnosticsAsync, ActivateDomainAsync, GetDomainUsageAsync
Mailboxes ListMailboxesAsync, GetMailboxAsync, CreateMailboxAsync, UpdateMailboxAsync, DeleteMailboxAsync, GetMailboxUsageAsync
Identities ListIdentitiesAsync, GetIdentityAsync, CreateIdentityAsync, UpdateIdentityAsync, DeleteIdentityAsync
Forwardings ListForwardingsAsync, GetForwardingAsync, CreateForwardingAsync, UpdateForwardingAsync, DeleteForwardingAsync
Aliases ListAliasesAsync, GetAliasAsync, CreateAliasAsync, UpdateAliasAsync, DeleteAliasAsync
Rewrites ListRewritesAsync, GetRewriteAsync, CreateRewriteAsync, UpdateRewriteAsync, DeleteRewriteAsync

The Migadu API does not support deleting domains.

Things to know

  • 401 does not say why: a wrong email, a wrong key and no credentials at all all return 401 the token is invalid or expired. When you see it, check the login email and the key in the admin panel.
  • Domain activation uses GET: the Migadu documentation specifies GET for the request behind ActivateDomainAsync, even though it changes the domain's state. If you add a retry handler to the migadu named client, keep in mind that such handlers retry GET by default.
  • Mailbox timestamps are dates only: for a mailbox's activated_at and changed_at, Migadu returns the admin panel's display text (10:42 for today, 13/11/26 for earlier days), so Mailbox.ActivatedOn and ChangedOn are DateOnly?. Migadu displays these in UTC, so a time with no date is taken as today in UTC. activated_at is null until the user accepts an invitation. Domain and forwarding timestamps are full DateTimeOffset values.
  • Lists in requests are comma-separated strings: Migadu rejects JSON arrays for some request fields (domain tags, rewrite destinations), so every list in a request model is sent as "a,b"; an empty list clears the field. A value that itself contains a comma will be split by Migadu.
  • External forwarding needs an external address: creating a forwarding to an address on the mailbox's own domain returns 400 bad request.
  • Value sets are string constants: values Migadu defines (MailboxPasswordMethods, IdentityPasswordUses) are provided as constants rather than enums, so a new value from Migadu does not break deserialization.
  • DNS diagnostics: the documentation does not describe the response of GetDomainDiagnosticsAsync. The model is based on an actual passing response; the shape of a failing check has not been verified yet.

Development

dotnet build Migadu.slnx -c Release
dotnet test Migadu.slnx -c Release
dotnet format Migadu.slnx --verify-no-changes

Unit tests use a fake HttpMessageHandler and never touch the network. Live tests call read-only endpoints only, and run only when the following environment variables are set; otherwise they show as skipped:

Variable Description
MIGADU_EMAIL Migadu user email
MIGADU_API_KEY API key
MIGADU_DOMAIN Optional; defaults to the first domain on the account

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
0.1.0 105 11/15/2026