Coffrify.Resources.Webhooks (Coffrify v0.9.0)

View Source

Webhook subscriptions.

Coffrify signs every delivery with Standard Webhooks v2 (webhook-id, webhook-timestamp, webhook-signature). Verify with Coffrify.Webhook.Verification.verify/4.

Summary

Functions

Create a webhook subscription.

Delete a webhook subscription.

Fetch the recent delivery attempts for a webhook (debug).

List every webhook subscribed in the workspace.

Replay a past delivery. Preserves the original event_id so the receiver can dedupe via webhook-id.

Force a non-success delivery back into the retry queue.

Rotate the webhook signing secret. Both new + previous secrets remain valid during the grace window (default 24h, max 168h).

Send a sandbox event to verify signing & URL. Receiver gets x-coffrify-test-delivery: true.

Patch a webhook (URL, events, is_active, …).

Functions

create(client, opts)

@spec create(Coffrify.t(), map() | keyword()) ::
  {:ok, map()} | {:error, Exception.t()}

Create a webhook subscription.

The returned secret MUST be stored — it is only returned once.

Example

{:ok, %{"webhook" => wh, "secret" => secret}} =
  Coffrify.Resources.Webhooks.create(client, %{
    name: "Production",
    url: "https://api.example.com/hooks/coffrify",
    events: ["transfer.created", "transfer.downloaded"]
  })

delete(client, id)

@spec delete(Coffrify.t(), String.t()) :: {:ok, map()} | {:error, Exception.t()}

Delete a webhook subscription.

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

@spec deliveries(Coffrify.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Exception.t()}

Fetch the recent delivery attempts for a webhook (debug).

list(client)

@spec list(Coffrify.t()) :: {:ok, map()} | {:error, Exception.t()}

List every webhook subscribed in the workspace.

replay(client, delivery_id)

@spec replay(Coffrify.t(), String.t()) :: {:ok, map()} | {:error, Exception.t()}

Replay a past delivery. Preserves the original event_id so the receiver can dedupe via webhook-id.

retry(client, delivery_id)

@spec retry(Coffrify.t(), String.t()) :: {:ok, map()} | {:error, Exception.t()}

Force a non-success delivery back into the retry queue.

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

@spec rotate_secret(Coffrify.t(), String.t(), keyword() | map()) ::
  {:ok, map()} | {:error, Exception.t()}

Rotate the webhook signing secret. Both new + previous secrets remain valid during the grace window (default 24h, max 168h).

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

@spec test(Coffrify.t(), String.t(), keyword() | map()) ::
  {:ok, map()} | {:error, Exception.t()}

Send a sandbox event to verify signing & URL. Receiver gets x-coffrify-test-delivery: true.

update(client, id, updates)

@spec update(Coffrify.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Exception.t()}

Patch a webhook (URL, events, is_active, …).