Sendio.Transactional (sendio v1.2.0)
Manage transactional emails in Sendio (/transactional).
A transactional email is a named, saved send of a published template: a sign-in code, a password reset, a
receipt. It stores the envelope (From, subject, preview text, reply-to, and open and click tracking, off by
default) and a template; the content is always the template's published version at send time. Send it with
Sendio.Emails.send/1 and :transactional_id, passing only the recipient and its :variables:
{:ok, tx} =
Sendio.Transactional.create(
name: "Sign-in code",
template_id: "signin-code",
from: "Acme <security@yourdomain.com>",
subject: "Your code is {{CODE}}"
)
Sendio.Emails.send(%{transactional_id: tx.id, to: "ada@example.com", variables: %{CODE: "123456"}})A republish of the template, or an update, reaches every send within 10 seconds.
Summary
Functions
Creates a transactional email.
Gets a transactional email, with the variables of the template version its sends use now.
Lists transactional emails, newest first.
Removes a transactional email; sends of it then fail with 404. Its stats stay readable.
Sends a transactional email to 1 to 5 addresses now, with "[Test] " before the subject. Tests are not counted in stats.
Reads a transactional email's numbers in a period (the last 30 days by default).
Updates a transactional email. Only the options given are changed; sends use the change within 10 seconds.
Functions
create(opts)
@spec create(Keyword.t()) :: Sendio.Client.response(Sendio.Transactional.TransactionalEmail.t())
Creates a transactional email.
Options
:name- The name, 1 to 255 characters (required):template_id- The id or alias of a published template (required):from- The sender, on a verified sending domain (required):subject- The subject; it may use the template's variables, e.g."Your code is {{CODE}}"(required):preview_text- The inbox preview text:reply_to- A reply-to address or a list of them (at most 50):track_opens-truetracks opens (defaultfalse):track_clicks-truetracks clicks (defaultfalse)
Request options (an optional keyword list after the options):
:idempotency_key- Sent as theIdempotency-Keyheader. Retrying with the same key returns the first result instead of creating a second transactional email.
create(client, opts)
@spec create(Sendio.Client.t(), Keyword.t()) :: Sendio.Client.response(Sendio.Transactional.TransactionalEmail.t())
@spec create(Keyword.t(), Keyword.t()) :: Sendio.Client.response(Sendio.Transactional.TransactionalEmail.t())
create(client, opts, request_opts)
@spec create(Sendio.Client.t(), Keyword.t(), Keyword.t()) :: Sendio.Client.response(Sendio.Transactional.TransactionalEmail.t())
get(client \\ Sendio.client(), transactional_id)
@spec get(Sendio.Client.t(), String.t()) :: Sendio.Client.response(Sendio.Transactional.TransactionalEmail.t())
Gets a transactional email, with the variables of the template version its sends use now.
list(client_or_opts \\ [])
@spec list(Keyword.t()) :: Sendio.Client.response( Sendio.List.t(Sendio.Transactional.TransactionalEmail.t()) )
Lists transactional emails, newest first.
Options
:limit- Maximum number of transactional emails to return (1-100):after- Cursor for pagination (transactional email ID to start after):before- Cursor for pagination (transactional email ID to start before):search- Only transactional emails whose name or subject matches (case-insensitive):template_id- Only the transactional emails of this template (id or alias)
list(client, opts)
@spec list(Sendio.Client.t(), Keyword.t()) :: Sendio.Client.response( Sendio.List.t(Sendio.Transactional.TransactionalEmail.t()) )
remove(client \\ Sendio.client(), transactional_id)
@spec remove(Sendio.Client.t(), String.t()) :: Sendio.Client.response(Sendio.Transactional.TransactionalEmail.t())
Removes a transactional email; sends of it then fail with 404. Its stats stay readable.
send_test(client \\ Sendio.client(), transactional_id, opts)
@spec send_test(Sendio.Client.t(), String.t(), Keyword.t()) :: Sendio.Client.response(Sendio.Emails.Email.t())
Sends a transactional email to 1 to 5 addresses now, with "[Test] " before the subject. Tests are not counted in stats.
Options
:to- An address or a list of 1 to 5 addresses (required):variables- The template variables, e.g.%{CODE: "123456"}
stats(client_or_id, id_or_opts \\ [])
@spec stats(String.t(), Keyword.t()) :: Sendio.Client.response(Sendio.Transactional.Stats.t())
Reads a transactional email's numbers in a period (the last 30 days by default).
Options
:fromand:to- A date ("2026-11-01") or an ISO 8601 time; at most 90 days apart:timezone- An IANA time zone (default UTC):version- One template version: an id, or a version number of the current template:granularity-"daily"(the default) or"hourly"
stats(client, transactional_id, opts)
@spec stats(Sendio.Client.t(), String.t(), Keyword.t()) :: Sendio.Client.response(Sendio.Transactional.Stats.t())
update(client \\ Sendio.client(), transactional_id, opts)
@spec update(Sendio.Client.t(), String.t(), Keyword.t()) :: Sendio.Client.response(Sendio.Transactional.TransactionalEmail.t())
Updates a transactional email. Only the options given are changed; sends use the change within 10 seconds.
Options
The same as create/2 (:template_id points it at another published template; preview_text: "" and
reply_to: [] clear them), and:
:expected_updated_at- Theupdated_atyou read (aDateTimeor the API's string). When the transactional email changed since, the update fails with 409conflictinstead of overwriting it.