SDKs
Java SDK
Install and use the MisarMail Java SDK
Installation
Add to pom.xml:
<dependency>
<groupId>io.misar</groupId>
<artifactId>misarmail-java</artifactId>
<version>1.0.0</version>
</dependency>Or Gradle:
implementation 'io.misar:misarmail-java:1.0.0'Quick Start
import io.misar.mail.MisarMailClient;
import io.misar.mail.models.*;
public class Main {
public static void main(String[] args) throws Exception {
MisarMailClient client = MisarMailClient.builder()
.apiKey(System.getenv("MISARMAIL_API_KEY"))
.build();
SendRequest request = SendRequest.builder()
.from(new Address("hello@misar.io", "Misar"))
.to(List.of(new Address("user@example.com")))
.subject("Welcome")
.html("<p>Hello from MisarMail!</p>")
.build();
SendResponse result = client.send(request).get();
System.out.println("Sent: " + result.getMessageId());
client.close();
}
}Available Methods
All methods return CompletableFuture<T>. Call .get() to block or .thenAccept() for async chaining.
| 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(convId, 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
LeadJob job = client.leads().search(
LeadSearchRequest.builder().query("VP Engineering at fintech").limit(100).build()
).get();
LeadJobStatus status = client.leads().getJob(job.getId()).get();
if ("completed".equals(status.getState())) {
LeadResults results = client.leads().results(job.getId(), null).get();
System.out.println(results.getLeads());
}Autopilot
AutopilotRun run = client.autopilot().start(
AutopilotRequest.builder()
.goal("Book 20 demo calls with HR directors")
.audience("HR directors at mid-size companies")
.dailyLimit(30)
.build()
).get();
AutopilotStatus status = client.autopilot().get(run.getId()).get();
System.out.println(status.getState() + " — sent: " + status.getEmailsSent());CRM conversations & deals
ConversationList convs = client.crm().listConversations(
CRMParams.builder().status("open").limit(20).build()
).get();
Deal deal = client.crm().createDeal(
CreateDealRequest.builder()
.title("Enterprise contract")
.amount(25000)
.currency("USD")
.contactId(convs.getConversations().get(0).getContactId())
.build()
).get();Webhooks
Webhook wh = client.webhooks().create(
CreateWebhookRequest.builder()
.url("https://yourapp.com/webhooks/mail")
.events(List.of("email.delivered", "email.opened"))
.build()
).get();
client.webhooks().test(wh.getId()).get();Error Handling
try {
client.send(request).get();
} catch (ExecutionException e) {
if (e.getCause() instanceof MisarMailApiException ex) {
System.err.println(ex.getStatusCode() + ": " + ex.getMessage());
}
}