MillionSend.Webhooks (MillionSend v0.6.0)

Copy Markdown View Source

Webhooks. Input maps are sent as given: create/2 accepts endpoint, events and an optional signing_secret (carry over an existing whsec_ secret so the receiver keeps verifying unchanged); update/3 accepts endpoint, events and status.

MillionSend.Webhooks.create(%{
  endpoint: "https://acme.dev/hooks/email",
  events: ["email.delivered", "email.bounced"]
})

Subscribable events: email.* (sent, delivered, delivery_delayed, bounced, complained, opened, clicked), deliverability.* (warning, paused), quota.* (warning, reached, paused), contact.* (created, updated, deleted, unsubscribed, resubscribed, topic_opt_in, topic_opt_out) and suppression.* (added, removed).

Summary

Functions

POST /webhooks — the response carries the signing_secret.

GET /webhooks/:id — includes the signing_secret.

GET /webhooks — accepts limit:, after:, before:.

POST /webhooks/:id/rotate — mint a new signing secret (or install the signing_secret: given, a whsec_ value). For overlap_hours: (0..72) the previous secret keeps signing too: every delivery in that window carries both signatures, so the receiver can switch at any point without a gap. Both options are optional; the response carries the new signing_secret and previous_secret_expires_at.

PATCH /webhooks/:idendpoint, events, status (:enabled | :disabled).

Functions

create(client \\ MillionSend.client(), params)

@spec create(MillionSend.Client.t(), map()) ::
  {:ok, MillionSend.Webhooks.Webhook.t()} | {:error, MillionSend.Error.t()}

POST /webhooks — the response carries the signing_secret.

get(client \\ MillionSend.client(), id)

GET /webhooks/:id — includes the signing_secret.

list()

GET /webhooks — accepts limit:, after:, before:.

list(client)

@spec list(MillionSend.Client.t() | keyword()) ::
  {:ok, MillionSend.List.t()} | {:error, MillionSend.Error.t()}

list(client, opts)

@spec list(
  MillionSend.Client.t(),
  keyword()
) :: {:ok, MillionSend.List.t()} | {:error, MillionSend.Error.t()}

remove(client \\ MillionSend.client(), id)

DELETE /webhooks/:id

rotate(id)

@spec rotate(String.t()) ::
  {:ok, MillionSend.Webhooks.Webhook.t()} | {:error, MillionSend.Error.t()}

POST /webhooks/:id/rotate — mint a new signing secret (or install the signing_secret: given, a whsec_ value). For overlap_hours: (0..72) the previous secret keeps signing too: every delivery in that window carries both signatures, so the receiver can switch at any point without a gap. Both options are optional; the response carries the new signing_secret and previous_secret_expires_at.

MillionSend.Webhooks.rotate(id)
MillionSend.Webhooks.rotate(id, overlap_hours: 24)

rotate(client, id)

rotate(client, id, opts)

update(client \\ MillionSend.client(), id, params)

@spec update(MillionSend.Client.t(), String.t(), map()) ::
  {:ok, MillionSend.Webhooks.Webhook.t()} | {:error, MillionSend.Error.t()}

PATCH /webhooks/:idendpoint, events, status (:enabled | :disabled).