Rust SDK
Install and use the MisarMail Rust SDK
Installation
Add to Cargo.toml:
[dependencies]
misarmail = "0.1"
tokio = { version = "1", features = ["full"] }
Quick Start
use misarmail::{Client, types::{SendRequest, Address}};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new(std::env::var("MISARMAIL_API_KEY")?);
let result = client
.send(SendRequest {
from: Address { email: "[email protected]".into(), name: Some("Misar".into()) },
to: vec![Address { email: "[email protected]".into(), name: None }],
subject: "Welcome".into(),
html: Some("<p>Hello from MisarMail!</p>".into()),
..Default::default()
})
.await?;
println!("Sent: {}", result.message_id);
Ok(())
}
Available Methods
| Method | Description |
|--------|-------------|
| client.send(req).await | Send a transactional email |
| client.contacts().list(params).await | List contacts |
| client.contacts().create(req).await | Create a contact |
| client.contacts().get(id).await | Get a contact |
| client.contacts().update(id, req).await | Update a contact |
| client.contacts().delete(id).await | Delete a contact |
| client.contacts().import_contacts(req).await | Bulk import/upsert contacts |
| client.campaigns().list(params).await | List campaigns |
| client.campaigns().create(req).await | Create a campaign |
| client.campaigns().get(id).await | Get a campaign |
| client.campaigns().update(id, req).await | Update a campaign |
| client.campaigns().send(id).await | Send/schedule a campaign |
| client.campaigns().delete(id).await | Delete a campaign |
| client.templates().list(params).await | List templates |
| client.templates().create(req).await | Create a template |
| client.templates().get(id).await | Get a template |
| client.templates().update(id, req).await | Update a template |
| client.templates().delete(id).await | Delete a template |
| client.templates().render(id, req).await | Render a template with merge data |
| client.automations().list(params).await | List automations |
| client.automations().create(req).await | Create an automation |
| client.automations().get(id).await | Get an automation |
| client.automations().update(id, req).await | Update an automation |
| client.automations().delete(id).await | Delete an automation |
| client.automations().activate(id).await | Activate/deactivate an automation |
| client.domains().list().await | List sending domains |
| client.domains().create(req).await | Add a sending domain |
| client.domains().get(id).await | Get a domain |
| client.domains().verify(id).await | Trigger domain DNS verification |
| client.domains().delete(id).await | Delete a domain |
| client.aliases().list(params).await | List email aliases |
| client.aliases().create(req).await | Create an alias |
| client.aliases().get(id).await | Get an alias |
| client.aliases().update(id, req).await | Update an alias |
| client.aliases().delete(id).await | Delete an alias |
| client.dedicated_ips().list().await | List dedicated IPs |
| client.dedicated_ips().create(req).await | Purchase a dedicated IP |
| client.dedicated_ips().update(id, req).await | Update IP pool assignment |
| client.dedicated_ips().delete(id).await | Release a dedicated IP |
| client.channels().send_whatsapp(req).await | Send a WhatsApp message |
| client.channels().send_push(req).await | Send a push notification |
| client.ab_tests().list(params).await | List A/B tests |
| client.ab_tests().create(req).await | Create an A/B test |
| client.ab_tests().get(id).await | Get an A/B test |
| client.ab_tests().set_winner(id, variant).await | Manually set the winning variant |
| client.sandbox().send(req).await | Send in sandbox mode |
| client.sandbox().list(params).await | List sandbox messages |
| client.sandbox().delete(id).await | Delete a sandbox message |
| client.inbound().list(params).await | List inbound routing rules |
| client.inbound().create(req).await | Create an inbound route |
| client.inbound().get(id).await | Get an inbound route |
| client.inbound().delete(id).await | Delete an inbound route |
| client.analytics().overview(params).await | Get send/open/click/bounce analytics |
| client.track().event(req).await | Track a custom event |
| client.track().purchase(req).await | Track a purchase event |
| client.keys().list().await | List API keys |
| client.keys().create(req).await | Create an API key |
| client.keys().get(id).await | Get an API key |
| client.keys().revoke(id).await | Revoke an API key |
| client.validate().email(address).await | Validate an email address |
| client.leads().search(req).await | Start an async lead search job |
| client.leads().get_job(job_id).await | Get lead search job status |
| client.leads().list_jobs(params).await | List all lead search jobs |
| client.leads().results(job_id, params).await | Fetch results for a completed job |
| client.leads().import_leads(req).await | Import leads directly to contacts |
| client.leads().credits().await | Get lead finder credits balance |
| client.autopilot().start(req).await | Start an AI Autopilot campaign run |
| client.autopilot().get(id).await | Get Autopilot run status |
| client.autopilot().list(params).await | List Autopilot runs |
| client.autopilot().daily_plan(params).await | Get today's AI-suggested outreach plan |
| client.sales_agent().get_config().await | Get Sales Agent AI configuration |
| client.sales_agent().update_config(req).await | Update Sales Agent configuration |
| client.sales_agent().get_actions(params).await | List Sales Agent actions taken |
| client.crm().list_conversations(params).await | List CRM conversations |
| client.crm().get_conversation(id).await | Get a CRM conversation |
| client.crm().update_conversation(id, req).await | Update conversation status/notes |
| client.crm().list_messages(conv_id, params).await | List messages in a conversation |
| client.crm().list_deals(params).await | List deals in pipeline |
| client.crm().create_deal(req).await | Create a new deal |
| client.crm().get_deal(id).await | Get a deal |
| client.crm().update_deal(id, req).await | Update a deal |
| client.crm().delete_deal(id).await | Delete a deal |
| client.crm().list_clients(params).await | List CRM clients/accounts |
| client.crm().create_client(req).await | Create a CRM client |
| client.webhooks().list(params).await | List webhooks |
| client.webhooks().create(req).await | Create a webhook endpoint |
| client.webhooks().get(id).await | Get a webhook |
| client.webhooks().update(id, req).await | Update a webhook |
| client.webhooks().delete(id).await | Delete a webhook |
| client.webhooks().test(id).await | Send a test event to a webhook |
| client.usage().get(params).await | Get API usage stats |
| client.billing().subscription().await | Get current subscription details |
| client.billing().checkout(req).await | Create a billing checkout session |
| client.workspaces().list().await | List workspaces |
| client.workspaces().create(req).await | Create a workspace |
| client.workspaces().get(id).await | Get a workspace |
| client.workspaces().update(id, req).await | Update a workspace |
| client.workspaces().delete(id).await | Delete a workspace |
| client.workspaces().list_members(id).await | List workspace members |
| client.workspaces().invite_member(id, req).await | Invite a member to workspace |
| client.workspaces().update_member(id, user_id, req).await | Update member role |
| client.workspaces().remove_member(id, user_id).await | Remove a member from workspace |
Examples
Lead finder
let job = client.leads().search(LeadSearchRequest {
query: "VP Engineering at fintech".into(),
limit: 100,
..Default::default()
}).await?;
let status = client.leads().get_job(&job.id).await?;
if status.state == "completed" {
let results = client.leads().results(&job.id, Default::default()).await?;
println!("{:?}", results.leads);
}
Autopilot
let run = client.autopilot().start(AutopilotRequest {
goal: "Book 20 demos with HR directors".into(),
audience: "HR directors, 50-500 employee companies".into(),
daily_limit: 30,
}).await?;
let status = client.autopilot().get(&run.id).await?;
println!("{} — sent: {}", status.state, status.emails_sent);
CRM conversations & deals
let convs = client.crm().list_conversations(CRMParams {
status: Some("open".into()),
limit: Some(20),
..Default::default()
}).await?;
let deal = client.crm().create_deal(CreateDealRequest {
title: "Enterprise contract".into(),
amount: 25000,
currency: "USD".into(),
contact_id: convs.conversations[0].contact_id.clone(),
}).await?;
Webhooks
let wh = client.webhooks().create(CreateWebhookRequest {
url: "https://yourapp.com/webhooks/mail".into(),
events: vec!["email.delivered".into(), "email.opened".into()],
}).await?;
client.webhooks().test(&wh.id).await?;
Error Handling
use misarmail::Error;
match client.send(req).await {
Ok(r) => println!("Sent: {}", r.message_id),
Err(Error::Api { status, message }) => eprintln!("API {status}: {message}"),
Err(e) => eprintln!("Network error: {e}"),
}