TreasuryPrime.Webhook (TreasuryPrime v1.0.0)

Copy Markdown View Source

Registers a URL to be notified whenever a given event fires. See TreasuryPrime.WebhookEvent for the shape of what gets POSTed to your url, and TreasuryPrime.WebhookSignature for verifying authenticity.

Creating a webhook

{:ok, webhook} =
  TreasuryPrime.Webhook.create(client, %{
    event: "ach.update",
    url: "https://example.application.com/notify",
    basic_user: "myapp",
    basic_secret: "a long random secret"
  })

One TreasuryPrime.Webhook object covers exactly one event type — to subscribe to multiple events, create one webhook per event (they can all point at the same url).

Event catalog

Common events include account.update, ach.update, wire.update, book.update, card.update, card_event.create, check_deposit.update, check.update, fednow.update, network_transfer.update, account_application.update, business_application.update, person_application.update, kyc.update, incoming_ach.create, incoming_wire.create, digital_wallet_token.update, greendot.update, account_tax_document.update, account_statement.create, and more — see Treasury Prime's Event Types reference for the authoritative, current list (it grows as new resources ship).

Summary

Functions

Creates a webhook. Required: event, url. Strongly recommended: basic_user + basic_secret, so you can verify incoming notifications with TreasuryPrime.WebhookSignature.valid?/3.

Deletes a webhook.

Disables a webhook without deleting it (so it stops receiving notifications but keeps its config).

Re-enables a previously disabled webhook.

Fetches a single webhook by id.

Lists webhooks.

Updates a webhook (e.g. url, status, credentials).

Types

t()

@type t() :: %TreasuryPrime.Webhook{
  basic_secret: String.t() | nil,
  basic_user: String.t() | nil,
  created_at: String.t() | nil,
  error: String.t() | nil,
  event: String.t() | nil,
  id: String.t() | nil,
  status: String.t() | nil,
  updated_at: String.t() | nil,
  url: String.t() | nil,
  userdata: map() | nil
}

Functions

create(client, params, opts \\ [])

@spec create(TreasuryPrime.Client.t(), map(), keyword()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Creates a webhook. Required: event, url. Strongly recommended: basic_user + basic_secret, so you can verify incoming notifications with TreasuryPrime.WebhookSignature.valid?/3.

create!(client, params, opts \\ [])

@spec create!(TreasuryPrime.Client.t(), map(), keyword()) :: t()

delete(client, id)

@spec delete(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, nil} | {:error, TreasuryPrime.Error.t()}

Deletes a webhook.

delete!(client, id)

@spec delete!(TreasuryPrime.Client.t(), String.t()) :: nil

disable(client, id)

@spec disable(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Disables a webhook without deleting it (so it stops receiving notifications but keeps its config).

enable(client, id)

@spec enable(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Re-enables a previously disabled webhook.

get(client, id)

@spec get(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Fetches a single webhook by id.

get!(client, id)

@spec get!(TreasuryPrime.Client.t(), String.t()) :: t()

list(client, params \\ %{})

@spec list(TreasuryPrime.Client.t(), map()) ::
  {:ok, TreasuryPrime.Page.t()} | {:error, TreasuryPrime.Error.t()}

Lists webhooks.

Filterable params

event, status.

list!(client, params \\ %{})

update(client, id, params)

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

Updates a webhook (e.g. url, status, credentials).

update!(client, id, params)

@spec update!(TreasuryPrime.Client.t(), String.t(), map()) :: t()