Misar IO Docs

C# SDK

Install and use the MisarMail C# SDK

Installation

dotnet add package Misar.Mail

Or via the NuGet Package Manager:

Install-Package Misar.Mail

Quick Start

using Misar.Mail;
using Misar.Mail.Models;

var client = new MisarMailClient(Environment.GetEnvironmentVariable("MISARMAIL_API_KEY")!);

var result = await client.SendAsync(new SendRequest
{
    From = new Address { Email = "[email protected]", Name = "Misar" },
    To = [new Address { Email = "[email protected]" }],
    Subject = "Welcome",
    Html = "<p>Hello from MisarMail!</p>",
});

Console.WriteLine($"Sent: {result.MessageId}");

Available Methods

All async methods accept an optional CancellationToken ct parameter.

| Method | Description | |--------|-------------| | client.SendAsync(request, ct) | Send a transactional email | | client.Contacts.ListAsync(params, ct) | List contacts | | client.Contacts.CreateAsync(request, ct) | Create a contact | | client.Contacts.GetAsync(id, ct) | Get a contact | | client.Contacts.UpdateAsync(id, request, ct) | Update a contact | | client.Contacts.DeleteAsync(id, ct) | Delete a contact | | client.Contacts.ImportAsync(request, ct) | Bulk import contacts | | client.Campaigns.ListAsync(params, ct) | List campaigns | | client.Campaigns.CreateAsync(request, ct) | Create a campaign | | client.Campaigns.GetAsync(id, ct) | Get a campaign | | client.Campaigns.UpdateAsync(id, request, ct) | Update a campaign | | client.Campaigns.SendAsync(id, ct) | Send/schedule a campaign | | client.Campaigns.DeleteAsync(id, ct) | Delete a campaign | | client.Templates.ListAsync(params, ct) | List templates | | client.Templates.CreateAsync(request, ct) | Create a template | | client.Templates.GetAsync(id, ct) | Get a template | | client.Templates.UpdateAsync(id, request, ct) | Update a template | | client.Templates.DeleteAsync(id, ct) | Delete a template | | client.Templates.RenderAsync(id, request, ct) | Render a template with merge data | | client.Automations.ListAsync(params, ct) | List automations | | client.Automations.CreateAsync(request, ct) | Create an automation | | client.Automations.GetAsync(id, ct) | Get an automation | | client.Automations.UpdateAsync(id, request, ct) | Update an automation | | client.Automations.DeleteAsync(id, ct) | Delete an automation | | client.Automations.ActivateAsync(id, ct) | Activate/deactivate an automation | | client.Domains.ListAsync(ct) | List sending domains | | client.Domains.CreateAsync(request, ct) | Add a sending domain | | client.Domains.GetAsync(id, ct) | Get a domain | | client.Domains.VerifyAsync(id, ct) | Trigger domain DNS verification | | client.Domains.DeleteAsync(id, ct) | Delete a domain | | client.Aliases.ListAsync(params, ct) | List email aliases | | client.Aliases.CreateAsync(request, ct) | Create an alias | | client.Aliases.GetAsync(id, ct) | Get an alias | | client.Aliases.UpdateAsync(id, request, ct) | Update an alias | | client.Aliases.DeleteAsync(id, ct) | Delete an alias | | client.DedicatedIPs.ListAsync(ct) | List dedicated IPs | | client.DedicatedIPs.CreateAsync(request, ct) | Purchase a dedicated IP | | client.DedicatedIPs.UpdateAsync(id, request, ct) | Update IP pool assignment | | client.DedicatedIPs.DeleteAsync(id, ct) | Release a dedicated IP | | client.Channels.SendWhatsAppAsync(request, ct) | Send a WhatsApp message | | client.Channels.SendPushAsync(request, ct) | Send a push notification | | client.ABTests.ListAsync(params, ct) | List A/B tests | | client.ABTests.CreateAsync(request, ct) | Create an A/B test | | client.ABTests.GetAsync(id, ct) | Get an A/B test | | client.ABTests.SetWinnerAsync(id, variant, ct) | Manually set the winning variant | | client.Sandbox.SendAsync(request, ct) | Send in sandbox mode | | client.Sandbox.ListAsync(params, ct) | List sandbox messages | | client.Sandbox.DeleteAsync(id, ct) | Delete a sandbox message | | client.Inbound.ListAsync(params, ct) | List inbound routing rules | | client.Inbound.CreateAsync(request, ct) | Create an inbound route | | client.Inbound.GetAsync(id, ct) | Get an inbound route | | client.Inbound.DeleteAsync(id, ct) | Delete an inbound route | | client.Analytics.OverviewAsync(params, ct) | Get send/open/click/bounce analytics | | client.Track.EventAsync(request, ct) | Track a custom event | | client.Track.PurchaseAsync(request, ct) | Track a purchase event | | client.Keys.ListAsync(ct) | List API keys | | client.Keys.CreateAsync(request, ct) | Create an API key | | client.Keys.GetAsync(id, ct) | Get an API key | | client.Keys.RevokeAsync(id, ct) | Revoke an API key | | client.Validate.EmailAsync(address, ct) | Validate an email address | | client.Leads.SearchAsync(request, ct) | Start an async lead search job | | client.Leads.GetJobAsync(jobId, ct) | Get lead search job status | | client.Leads.ListJobsAsync(params, ct) | List all lead search jobs | | client.Leads.ResultsAsync(jobId, params, ct) | Fetch results for a completed job | | client.Leads.ImportLeadsAsync(request, ct) | Import leads directly to contacts | | client.Leads.CreditsAsync(ct) | Get lead finder credits balance | | client.Autopilot.StartAsync(request, ct) | Start an AI Autopilot campaign run | | client.Autopilot.GetAsync(id, ct) | Get Autopilot run status | | client.Autopilot.ListAsync(params, ct) | List Autopilot runs | | client.Autopilot.DailyPlanAsync(params, ct) | Get today's AI-suggested outreach plan | | client.SalesAgent.GetConfigAsync(ct) | Get Sales Agent AI configuration | | client.SalesAgent.UpdateConfigAsync(request, ct) | Update Sales Agent configuration | | client.SalesAgent.GetActionsAsync(params, ct) | List Sales Agent actions taken | | client.CRM.ListConversationsAsync(params, ct) | List CRM conversations | | client.CRM.GetConversationAsync(id, ct) | Get a CRM conversation | | client.CRM.UpdateConversationAsync(id, request, ct) | Update conversation status/notes | | client.CRM.ListMessagesAsync(convId, params, ct) | List messages in a conversation | | client.CRM.ListDealsAsync(params, ct) | List deals in pipeline | | client.CRM.CreateDealAsync(request, ct) | Create a new deal | | client.CRM.GetDealAsync(id, ct) | Get a deal | | client.CRM.UpdateDealAsync(id, request, ct) | Update a deal | | client.CRM.DeleteDealAsync(id, ct) | Delete a deal | | client.CRM.ListClientsAsync(params, ct) | List CRM clients/accounts | | client.CRM.CreateClientAsync(request, ct) | Create a CRM client | | client.Webhooks.ListAsync(params, ct) | List webhooks | | client.Webhooks.CreateAsync(request, ct) | Create a webhook endpoint | | client.Webhooks.GetAsync(id, ct) | Get a webhook | | client.Webhooks.UpdateAsync(id, request, ct) | Update a webhook | | client.Webhooks.DeleteAsync(id, ct) | Delete a webhook | | client.Webhooks.TestAsync(id, ct) | Send a test event to a webhook | | client.Usage.GetAsync(params, ct) | Get API usage stats | | client.Billing.SubscriptionAsync(ct) | Get current subscription details | | client.Billing.CheckoutAsync(request, ct) | Create a billing checkout session | | client.Workspaces.ListAsync(ct) | List workspaces | | client.Workspaces.CreateAsync(request, ct) | Create a workspace | | client.Workspaces.GetAsync(id, ct) | Get a workspace | | client.Workspaces.UpdateAsync(id, request, ct) | Update a workspace | | client.Workspaces.DeleteAsync(id, ct) | Delete a workspace | | client.Workspaces.ListMembersAsync(id, ct) | List workspace members | | client.Workspaces.InviteMemberAsync(id, request, ct) | Invite a member to workspace | | client.Workspaces.UpdateMemberAsync(id, userId, request, ct) | Update member role | | client.Workspaces.RemoveMemberAsync(id, userId, ct) | Remove a member from workspace |


