Nuntly.Emails (nuntly v0.1.0)

Copy Markdown View Source

Send transactional emails, retrieve sending history, and track delivery status per message.

Summary

Functions

cancel_email(client, id, opts \\ [])

Cancel Email

Cancel a scheduled email before delivery. Only emails with scheduled status can be cancelled.

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • id — Required path parameter, string. The id of the email
  • opts — Optional keyword list passed to Req for this request.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.cancel_email(client, "id")

list_emails(client, params \\ %{}, opts \\ [])

List Emails

Returns sent emails ordered by submission date, newest first.

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • params — Optional map of query parameters:
    • "cursor" — Optional query parameter, string. Pagination cursor from a previous response
    • "limit" — Optional query parameter, integer. Maximum number of items to return Defaults to 30.
  • opts — Optional keyword list passed to Req for this request.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.list_emails(
  client,
  %{
    "cursor" => "cursor",
    "limit" => 30
  }
)

retrieve_bulk_emails(client, bulk_id, opts \\ [])

Retrieve Bulk Emails

Returns the emails submitted in a bulk request.

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • bulk_id — Required path parameter, string.
  • opts — Optional keyword list passed to Req for this request.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.retrieve_bulk_emails(client, "bulk-id")

retrieve_email(client, id, opts \\ [])

Retrieve Email

Returns an email with its current delivery status and metadata.

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • id — Required path parameter, string. The id of the email
  • opts — Optional keyword list passed to Req for this request.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.retrieve_email(client, "id")

retrieve_email_content(client, id, opts \\ [])

Retrieve Email Content

Returns presigned URLs to download the HTML, plain-text, and raw MIME source of a sent email.

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • id — Required path parameter, string.
  • opts — Optional keyword list passed to Req for this request.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.retrieve_email_content(client, "id")

retrieve_email_events(client, id, opts \\ [])

Retrieve Email Events

Returns the delivery event history for an email (sent, delivered, opened, bounced, etc.).

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • id — Required path parameter, string.
  • opts — Optional keyword list passed to Req for this request.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.retrieve_email_events(client, "id")

retrieve_email_stats(client, opts \\ [])

Retrieve Email Stats

Returns aggregated daily sending statistics for the current period.

Arguments

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.retrieve_email_stats(client)

send_bulk_emails(client, body, opts \\ [])

Send Bulk Emails

Send up to 20 emails in a single request. Use fallback to set default values shared across all messages.

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • body — application/json request body using CreateBulkEmailsRequest. Accepted fields:
    • "fallback" (CreateBulkFallback map, optional) — Used as a fallback field email value if no value is present in emails.
    • "emails" (list of CreateBulkEmail map, required) — The bulk emails to send.
  • opts — Optional keyword list passed to Req for this request.
    • "Idempotency-Key" — Optional header, string. Unique key to ensure the request is processed at most once. UUIDv4 recommended.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.send_bulk_emails(
  client,
  %{
    "emails" => [
      %{
        "from" => "Tomlinson AI <ray@info.tomlinson.ai>"
      }
    ]
  },
  headers: [{"Idempotency-Key", "idempotency-key"}]
)

send_email(client, body, opts \\ [])

Send Email

Send transactional emails through Nuntly platform. It supports HTML and plain-text emails, attachments, labels, custom headers and scheduling.

Arguments

  • client — A Nuntly.Client returned by Nuntly.new/1.
  • body — application/json request body using CreateEmailRequest. Accepted fields:
    • "from" (string, required) — The e-mail address of the sender
    • "to" (list of string or string, required) — The primary recipient(s) of the email
    • "cc" (list of string or string, optional) — The carbon copy recipient(s) of the email
    • "bcc" (list of string or string, optional) — The blind carbon copy recipient(s) of the email
    • "replyTo" (list of string or string, optional) — The email address where replies should be sent. If a recipient replies, the response will go to this address instead of the sender's email address
    • "subject" (string, required) — The subject of the e-mail
    • "text" (string, optional) — The plaintext version of the email
    • "html" (string, optional) — The HTML version of the email
    • "headers" (map, optional) — The headers to add to the email
    • "tags" (list of Tag map, optional) — The tags to add to the email
    • "attachments" (list of Attachment map, optional) — The attachements to add to the email
    • "variables" (map, optional) — The variables for the template
    • "scheduledAt" (string, optional) — The date at which the email is scheduled to be sent
  • opts — Optional keyword list passed to Req for this request.
    • "Idempotency-Key" — Optional header, string. Unique key to ensure the request is processed at most once. UUIDv4 recommended.

Example

client = Nuntly.new(api_key: "ntly_...")

Nuntly.Emails.send_email(
  client,
  %{
    "from" => "Tomlinson AI <ray@info.tomlinson.ai>",
    "to" => "brian67@gmail.com",
    "subject" => "Verify your email address"
  },
  headers: [{"Idempotency-Key", "idempotency-key"}]
)