Karta. Webhooks. Format
(Karta v1.0.0)
The formats of webhook requests. A webhook's format is chosen when it is added and does not change; it decides the body, the headers and the signature of every request, and which event types the webhook can receive. Events, deliveries, retries, dead letters and replays are the same in every format.
:standard- Karta's own payload (Karta.Webhooks.Payload), signed as Standard Webhooks (Karta.Webhooks.Signature) with the webhook'swhsec_secret. Every event type.:mailgun- Mailgun's webhook payload (Karta.Webhooks.Mailgun):signatureandevent-data, signed with the webhook's signing key.:postal- Postal's webhook payload (Karta.Webhooks.Postal):event,timestamp,payloadanduuid, signed with the key of the webhook's organisation (Karta.Webhooks.PostalKey); the webhook has no secret.:sendgrid- SendGrid's Event Webhook (Karta.Webhooks.Sendgrid): an array of one event, signed with the webhook's ECDSA key pair; the private key is never shown, the public key always is (public_key/1).:postmark- Postmark's webhooks (Karta.Webhooks.Postmark): one object per event byRecordType, not signed (a user name and password in the URL authenticate Karta); the webhook has no secret.
webhook.test (send_test) is sent in every format.
Summary
Functions
The formats, the default first.
A new secret for a webhook in this format: whsec_ and base64 for
Standard Webhooks, 64 hexadecimal digits for Mailgun's signing key, an
ECDSA private key (PEM) for SendGrid's; none for Postal's format, which
the organisation's key signs, nor for Postmark's, which is not signed.
What the pages offer to choose from: subscribable_types/1, the
messaging events only while the module is on.
True when the previous secret signs too for a while after a rotation; Mailgun's and SendGrid's requests have room for one signature only.
The body of the delivery's requests as far as it is the same in every
request: Mailgun's signature is made for each request and left out.
The public key receivers verify the webhook's requests with, or nil (SendGrid's format only).
True when a webhook in this format receives events of this type (the test event included).
The headers and body of a request about the delivery's event (preloaded)
to the webhook, made at now.
True when webhooks in this format have a secret of their own (that can be rotated).
True when the secret is shown (once, when it is made) to the webhook's owners: not SendGrid's private key, whose public key they get instead.
The event types a webhook in this format may name: types/1, and for
Karta's own format, while the messaging module is on, the messaging events
too (Karta.Webhooks.Catalogue.messaging_types/0), which a webhook
receives only when it names them. With the module off they are not
accepted.
The event types a webhook in this format can receive.
Functions
@spec formats() :: [atom()]
The formats, the default first.
A new secret for a webhook in this format: whsec_ and base64 for
Standard Webhooks, 64 hexadecimal digits for Mailgun's signing key, an
ECDSA private key (PEM) for SendGrid's; none for Postal's format, which
the organisation's key signs, nor for Postmark's, which is not signed.
What the pages offer to choose from: subscribable_types/1, the
messaging events only while the module is on.
True when the previous secret signs too for a while after a rotation; Mailgun's and SendGrid's requests have room for one signature only.
@spec preview(Karta.Webhooks.Webhook.t(), Karta.Webhooks.Delivery.t()) :: String.t()
The body of the delivery's requests as far as it is the same in every
request: Mailgun's signature is made for each request and left out.
@spec public_key(Karta.Webhooks.Webhook.t()) :: String.t() | nil
The public key receivers verify the webhook's requests with, or nil (SendGrid's format only).
True when a webhook in this format receives events of this type (the test event included).
@spec request(Karta.Webhooks.Webhook.t(), Karta.Webhooks.Delivery.t(), DateTime.t()) :: {[{String.t(), String.t()}], String.t()}
The headers and body of a request about the delivery's event (preloaded)
to the webhook, made at now.
True when webhooks in this format have a secret of their own (that can be rotated).
True when the secret is shown (once, when it is made) to the webhook's owners: not SendGrid's private key, whose public key they get instead.
The event types a webhook in this format may name: types/1, and for
Karta's own format, while the messaging module is on, the messaging events
too (Karta.Webhooks.Catalogue.messaging_types/0), which a webhook
receives only when it names them. With the module off they are not
accepted.
The event types a webhook in this format can receive.