Twilio.Client (twilio_elixir v0.1.1)

Copy Markdown View Source

Twilio API client. Holds credentials and executes requests.

Usage

# From application config (simplest)
client = Twilio.client()

# Explicit credentials
client = Twilio.client("ACxxx", "auth_token")

# With options
client = Twilio.client("ACxxx", "auth_token",
  region: "ie1",
  edge: "dublin",
  max_retries: 3
)

Summary

Functions

Create a new client from application config.

Create a new client with explicit credentials.

Create a new client with explicit credentials and options.

Types

t()

@type t() :: %Twilio.Client{
  account_sid: String.t(),
  auth_token: String.t(),
  edge: String.t() | nil,
  finch: atom(),
  max_retries: non_neg_integer(),
  open_timeout: pos_integer(),
  password: String.t(),
  read_timeout: pos_integer(),
  region: String.t() | nil,
  user_agent_extensions: [String.t()],
  username: String.t()
}

Functions

new()

@spec new() :: t()

Create a new client from application config.

new(account_sid, auth_token)

@spec new(String.t(), String.t()) :: t()

Create a new client with explicit credentials.

new(account_sid, auth_token, opts)

@spec new(String.t(), String.t(), keyword()) :: t()

Create a new client with explicit credentials and options.

Options

  • :region - Twilio region (e.g., "us1", "ie1")
  • :edge - Twilio edge location (e.g., "ashburn", "dublin")
  • :max_retries - Maximum retry attempts (default: 0)
  • :open_timeout - Connection timeout in ms (default: 30_000)
  • :read_timeout - Read timeout in ms (default: 30_000)
  • :finch - Custom Finch instance name (default: Twilio.Finch)
  • :account_sid - Override account SID for subaccounts

request(client, method, path, opts \\ [])

@spec request(t(), atom(), String.t(), keyword()) ::
  {:ok, map()} | {:ok, map(), map()} | :ok | {:error, Twilio.Error.t()}

Execute an API request.

Options

  • :params - Request parameters (map)
  • :base_url - Base URL for the request
  • :page_key - Key for pagination results
  • :content_type - Request content type (:form or :json, default :form)
  • :max_retries - Override client max_retries for this request
  • :return_response - Return {:ok, data, response} with metadata
  • :idempotency_token - Custom idempotency token for POST requests