Integrate TemporaryEmail.dev in your application
Install the NuGet package, register the typed client, and start reacting to inbound email from your own virtual mailboxes.
Install the NuGet package
The TemporaryEmail.Contracts package ships the typed client, request/response contracts, and API key handler.
dotnet add package TemporaryEmail.Contracts
Alternatively, add it via Paket, NuGet UI, or include it in your central package management file.
Configure the client
Register the client in Program.cs using RegisterTemporaryEmail. The API key is the one generated in the developer portal dashboard.
using TemporaryEmail.Contracts.Client.Extensions;
builder.Services.RegisterTemporaryEmail(options =>
{
options.ApiKey = configuration["TemporaryEmail:ApiKey"]!;
options.BaseAddress = "https://api.temporaryemail.ai"; // optional override
});
The helper wires a Refit client, injects the API key header, and validates configuration on startup.
Create a virtual mailbox
Inject ITemporaryEmailClient and call CreateAccountMailboxAsync. Share tokens are the dashboard tokens shown in the Overview card.
using TemporaryEmail.Contracts.Client.Interfaces;
using TemporaryEmail.Contracts.Mailboxes;
public class MailboxService
{
private readonly ITemporaryEmailClient client;
public MailboxService(ITemporaryEmailClient client) => this.client = client;
public async Task<AccountMailboxResponse> ProvisionEmployeeInboxAsync(string shareToken, string employeeId, CancellationToken ct = default)
{
var request = new CreateAccountMailboxRequest
{
ShareToken = shareToken,
Prefix = $"payroll-{employeeId}-",
AcceptAttachments = true,
Domain = "workers.yourcompany.email"
};
return await client.CreateAccountMailboxAsync(request, ct);
}
}
Each mailbox returns an email address you can hand to upstream systems (HR, billing, onboarding flows).
Handle inbound events
Example minimal ASP.NET Core endpoint that stores payslips after verifying the signature.
app.MapPost("/webhooks/payslips", async (HttpRequest request, ILogger<Program> logger) =>
{
var payload = await JsonSerializer.DeserializeAsync<InboundEmailEvent>(request.Body);
if (payload is null)
{
return Results.BadRequest();
}
// TODO: verify signature using request.Headers["X-Webhook-Signature"]
foreach (var attachment in payload.Attachments)
{
await PayrollAiParser.ProcessAsync(payload, attachment);
}
await PayslipArchive.StoreAsync(payload);
return Results.Ok();
});
This mirrors our internal workflow: each employee has a virtual mailbox, payslips are parsed with AI, and the structured documents surface inside the product.
Client reference
ITemporaryEmailClient exposes helpers for:
- Creating, listing, and deleting virtual mailboxes
- Managing API keys
- Registering webhooks
- Adding and removing custom domains
- Fetching usage snapshots (mailboxes, daily/monthly emails)
Explore the interface in TemporaryEmail.Contracts.Client.Interfaces for the full list of methods.