SDKs
Swift SDK
Install and use the MisarMail Swift SDK
Installation
Add to Package.swift:
dependencies: [
.package(url: "https://github.com/misarai/misarmail-swift.git", from: "1.0.0"),
],
targets: [
.target(name: "MyApp", dependencies: [
.product(name: "MisarMail", package: "misarmail-swift"),
]),
]Quick Start
import MisarMail
let client = MisarMailClient(apiKey: ProcessInfo.processInfo.environment["MISARMAIL_API_KEY"]!)
let request = SendRequest(
from: Address(email: "hello@misar.io", name: "Misar"),
to: [Address(email: "user@example.com")],
subject: "Welcome",
html: "<p>Hello from MisarMail!</p>"
)
let result = try await client.send(request)
print("Sent: \(result.messageId)")Available Methods
| Method | Description |
|---|---|
client.send(_ request:) | Send a transactional email |
client.contacts.list(params:) | List contacts |
client.contacts.create(_ request:) | Create a contact |
client.contacts.get(_ id:) | Get a contact |
client.contacts.update(_ id:, _ request:) | Update a contact |
client.contacts.delete(_ id:) | Delete a contact |
client.contacts.importContacts(_ request:) | Bulk import contacts |
client.campaigns.list(params:) | List campaigns |
client.campaigns.create(_ request:) | Create a campaign |
client.campaigns.get(_ id:) | Get a campaign |
client.campaigns.update(_ id:, _ request:) | Update a campaign |
client.campaigns.send(_ id:) | Send/schedule a campaign |
client.campaigns.delete(_ id:) | Delete a campaign |
client.templates.list(params:) | List templates |
client.templates.create(_ request:) | Create a template |
client.templates.get(_ id:) | Get a template |
client.templates.update(_ id:, _ request:) | Update a template |
client.templates.delete(_ id:) | Delete a template |
client.templates.render(_ id:, _ request:) | Render a template with merge data |
client.automations.list(params:) | List automations |
client.automations.create(_ request:) | Create an automation |
client.automations.get(_ id:) | Get an automation |
client.automations.update(_ id:, _ request:) | Update an automation |
client.automations.delete(_ id:) | Delete an automation |
client.automations.activate(_ id:) | Activate/deactivate an automation |
client.domains.list() | List sending domains |
client.domains.create(_ request:) | Add a sending domain |
client.domains.get(_ id:) | Get a domain |
client.domains.verify(_ id:) | Trigger domain DNS verification |
client.domains.delete(_ id:) | Delete a domain |
client.aliases.list(params:) | List email aliases |
client.aliases.create(_ request:) | Create an alias |
client.aliases.get(_ id:) | Get an alias |
client.aliases.update(_ id:, _ request:) | Update an alias |
client.aliases.delete(_ id:) | Delete an alias |
client.dedicatedIPs.list() | List dedicated IPs |
client.dedicatedIPs.create(_ request:) | Purchase a dedicated IP |
client.dedicatedIPs.update(_ id:, _ request:) | Update IP pool assignment |
client.dedicatedIPs.delete(_ id:) | Release a dedicated IP |
client.channels.sendWhatsApp(_ request:) | Send a WhatsApp message |
client.channels.sendPush(_ request:) | Send a push notification |
client.abTests.list(params:) | List A/B tests |
client.abTests.create(_ request:) | Create an A/B test |
client.abTests.get(_ id:) | Get an A/B test |
client.abTests.setWinner(_ id:, variant:) | Manually set the winning variant |
client.sandbox.send(_ request:) | Send in sandbox mode |
client.sandbox.list(params:) | List sandbox messages |
client.sandbox.delete(_ id:) | Delete a sandbox message |
client.inbound.list(params:) | List inbound routing rules |
client.inbound.create(_ request:) | Create an inbound route |
client.inbound.get(_ id:) | Get an inbound route |
client.inbound.delete(_ id:) | Delete an inbound route |
client.analytics.overview(params:) | Get send/open/click/bounce analytics |
client.track.event(_ request:) | Track a custom event |
client.track.purchase(_ request:) | Track a purchase event |
client.keys.list() | List API keys |
client.keys.create(_ request:) | Create an API key |
client.keys.get(_ id:) | Get an API key |
client.keys.revoke(_ id:) | Revoke an API key |
client.validate.email(_ address:) | Validate an email address |
client.leads.search(_ request:) | Start an async lead search job |
client.leads.getJob(_ jobId:) | Get lead search job status |
client.leads.listJobs(params:) | List all lead search jobs |
client.leads.results(_ jobId:, params:) | Fetch results for a completed job |
client.leads.importLeads(_ request:) | Import leads directly to contacts |
client.leads.credits() | Get lead finder credits balance |
client.autopilot.start(_ request:) | Start an AI Autopilot campaign run |
client.autopilot.get(_ id:) | Get Autopilot run status |
client.autopilot.list(params:) | List Autopilot runs |
client.autopilot.dailyPlan(params:) | Get today's AI-suggested outreach plan |
client.salesAgent.getConfig() | Get Sales Agent AI configuration |
client.salesAgent.updateConfig(_ request:) | Update Sales Agent configuration |
client.salesAgent.getActions(params:) | List Sales Agent actions taken |
client.crm.listConversations(params:) | List CRM conversations |
client.crm.getConversation(_ id:) | Get a CRM conversation |
client.crm.updateConversation(_ id:, _ request:) | Update conversation status/notes |
client.crm.listMessages(_ conversationId:, params:) | List messages in a conversation |
client.crm.listDeals(params:) | List deals in pipeline |
client.crm.createDeal(_ request:) | Create a new deal |
client.crm.getDeal(_ id:) | Get a deal |
client.crm.updateDeal(_ id:, _ request:) | Update a deal |
client.crm.deleteDeal(_ id:) | Delete a deal |
client.crm.listClients(params:) | List CRM clients/accounts |
client.crm.createClient(_ request:) | Create a CRM client |
client.webhooks.list(params:) | List webhooks |
client.webhooks.create(_ request:) | Create a webhook endpoint |
client.webhooks.get(_ id:) | Get a webhook |
client.webhooks.update(_ id:, _ request:) | Update a webhook |
client.webhooks.delete(_ id:) | Delete a webhook |
client.webhooks.test(_ id:) | Send a test event to a webhook |
client.usage.get(params:) | Get API usage stats |
client.billing.subscription() | Get current subscription details |
client.billing.checkout(_ request:) | Create a billing checkout session |
client.workspaces.list() | List workspaces |
client.workspaces.create(_ request:) | Create a workspace |
client.workspaces.get(_ id:) | Get a workspace |
client.workspaces.update(_ id:, _ request:) | Update a workspace |
client.workspaces.delete(_ id:) | Delete a workspace |
client.workspaces.listMembers(_ id:) | List workspace members |
client.workspaces.inviteMember(_ id:, _ request:) | Invite a member to workspace |
client.workspaces.updateMember(_ id:, userId:, _ request:) | Update member role |
client.workspaces.removeMember(_ id:, userId:) | Remove a member from workspace |
Examples
Lead finder
let job = try await client.leads.search(LeadSearchRequest(
query: "VP Engineering at fintech companies",
limit: 100
))
let status = try await client.leads.getJob(job.id)
if status.state == "completed" {
let results = try await client.leads.results(job.id)
print(results.leads)
}Autopilot
let run = try await client.autopilot.start(AutopilotRequest(
goal: "Book 20 demo calls with HR directors",
audience: "HR directors at mid-size companies",
dailyLimit: 30
))
let status = try await client.autopilot.get(run.id)
print("\(status.state) — sent: \(status.emailsSent)")CRM conversations & deals
let convs = try await client.crm.listConversations(params: .init(status: "open", limit: 20))
let deal = try await client.crm.createDeal(CreateDealRequest(
title: "Enterprise contract",
amount: 25000,
currency: "USD",
contactId: convs.conversations.first!.contactId
))Webhooks
let webhook = try await client.webhooks.create(CreateWebhookRequest(
url: "https://yourapp.com/webhooks/mail",
events: ["email.delivered", "email.opened", "email.bounced"]
))
try await client.webhooks.test(webhook.id)Error Handling
do {
let result = try await client.send(request)
print(result.messageId)
} catch let error as MisarMailError {
print("\(error.statusCode): \(error.message)")
}