Examples

Lead finder

var job = await client.Leads.SearchAsync(new LeadSearchRequest
{
    Query = "VP Engineering at fintech companies",
    Limit = 100,
});

var status = await client.Leads.GetJobAsync(job.Id);
if (status.State == "completed")
{
    var results = await client.Leads.ResultsAsync(job.Id, null);
    Console.WriteLine(results.Leads.Count);
}

Autopilot

var run = await client.Autopilot.StartAsync(new AutopilotRequest
{
    Goal = "Book 20 demo calls with HR directors",
    Audience = "HR directors at mid-size companies",
    DailyLimit = 30,
});

var status = await client.Autopilot.GetAsync(run.Id);
Console.WriteLine($"{status.State} — sent: {status.EmailsSent}");

CRM conversations & deals

var convs = await client.CRM.ListConversationsAsync(new CRMParams { Status = "open", Limit = 20 });

var deal = await client.CRM.CreateDealAsync(new CreateDealRequest
{
    Title = "Enterprise contract",
    Amount = 25000,
    Currency = "USD",
    ContactId = convs.Conversations[0].ContactId,
});

Webhooks

var webhook = await client.Webhooks.CreateAsync(new CreateWebhookRequest
{
    Url = "https://yourapp.com/webhooks/mail",
    Events = ["email.delivered", "email.opened", "email.bounced"],
});
await client.Webhooks.TestAsync(webhook.Id);

Error Handling

try
{
    await client.SendAsync(request);
}
catch (MisarMailApiException ex)
{
    Console.Error.WriteLine($"{ex.StatusCode}: {ex.Message}");
}