Send, list, fetch, reschedule and cancel emails.
Input maps use snake_case keys and are sent to the API as given — every key
reaches the wire: from, to, subject, html, text, cc, bcc,
reply_to, scheduled_at, tags, topic_id, attachments, headers and
template. :to, :cc, :bcc and :reply_to take a string or a list of
strings.
MillionSend.Emails.send(%{
from: "Acme <onboarding@acme.dev>",
to: "delivered@resend.dev",
subject: "Hello",
html: "<strong>it works</strong>",
tags: [%{name: "campaign", value: "welcome"}],
attachments: [%{filename: "hi.txt", content: Base.encode64("hi")}]
})
Summary
Functions
POST /emails/:id/cancel — only scheduled, unsent emails.
GET /emails/:id
GET /emails/:id/insights — the email's deliverability insights report.
Returns a "not_found" error until insights exist for the email.
GET /emails — accepts limit:, after:, before:.
DELETE /emails/:id
POST /emails. Accepts an optional leading client and an optional
idempotency_key: in the trailing options.
POST /emails/batch — 1..100 emails in one call. Options: idempotency_key:
and batch_validation: (:strict, the default, or :permissive; sent as the
x-batch-validation header).
PATCH /emails/:id — reschedule a scheduled, unsent email. params carries
scheduled_at: (a map or keyword list).
Functions
@spec cancel(MillionSend.Client.t(), String.t()) :: {:ok, MillionSend.Emails.Email.t()} | {:error, MillionSend.Error.t()}
POST /emails/:id/cancel — only scheduled, unsent emails.
@spec get(MillionSend.Client.t(), String.t()) :: {:ok, MillionSend.Emails.Email.t()} | {:error, MillionSend.Error.t()}
GET /emails/:id
@spec get_insights(MillionSend.Client.t(), String.t()) :: {:ok, MillionSend.Emails.Insights.t()} | {:error, MillionSend.Error.t()}
GET /emails/:id/insights — the email's deliverability insights report.
Returns a "not_found" error until insights exist for the email.
GET /emails — accepts limit:, after:, before:.
@spec list(MillionSend.Client.t() | keyword()) :: {:ok, MillionSend.List.t()} | {:error, MillionSend.Error.t()}
@spec list( MillionSend.Client.t(), keyword() ) :: {:ok, MillionSend.List.t()} | {:error, MillionSend.Error.t()}
@spec remove(MillionSend.Client.t(), String.t()) :: {:ok, MillionSend.Emails.Email.t()} | {:error, MillionSend.Error.t()}
DELETE /emails/:id
@spec send(map()) :: {:ok, MillionSend.Emails.Email.t()} | {:error, MillionSend.Error.t()}
POST /emails. Accepts an optional leading client and an optional
idempotency_key: in the trailing options.
@spec send(MillionSend.Client.t() | map(), map() | keyword()) :: {:ok, MillionSend.Emails.Email.t()} | {:error, MillionSend.Error.t()}
@spec send(MillionSend.Client.t(), map(), keyword()) :: {:ok, MillionSend.Emails.Email.t()} | {:error, MillionSend.Error.t()}
@spec send_batch([map()]) :: {:ok, [MillionSend.Emails.Email.t()]} | {:error, MillionSend.Error.t()}
POST /emails/batch — 1..100 emails in one call. Options: idempotency_key:
and batch_validation: (:strict, the default, or :permissive; sent as the
x-batch-validation header).
Strict mode is all-or-nothing and returns the accepted emails as a plain
list. Permissive mode writes the valid subset and returns a
MillionSend.Emails.BatchResponse whose errors lists the rejected items by
request index.
@spec send_batch(MillionSend.Client.t() | [map()], [map()] | keyword()) :: {:ok, [MillionSend.Emails.Email.t()] | MillionSend.Emails.BatchResponse.t()} | {:error, MillionSend.Error.t()}
@spec send_batch(MillionSend.Client.t(), [map()], keyword()) :: {:ok, [MillionSend.Emails.Email.t()] | MillionSend.Emails.BatchResponse.t()} | {:error, MillionSend.Error.t()}
@spec update(MillionSend.Client.t(), String.t(), map() | keyword()) :: {:ok, MillionSend.Emails.Email.t()} | {:error, MillionSend.Error.t()}
PATCH /emails/:id — reschedule a scheduled, unsent email. params carries
scheduled_at: (a map or keyword list).