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

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 - true tracks opens (default false)
  • :track_clicks - true tracks clicks (default false)

Request options (an optional keyword list after the options):

  • :idempotency_key - Sent as the Idempotency-Key header. Retrying with the same key returns the first result instead of creating a second transactional email.
Link to this function

create(client, opts)

Link to this function

create(client, opts, request_opts)

Link to this function

get(client \\ Sendio.client(), transactional_id)

Gets a transactional email, with the variables of the template version its sends use now.

Link to this function

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)
Link to this function

list(client, opts)

@spec list(Sendio.Client.t(), Keyword.t()) ::
  Sendio.Client.response(
    Sendio.List.t(Sendio.Transactional.TransactionalEmail.t())
  )
Link to this function

remove(client \\ Sendio.client(), transactional_id)

Removes a transactional email; sends of it then fail with 404. Its stats stay readable.

Link to this function

send_test(client \\ Sendio.client(), transactional_id, opts)

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"}
Link to this function

stats(client_or_id, id_or_opts \\ [])

Reads a transactional email's numbers in a period (the last 30 days by default).

Options

  • :from and :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"
Link to this function

stats(client, transactional_id, opts)

Link to this function

update(client \\ Sendio.client(), transactional_id, opts)

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 - The updated_at you read (a DateTime or the API's string). When the transactional email changed since, the update fails with 409 conflict instead of overwriting it.