Expand description
Official Rust SDK for MillionSend — a self-hostable, Resend-compatible email API.
Construct a MillionSend once and reuse it (it is cheap to Clone). Each
resource hangs off a public field: emails, batch, contacts, topics,
broadcasts, segments, suppressions, domains, webhooks, api_keys,
templates, deliverability, usage.
use millionsend::{MillionSend, SendEmailOptions};
let ms = MillionSend::with_base_url("ms_123", "https://mail.acme.dev");
let sent = ms
.emails
.send(&SendEmailOptions {
from: "Acme <onboarding@acme.dev>".into(),
to: "delivered@resend.dev".into(),
subject: "Hello".into(),
html: Some("<strong>it works</strong>".into()),
..Default::default()
})
.await?;
println!("sent {}", sent.id);Fallible calls return Result<T, Error>; Error::Api carries the
API’s { statusCode, name, message }, Error::Http a transport failure
(its status_code is None).
Structs§
- AddContact
Segment Response - AddSuppression
Options origindefaults tomanualserver-side.- ApiError
- The API’s canonical error shape (
{ statusCode, name, message }), plus the client-side conditions that never reached the API, which carrystatus_code: None. Mirrors Resend’sErrorResponse, so code that switches onnameports across unchanged. - ApiKey
- ApiKey
Token - The
tokenis shown once, at creation. - ApiKeys
- API keys. Mirrors Resend’s
api_keysresource. - Attachment
- An attachment.
contentis base64;pathis passed through so the API, not the SDK, decides whether remote attachments are accepted. - Batch
- Batch send. Mirrors Resend’s
batchresource. - Batch
AddSuppression Options - Up to 1000 addresses; duplicates collapse.
- Batch
AddSuppression Response - Batch
Contact Result - Batch
Contacts Counts - Per-status totals; they sum to the request length.
- Batch
Contacts Options - Batch
Contacts Response - Batch
Error - A per-item failure from a permissive batch, addressed by request index.
- Batch
Remove Suppressions Response - Batch
Response errorsis only populated underBatchValidation::Permissive.- Broadcast
- Broadcast
Id - Broadcast
List Item - Broadcasts
- Broadcasts — a one-off email to a segment, a topic’s subscribers, or (with
neither set) every contact. Mirrors Resend’s
broadcastsresource. - Cancel
Broadcast Response - Cancel
Email Response - Contact
- Contact
Address - Address a contact by id or email (email wins when both are set). A bare
&str/Stringis treated as an id. - Contact
Id - Contact
List Item - Contact
Properties - Typed definitions for the keys of
contact.properties(/contact-properties). - Contact
Property - Contact
Property Id - Contact
Segments - Manual segment membership for one contact.
- Contact
Topic Update - Contact
Topics - Per-contact topic subscriptions (opt a contact in/out of a topic).
- Contacts
- Contacts — team-global, addressable by id or email (email wins). Mirrors
Resend’s
contactsresource, plus nestedtopics,segmentsandproperties. - Create
ApiKey Options permissiondefaults tofull_access;domain_idrestricts asending_accesskey to one domain.- Create
Broadcast Options - Create
Contact Options - Build with
CreateContactOptions::new(email). Contacts are team-global; duplicates (case-insensitive email) are a 409validation_error. - Create
Contact Property Options fallback_valueisSome(Value::Null)to store an explicit null; its JSON type must matchtype.- Create
Domain Options regionis a plain string because each deployment serves its own SES region and rejects any other with 422; omit it to use the deployment’s.- Create
Email Response - Create
Segment Options filter: Nonecreates a manual-membership segment, fed only bycontacts.segments.addandcontacts.create’ssegments.- Create
Template Options from,reply_toandvariablesare passed through so the API, not the SDK, decides whether they are supported (422 while not).- Create
Topic Options - Create
Webhook Options eventsare wire names (email.delivered,deliverability.paused, …), kept as strings because the catalog grows.signing_secretis optional: omit it to have one minted; passwhsec_…to reuse an existing one.- Create
Webhook Response - Delete
Broadcast Response - Delete
Contact Response - Delete
Segment Response - Delete
Topic Response - Deleted
{ object, id, deleted: true }— the envelope everydeletereturns.- Deliverability
- Account-level deliverability score over the trailing window.
- Deliverability
Report GET /deliverability— the account score over the trailing window. Scores are 0–10 with one decimal;Nonemeans not enough data to compute.- Domain
- Domain
Capabilities - Domain
Record - Domains
- Sending domains and their DNS records. Mirrors Resend’s
domainsresource. - Email
Insights GET /emails/:id/insights— the pre-send best-practice report computed when the email was sent.- Email
List Item GET /emailsitem — the summary without bodies,message_idorscore.- Emails
- Transactional email. Mirrors Resend’s
emailsresource. - Idempotent
- A request body paired with an optional
Idempotency-Key. Any body converts implicitly (ms.emails.send(&email)); attach a key withwith_idempotency_key. - Insight
Check - One check from the insights report.
idis an open catalog that grows across score versions;severity/statusstay plain strings for the same reasonbanddoes. - List
- The
{ object: "list", data, has_more }envelope every paginated list returns. - List
Options - Keyset pagination for
listcalls.after/beforeare mutually exclusive UUID cursors;limitis 1–100 (server default 20). - List
Suppressions Options ListOptionsplus an optionaloriginfilter.- Million
Send - The MillionSend client. Construct once and reuse.
- Remove
Contact Segment Response - Segment
- Segment
Condition - Segment
Filter - Segment
Ref { id }— a segment referenced from a contact payload.- Segments
- Dynamic segments — a saved filter over the team’s contacts (MillionSend
extension, no Resend equivalent).
getreturns a livecontact_count. - Send
Email Options - Build with
SendEmailOptions::new(from, to, subject)then set the rest, or a struct literal with..Default::default(). - Suppression
- Suppression
Id - Suppressions
- Suppression list — addresses the team never sends to. Mirrors Resend’s
suppressionsresource; entries are addressable by id or email. - Tag
- Template
- Template
Id - Template
List Item - Templates
- Reusable email templates, addressable by id or alias. Mirrors Resend’s
templatesresource; templates are always published, sopublishis a compatibility no-op. - Topic
- TopicId
- Topic
List GET /topicsreturns every topic at once (has_moreis always false), so there are no cursors to expose.- Topics
- Subscription topics — granular unsubscribe categories for a team.
- Update
Broadcast Options - Fields default to “leave unchanged”. To detach the topic set
clear_topic_id: true, which puts"topic_id": nullon the wire. - Update
Contact Options - Fields default to “leave unchanged”. For
first_name/last_name,Some(Some(v))sets,Some(None)clears the field (sendsnull), andNoneomits it. - Update
Contact Property Options Noneleaves the fallback unchanged;Some(Value::Null)clears it.- Update
Contact Topics Response - Update
Domain Options tracking_subdomain:Some(Some(label))sets,Some(None)clears (sendsnull),Noneleaves it.tls/capabilitiesare passed through so the API, not the SDK, decides whether they are supported (422 while not).- Update
Email Options PATCH /emails/:id— reschedule a not-yet-sent email.- Update
Email Response - Update
Segment Options filter:Some(Some(f))replaces the filter,Some(None)clears it (sendsnull, turning the segment manual-membership-only),Noneleaves it.- Update
Template Options - For
subject/text/alias,Some(Some(v))sets,Some(None)clears (sendsnull),Noneleaves the field unchanged. - Update
Topic Options - Update
Webhook Options - Usage
- Plan limits and today’s send count (MillionSend extension).
- Usage
Limits None= unlimited (or self-hosted).- Usage
Report GET /usage— plan limits and today’s send count. Self-hosted instances reportcloud: falsewithplan: Noneand null limits.- Usage
Team - Usage
Today - Webhook
- Webhook
Id - Webhooks
- Webhook endpoints. Mirrors Resend’s
webhooksresource.
Enums§
- ApiKey
Permission - Batch
Contact Status - Batch
Remove Suppression Options - Remove by addresses or by suppression ids (up to 1000 either way);
serializes as
{ "emails": [...] }or{ "ids": [...] }. - Batch
Validation x-batch-validationon batch endpoints.Strict(the server default) rejects the whole batch when one item is invalid;Permissiveaccepts the valid subset and lists the rest undererrors.- Contact
Property Type - Error
- Every fallible SDK call resolves to
Result<T, Error>. - OnConflict
on_conflictforPOST /contacts/batch: what happens to an item whose email already belongs to a contact (or repeats inside the batch).- Recipients
- A recipient field that accepts a single address or a list — serializes as a
bare string or a JSON array to match the wire’s
string | string[]. - Segment
Match - Suppression
Origin - Topic
Subscription - Topic
Visibility - Webhook
Status
Traits§
- Idempotent
Trait - Resend’s idempotency shape:
ms.emails.send(email.with_idempotency_key("k"))andms.batch.send(emails.with_idempotency_key("k")).
Type Aliases§
- Delete
ApiKey Response - Delete
Contact Property Response - Delete
Domain Response - Delete
Email Response - Delete
Suppression Response - Delete
Template Response - Delete
Webhook Response - Result
- Shorthand for
std::result::Result<T, millionsend::Error>.