Send an approved template to many recipients, with per-recipient tracking. See the Broadcasts API guide.
Typical flow:
{:ok, %{"data" => %{"id" => id}}} =
Broadcasts.create(client, name: "Black Friday", phone_number_id: pnid, whatsapp_template_id: tid)
{:ok, _} =
Broadcasts.add_recipients(client, id, [
%{phone_number: "+56961567267", components: [%{type: "body", parameters: [%{type: "text", text: "Ana"}]}]}
])
{:ok, _} = Broadcasts.send(client, id)Kapso paces sends to stay within Meta's throughput limits.
Summary
Functions
Adds up to 1000 recipients to a draft broadcast. Duplicates are skipped.
Cancels a scheduled broadcast and returns it to draft.
Removes every recipient from a draft or scheduled broadcast.
Creates a draft broadcast. Attributes: name, phone_number_id and
whatsapp_template_id (all required).
Gets a broadcast with its delivery counters. Poll it to follow progress.
Lists broadcasts, most recent first.
Lists recipients with their delivery status. Params: page, per_page.
Schedules a draft broadcast with recipients. scheduled_at is a
DateTime or an ISO 8601 string.
Starts sending now. Sending is asynchronous; poll get/2 for progress.
Changes the status of a broadcast: "stopped" or back to "draft".
Types
@type result() :: {:ok, map()} | {:error, KapsoEx.Error.t()}
Functions
@spec add_recipients(KapsoEx.Client.t(), String.t(), [map()]) :: result()
Adds up to 1000 recipients to a draft broadcast. Duplicates are skipped.
Each recipient is a map with phone_number (E.164) or
whatsapp_contact_id and, when the template has parameters,
components (see KapsoEx.WhatsApp.TemplateComponents).
@spec cancel(KapsoEx.Client.t(), String.t()) :: result()
Cancels a scheduled broadcast and returns it to draft.
@spec clear_recipients(KapsoEx.Client.t(), String.t()) :: result()
Removes every recipient from a draft or scheduled broadcast.
@spec create(KapsoEx.Client.t(), map() | keyword()) :: result()
Creates a draft broadcast. Attributes: name, phone_number_id and
whatsapp_template_id (all required).
@spec get(KapsoEx.Client.t(), String.t()) :: result()
Gets a broadcast with its delivery counters. Poll it to follow progress.
@spec list(KapsoEx.Client.t(), map() | keyword()) :: result()
Lists broadcasts, most recent first.
Params: phone_number_id, status, created_after, created_before,
page, per_page.
@spec list_recipients(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
Lists recipients with their delivery status. Params: page, per_page.
@spec schedule(KapsoEx.Client.t(), String.t(), DateTime.t() | String.t()) :: result()
Schedules a draft broadcast with recipients. scheduled_at is a
DateTime or an ISO 8601 string.
@spec send(KapsoEx.Client.t(), String.t()) :: result()
Starts sending now. Sending is asynchronous; poll get/2 for progress.
@spec update_status(KapsoEx.Client.t(), String.t(), String.t()) :: result()
Changes the status of a broadcast: "stopped" or back to "draft".