KapsoEx.Client (kapso_ex v0.1.0)

Copy Markdown View Source

Holds the credentials and HTTP settings used for every request.

Build one with KapsoEx.new/1 and pass it as the first argument to any resource function. A client is a plain struct, so it is cheap to create one per Kapso project (for example, one per customer when you are a Tech Provider).

Fields

  • :api_key - Kapso project API key, sent as X-API-Key. Required for the Platform, Workflows and Kapso Agent APIs.

  • :access_token - optional bearer token for the WhatsApp API. When set, WhatsApp requests send Authorization: Bearer <token> instead of X-API-Key. Combined with :whatsapp_base_url, this lets you call Meta's Graph API directly.

  • :whatsapp_base_url - defaults to "https://api.kapso.ai/meta/whatsapp/v24.0".

  • :platform_base_url - defaults to "https://api.kapso.ai/platform/v1". Also used by the Workflows, Functions and Kapso Agent modules.

  • :req_options - extra options merged into every Req request, such as :receive_timeout, :retry or :plug (for Req.Test stubs).

Summary

Functions

Builds a client from opts, falling back to the :kapso_ex application environment for any option that is not given.

Types

t()

@type t() :: %KapsoEx.Client{
  access_token: String.t() | nil,
  api_key: String.t() | nil,
  platform_base_url: String.t(),
  req_options: keyword(),
  whatsapp_base_url: String.t()
}

Functions

new(opts \\ [])

@spec new(keyword()) :: t()

Builds a client from opts, falling back to the :kapso_ex application environment for any option that is not given.

Raises ArgumentError when neither :api_key nor :access_token is set.