Karta. Inbound. HTTPRequest
(Karta v1.0.0)
The POST of a received message to an HTTP endpoint, in the endpoint's
format, and what its answer means.
:karta- JSON,Content-Type: application/json:{"type": "message.received", "timestamp": "...", "data": { "id": delivery id, "message_id": Karta's message id, "server_id", "route_id", "mail_from", "rcpt_to", "header_message_id", "from", "subject", "size", "received_at", "authentication": what Karta found out about the sender (SPF, DKIM, DMARC, ARC; `Karta.Auth.to_map/1`, as the inbound API shows it) or null, "raw": the message, base64}}signed as Standard Webhooks (
Karta.Webhooks.Signature) with the endpoint's secret:webhook-id(the delivery's id, the same on every attempt),webhook-timestamp,webhook-signature.:raw- the message itself,Content-Type: message/rfc822, signed the same way, with the envelope inX-Karta-Mail-From,X-Karta-Rcpt-To(percent-encoded beyond printable ASCII) and the message's id inX-Karta-Message-Id.:postal- Postal'sRawMessage:id(the delivery's id, where Postal had a number),rcpt_to,mail_from,message(base64 in lines of 60 characters, as Ruby'sBase64.encode64writes it),base64: true,size; as JSON or as form data (encoding, encoded as Ruby'sURI.encode_www_formdoes), signed as Postal signs with the key of the endpoint's organisation (X-Postal-Signature-KID,X-Postal-Signature,X-Postal-Signature-256;Karta.Webhooks.Postal.headers/2).
A notify-only endpoint (Karta.Inbound.Endpoint) in this format gets
the same JSON without raw; size is then the stored size.
The parsed formats are built by Karta.Inbound.Formats: Postal's
Hash, a Mailgun route's forward() post, SendGrid's Inbound Parse in
its raw form, and Postmark's inbound webhook.
The message is the stored one: Karta's Received: field and the message
as it arrived. An endpoint whose URL had a user name and password gets
them as Basic authentication, and one with an extra authentication
header gets it beside the format's signature (Karta.RequestAuth).
Answers (outcome/2). A 2xx answer delivers. In Karta's formats,
408, 429 and 5xx answers, and requests that got no answer, are tried
again; any other answer fails. In Postal's formats, as Postal: 5xx and
no answer are tried again, anything else (429 too) fails. In Mailgun's,
as Mailgun: 406 fails, and anything else is tried again. In Postmark's,
as Postmark: 403 fails, and anything else is tried again.
Summary
Functions
Basic authentication with an endpoint's URL's user name and password, if it had them.
The headers and body of the request for delivery of message, stored
as raw, or why a parsed format could not read the message.
What an answer (or its absence) means for a delivery in format.
Types
Functions
@spec authorization(Karta.Inbound.Endpoint.t()) :: [{String.t(), String.t()}]
Basic authentication with an endpoint's URL's user name and password, if it had them.
@spec build( Karta.Inbound.Endpoint.t(), Karta.Inbound.Delivery.t(), Karta.Messages.Message.t(), binary(), DateTime.t() ) :: {:ok, [{String.t(), String.t()}], binary()} | {:error, String.t()}
The headers and body of the request for delivery of message, stored
as raw, or why a parsed format could not read the message.
What an answer (or its absence) means for a delivery in format.