Skip to main content

Crate millionsend

Crate millionsend 

Source
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§

AddContactSegmentResponse
AddSuppressionOptions
origin defaults to manual server-side.
ApiError
The API’s canonical error shape ({ statusCode, name, message }), plus the client-side conditions that never reached the API, which carry status_code: None. Mirrors Resend’s ErrorResponse, so code that switches on name ports across unchanged.
ApiKey
ApiKeyToken
The token is shown once, at creation.
ApiKeys
API keys. Mirrors Resend’s api_keys resource.
Attachment
An attachment. content is base64; path is passed through so the API, not the SDK, decides whether remote attachments are accepted.
Batch
Batch send. Mirrors Resend’s batch resource.
BatchAddSuppressionOptions
Up to 1000 addresses; duplicates collapse.
BatchAddSuppressionResponse
BatchContactResult
BatchContactsCounts
Per-status totals; they sum to the request length.
BatchContactsOptions
BatchContactsResponse
BatchError
A per-item failure from a permissive batch, addressed by request index.
BatchRemoveSuppressionsResponse
BatchResponse
errors is only populated under BatchValidation::Permissive.
Broadcast
BroadcastId
BroadcastListItem
Broadcasts
Broadcasts — a one-off email to a segment, a topic’s subscribers, or (with neither set) every contact. Mirrors Resend’s broadcasts resource.
CancelBroadcastResponse
CancelEmailResponse
Contact
ContactAddress
Address a contact by id or email (email wins when both are set). A bare &str/String is treated as an id.
ContactId
ContactListItem
ContactProperties
Typed definitions for the keys of contact.properties (/contact-properties).
ContactProperty
ContactPropertyId
ContactSegments
Manual segment membership for one contact.
ContactTopicUpdate
ContactTopics
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 contacts resource, plus nested topics, segments and properties.
CreateApiKeyOptions
permission defaults to full_access; domain_id restricts a sending_access key to one domain.
CreateBroadcastOptions
CreateContactOptions
Build with CreateContactOptions::new(email). Contacts are team-global; duplicates (case-insensitive email) are a 409 validation_error.
CreateContactPropertyOptions
fallback_value is Some(Value::Null) to store an explicit null; its JSON type must match type.
CreateDomainOptions
region is a plain string because each deployment serves its own SES region and rejects any other with 422; omit it to use the deployment’s.
CreateEmailResponse
CreateSegmentOptions
filter: None creates a manual-membership segment, fed only by contacts.segments.add and contacts.create’s segments.
CreateTemplateOptions
from, reply_to and variables are passed through so the API, not the SDK, decides whether they are supported (422 while not).
CreateTopicOptions
CreateWebhookOptions
events are wire names (email.delivered, deliverability.paused, …), kept as strings because the catalog grows. signing_secret is optional: omit it to have one minted; pass whsec_… to reuse an existing one.
CreateWebhookResponse
DeleteBroadcastResponse
DeleteContactResponse
DeleteSegmentResponse
DeleteTopicResponse
Deleted
{ object, id, deleted: true } — the envelope every delete returns.
Deliverability
Account-level deliverability score over the trailing window.
DeliverabilityReport
GET /deliverability — the account score over the trailing window. Scores are 0–10 with one decimal; None means not enough data to compute.
Domain
DomainCapabilities
DomainRecord
Domains
Sending domains and their DNS records. Mirrors Resend’s domains resource.
Email
EmailInsights
GET /emails/:id/insights — the pre-send best-practice report computed when the email was sent.
EmailListItem
GET /emails item — the summary without bodies, message_id or score.
Emails
Transactional email. Mirrors Resend’s emails resource.
Idempotent
A request body paired with an optional Idempotency-Key. Any body converts implicitly (ms.emails.send(&email)); attach a key with with_idempotency_key.
InsightCheck
One check from the insights report. id is an open catalog that grows across score versions; severity/status stay plain strings for the same reason band does.
List
The { object: "list", data, has_more } envelope every paginated list returns.
ListOptions
Keyset pagination for list calls. after/before are mutually exclusive UUID cursors; limit is 1–100 (server default 20).
ListSuppressionsOptions
ListOptions plus an optional origin filter.
MillionSend
The MillionSend client. Construct once and reuse.
RemoveContactSegmentResponse
Segment
SegmentCondition
SegmentFilter
SegmentRef
{ id } — a segment referenced from a contact payload.
Segments
Dynamic segments — a saved filter over the team’s contacts (MillionSend extension, no Resend equivalent). get returns a live contact_count.
SendEmailOptions
Build with SendEmailOptions::new(from, to, subject) then set the rest, or a struct literal with ..Default::default().
Suppression
SuppressionId
Suppressions
Suppression list — addresses the team never sends to. Mirrors Resend’s suppressions resource; entries are addressable by id or email.
Tag
Template
TemplateId
TemplateListItem
Templates
Reusable email templates, addressable by id or alias. Mirrors Resend’s templates resource; templates are always published, so publish is a compatibility no-op.
Topic
TopicId
TopicList
GET /topics returns every topic at once (has_more is always false), so there are no cursors to expose.
Topics
Subscription topics — granular unsubscribe categories for a team.
UpdateBroadcastOptions
Fields default to “leave unchanged”. To detach the topic set clear_topic_id: true, which puts "topic_id": null on the wire.
UpdateContactOptions
Fields default to “leave unchanged”. For first_name/last_name, Some(Some(v)) sets, Some(None) clears the field (sends null), and None omits it.
UpdateContactPropertyOptions
None leaves the fallback unchanged; Some(Value::Null) clears it.
UpdateContactTopicsResponse
UpdateDomainOptions
tracking_subdomain: Some(Some(label)) sets, Some(None) clears (sends null), None leaves it. tls/capabilities are passed through so the API, not the SDK, decides whether they are supported (422 while not).
UpdateEmailOptions
PATCH /emails/:id — reschedule a not-yet-sent email.
UpdateEmailResponse
UpdateSegmentOptions
filter: Some(Some(f)) replaces the filter, Some(None) clears it (sends null, turning the segment manual-membership-only), None leaves it.
UpdateTemplateOptions
For subject/text/alias, Some(Some(v)) sets, Some(None) clears (sends null), None leaves the field unchanged.
UpdateTopicOptions
UpdateWebhookOptions
Usage
Plan limits and today’s send count (MillionSend extension).
UsageLimits
None = unlimited (or self-hosted).
UsageReport
GET /usage — plan limits and today’s send count. Self-hosted instances report cloud: false with plan: None and null limits.
UsageTeam
UsageToday
Webhook
WebhookId
Webhooks
Webhook endpoints. Mirrors Resend’s webhooks resource.

Enums§

ApiKeyPermission
BatchContactStatus
BatchRemoveSuppressionOptions
Remove by addresses or by suppression ids (up to 1000 either way); serializes as { "emails": [...] } or { "ids": [...] }.
BatchValidation
x-batch-validation on batch endpoints. Strict (the server default) rejects the whole batch when one item is invalid; Permissive accepts the valid subset and lists the rest under errors.
ContactPropertyType
Error
Every fallible SDK call resolves to Result<T, Error>.
OnConflict
on_conflict for POST /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[].
SegmentMatch
SuppressionOrigin
TopicSubscription
TopicVisibility
WebhookStatus

Traits§

IdempotentTrait
Resend’s idempotency shape: ms.emails.send(email.with_idempotency_key("k")) and ms.batch.send(emails.with_idempotency_key("k")).

Type Aliases§

DeleteApiKeyResponse
DeleteContactPropertyResponse
DeleteDomainResponse
DeleteEmailResponse
DeleteSuppressionResponse
DeleteTemplateResponse
DeleteWebhookResponse
Result
Shorthand for std::result::Result<T, millionsend::Error>.