KartaWeb.API.V2.SendParams (Karta v1.0.0)

The fields Karta.Sending takes, from the request bodies of POST /api/v2/messages, POST /api/v2/messages/raw and POST /api/v2/messages/batch as OpenApiSpex.Plug.CastAndValidate cast them (KartaWeb.API.V2.Schemas).

The options of a message:

  • tag and tags are one list of tags: tag first, then tags, without duplicates; the first is the message's tag. Karta.Sending checks them (at most 10, each 1 to 128 bytes of text).
  • variables has text values (the document says so); a name has 1 to 128 bytes and no control characters. Karta.Sending checks the size (16 KiB as JSON).
  • send_at is a time with an offset, which the cast has turned into UTC.
  • track_opens and track_clicks: false switches that tracking off for the message; true is the same as leaving it out.

An option that cannot be kept is {:error, code, message, details}, as KartaWeb.API.V2.Errors.render/5 takes it; details names the field (a JSON pointer).

Summary

Functions

The fields of each message of a batch for Karta.Sending.send_batch/3, in the order of the recipients: the batch's parts and options, with the recipient alone in To, its replacements made in the subject, the text and the HTML (KartaWeb.API.V2.Replacements), and its variables over the batch's. Every recipient is checked before anything is sent; the first problem is the error, with the recipient's index in details.

Types

error()

@type error() :: {:error, String.t(), String.t(), [map()]}

Functions

batch(body)

@spec batch(map()) :: {:ok, [map()]} | error()

The fields of each message of a batch for Karta.Sending.send_batch/3, in the order of the recipients: the batch's parts and options, with the recipient alone in To, its replacements made in the subject, the text and the HTML (KartaWeb.API.V2.Replacements), and its variables over the batch's. Every recipient is checked before anything is sent; the first problem is the error, with the recipient's index in details.

A batch has at most Karta.Sending.Options.batch_limit/0 recipients (too_many_recipients), and its messages at most 50 MiB of content together (subject, text, HTML and attachments, after replacement; batch_too_large). They are counted as they are made (Karta.Sending.Options.make_batch/2), so a batch that is too large is refused before it is made whole.

message(body)

@spec message(map()) :: {:ok, map()} | error()

The fields for Karta.Sending.send_message/3.

raw(body)

@spec raw(map()) :: {:ok, map()} | error()

The fields for Karta.Sending.send_raw/3.