Webhook subscriptions.
- Project webhooks (
list/2,create/2, ...) receive project-wide events: connection lifecycle, workflow executions, custom events. - Phone number webhooks (
*_for_phone_number) receive message and conversation events for one number.kind: "kapso"sends Kapso's payloads;kind: "meta"forwards Meta's payloads unchanged.
Verify deliveries with KapsoEx.Webhook. Event names are listed in
Message events
and Project webhooks.
Summary
Functions
Creates a project webhook.
Subscribes a URL to a phone number's events. Attributes as in create/2;
events is required for kind: "kapso". Only one kind: "meta" webhook
is allowed per number.
Deletes a project webhook.
Deletes a phone number webhook.
Gets a project webhook.
Gets a phone number webhook.
Lists the project's webhooks (project and phone number scoped), most
recent first. Params: kind, page, per_page.
Lists a phone number's webhooks, most recent first.
Sends a test payload to the webhook URL, optionally for a specific event_type.
Updates a project webhook. Attributes as in create/2.
Updates a phone number webhook.
Types
@type result() :: {:ok, map() | nil} | {:error, KapsoEx.Error.t()}
Functions
@spec create(KapsoEx.Client.t(), map() | keyword()) :: result()
Creates a project webhook.
Attributes: url (required), events, secret_key, active,
headers, kind, phone_number_id, payload_version, and the
buffering settings (buffer_enabled, buffer_window_seconds,
max_buffer_size, buffer_events, inactivity_minutes).
Webhooks.create(client, url: "https://example.com/kapso", events: ["whatsapp.phone_number.created"])
@spec create_for_phone_number(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
Subscribes a URL to a phone number's events. Attributes as in create/2;
events is required for kind: "kapso". Only one kind: "meta" webhook
is allowed per number.
Webhooks.create_for_phone_number(client, phone_number_id, %{
url: "https://example.com/kapso",
events: ["whatsapp.message.received", "whatsapp.message.failed"],
secret_key: "..."
})
@spec delete(KapsoEx.Client.t(), String.t()) :: result()
Deletes a project webhook.
@spec delete_for_phone_number(KapsoEx.Client.t(), String.t(), String.t()) :: result()
Deletes a phone number webhook.
@spec get(KapsoEx.Client.t(), String.t()) :: result()
Gets a project webhook.
@spec get_for_phone_number(KapsoEx.Client.t(), String.t(), String.t()) :: result()
Gets a phone number webhook.
@spec list(KapsoEx.Client.t(), map() | keyword()) :: result()
Lists the project's webhooks (project and phone number scoped), most
recent first. Params: kind, page, per_page.
@spec list_for_phone_number(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
Lists a phone number's webhooks, most recent first.
Params: url_contains, kind, active, created_after,
created_before, page, per_page.
@spec test(KapsoEx.Client.t(), String.t(), String.t() | nil) :: result()
Sends a test payload to the webhook URL, optionally for a specific event_type.
@spec update(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
Updates a project webhook. Attributes as in create/2.
@spec update_for_phone_number( KapsoEx.Client.t(), String.t(), String.t(), map() | keyword() ) :: result()
Updates a phone number webhook.