Misar IO Docs

Go SDK

Install and use the MisarMail Go SDK

Installation

go get github.com/misarai/misarmail-go

Quick Start

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	misarmail "github.com/misarai/misarmail-go"
)

func main() {
	client := misarmail.NewClient(os.Getenv("MISARMAIL_API_KEY"))

	result, err := client.Send(context.Background(), misarmail.SendRequest{
		From:    misarmail.Address{Email: "[email protected]", Name: "Misar"},
		To:      []misarmail.Address{{Email: "[email protected]"}},
		Subject: "Welcome",
		HTML:    "<p>Hello from MisarMail!</p>",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Sent:", result.MessageID)
}

Available Methods

| Method | Description | |--------|-------------| | client.Send(ctx, req) | Send a transactional email | | client.Contacts.List(ctx, params) | List contacts with optional filters | | client.Contacts.Create(ctx, req) | Create a contact | | client.Contacts.Get(ctx, id) | Get a single contact | | client.Contacts.Update(ctx, id, req) | Update contact fields | | client.Contacts.Delete(ctx, id) | Delete a contact | | client.Contacts.Import(ctx, req) | Bulk import/upsert contacts | | client.Campaigns.List(ctx, params) | List campaigns | | client.Campaigns.Create(ctx, req) | Create a draft campaign | | client.Campaigns.Get(ctx, id) | Get a campaign | | client.Campaigns.Update(ctx, id, req) | Update a campaign | | client.Campaigns.Send(ctx, id) | Send/schedule a campaign | | client.Campaigns.Delete(ctx, id) | Delete a campaign | | client.Templates.List(ctx, params) | List email templates | | client.Templates.Create(ctx, req) | Create a template | | client.Templates.Get(ctx, id) | Get a template | | client.Templates.Update(ctx, id, req) | Update a template | | client.Templates.Delete(ctx, id) | Delete a template | | client.Templates.Render(ctx, id, req) | Render a template with merge data | | client.Automations.List(ctx, params) | List automation workflows | | client.Automations.Create(ctx, req) | Create an automation | | client.Automations.Get(ctx, id) | Get an automation | | client.Automations.Update(ctx, id, req) | Update an automation | | client.Automations.Delete(ctx, id) | Delete an automation | | client.Automations.Activate(ctx, id) | Activate/deactivate an automation | | client.Domains.List(ctx) | List sending domains | | client.Domains.Create(ctx, req) | Add a sending domain | | client.Domains.Get(ctx, id) | Get a domain | | client.Domains.Verify(ctx, id) | Trigger domain DNS verification | | client.Domains.Delete(ctx, id) | Delete a domain | | client.Aliases.List(ctx, params) | List email aliases | | client.Aliases.Create(ctx, req) | Create an alias | | client.Aliases.Get(ctx, id) | Get an alias | | client.Aliases.Update(ctx, id, req) | Update an alias | | client.Aliases.Delete(ctx, id) | Delete an alias | | client.DedicatedIPs.List(ctx) | List dedicated IPs | | client.DedicatedIPs.Create(ctx, req) | Purchase a dedicated IP | | client.DedicatedIPs.Update(ctx, id, req) | Update IP pool assignment | | client.DedicatedIPs.Delete(ctx, id) | Release a dedicated IP | | client.Channels.SendWhatsApp(ctx, req) | Send a WhatsApp message | | client.Channels.SendPush(ctx, req) | Send a push notification | | client.ABTests.List(ctx, params) | List A/B tests | | client.ABTests.Create(ctx, req) | Create an A/B test | | client.ABTests.Get(ctx, id) | Get an A/B test | | client.ABTests.SetWinner(ctx, id, variant) | Manually set the winning variant | | client.Sandbox.Send(ctx, req) | Send in sandbox mode (no real delivery) | | client.Sandbox.List(ctx, params) | List sandbox sent messages | | client.Sandbox.Delete(ctx, id) | Delete a sandbox message | | client.Inbound.List(ctx, params) | List inbound routing rules | | client.Inbound.Create(ctx, req) | Create an inbound route | | client.Inbound.Get(ctx, id) | Get an inbound route | | client.Inbound.Delete(ctx, id) | Delete an inbound route | | client.Analytics.Overview(ctx, params) | Get send/open/click/bounce analytics | | client.Track.Event(ctx, req) | Track a custom event | | client.Track.Purchase(ctx, req) | Track a purchase event | | client.Keys.List(ctx) | List API keys | | client.Keys.Create(ctx, req) | Create an API key | | client.Keys.Get(ctx, id) | Get an API key | | client.Keys.Revoke(ctx, id) | Revoke an API key | | client.Validate.Email(ctx, address) | Validate an email address | | client.Leads.Search(ctx, req) | Start an async lead search job | | client.Leads.GetJob(ctx, jobID) | Get lead search job status | | client.Leads.ListJobs(ctx, params) | List all lead search jobs | | client.Leads.Results(ctx, jobID, params) | Fetch results for a completed job | | client.Leads.ImportLeads(ctx, req) | Import leads directly to contacts | | client.Leads.Credits(ctx) | Get lead finder credits balance | | client.Autopilot.Start(ctx, req) | Start an AI Autopilot campaign run | | client.Autopilot.Get(ctx, id) | Get Autopilot run status | | client.Autopilot.List(ctx, params) | List Autopilot runs | | client.Autopilot.DailyPlan(ctx, params) | Get today's AI-suggested outreach plan | | client.SalesAgent.GetConfig(ctx) | Get Sales Agent AI configuration | | client.SalesAgent.UpdateConfig(ctx, req) | Update Sales Agent configuration | | client.SalesAgent.GetActions(ctx, params) | List Sales Agent actions taken | | client.CRM.ListConversations(ctx, params) | List CRM conversations | | client.CRM.GetConversation(ctx, id) | Get a CRM conversation | | client.CRM.UpdateConversation(ctx, id, req) | Update conversation status/notes | | client.CRM.ListMessages(ctx, convID, params) | List messages in a conversation | | client.CRM.ListDeals(ctx, params) | List deals in pipeline | | client.CRM.CreateDeal(ctx, req) | Create a new deal | | client.CRM.GetDeal(ctx, id) | Get a deal | | client.CRM.UpdateDeal(ctx, id, req) | Update a deal | | client.CRM.DeleteDeal(ctx, id) | Delete a deal | | client.CRM.ListClients(ctx, params) | List CRM clients/accounts | | client.CRM.CreateClient(ctx, req) | Create a CRM client | | client.Webhooks.List(ctx, params) | List webhooks | | client.Webhooks.Create(ctx, req) | Create a webhook endpoint | | client.Webhooks.Get(ctx, id) | Get a webhook | | client.Webhooks.Update(ctx, id, req) | Update a webhook | | client.Webhooks.Delete(ctx, id) | Delete a webhook | | client.Webhooks.Test(ctx, id) | Send a test event to a webhook | | client.Usage.Get(ctx, params) | Get API usage stats | | client.Billing.Subscription(ctx) | Get current subscription details | | client.Billing.Checkout(ctx, req) | Create a billing checkout session | | client.Workspaces.List(ctx) | List workspaces | | client.Workspaces.Create(ctx, req) | Create a workspace | | client.Workspaces.Get(ctx, id) | Get a workspace | | client.Workspaces.Update(ctx, id, req) | Update a workspace | | client.Workspaces.Delete(ctx, id) | Delete a workspace | | client.Workspaces.ListMembers(ctx, id) | List workspace members | | client.Workspaces.InviteMember(ctx, id, req) | Invite a member to workspace | | client.Workspaces.UpdateMember(ctx, id, userID, req) | Update member role | | client.Workspaces.RemoveMember(ctx, id, userID) | Remove a member from workspace |


Examples

Lead finder

ctx := context.Background()

job, err := client.Leads.Search(ctx, misarmail.LeadSearchRequest{
    Query: "VP of Engineering at fintech companies",
    Limit: 100,
})
if err != nil { log.Fatal(err) }

status, _ := client.Leads.GetJob(ctx, job.ID)
if status.State == "completed" {
    results, _ := client.Leads.Results(ctx, job.ID, misarmail.PaginationParams{Limit: 50})
    fmt.Println(results.Leads)
}

Autopilot

run, err := client.Autopilot.Start(ctx, misarmail.AutopilotRequest{
    Goal:       "Book 20 demo calls with HR directors",
    Audience:   "HR directors, 50–500 employee companies",
    DailyLimit: 30,
})
if err != nil { log.Fatal(err) }

s, _ := client.Autopilot.Get(ctx, run.ID)
fmt.Println(s.State, s.EmailsSent)

CRM conversations & deals

convs, _ := client.CRM.ListConversations(ctx, misarmail.CRMParams{Status: "open", Limit: 20})

deal, _ := client.CRM.CreateDeal(ctx, misarmail.CreateDealRequest{
    Title:     "Enterprise contract",
    Amount:    25000,
    Currency:  "USD",
    ContactID: convs.Conversations[0].ContactID,
})
fmt.Println(deal.ID)

Webhooks

wh, _ := client.Webhooks.Create(ctx, misarmail.CreateWebhookRequest{
    URL:    "https://yourapp.com/webhooks/mail",
    Events: []string{"email.delivered", "email.opened", "email.bounced"},
})
client.Webhooks.Test(ctx, wh.ID)

Error Handling

result, err := client.Send(ctx, req)
if err != nil {
    var apiErr *misarmail.APIError
    if errors.As(err, &apiErr) {
        fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Message)
    } else {
        fmt.Printf("Network error: %v\n", err)
    }
    return
}