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.
Execute an API request.
Types
@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
@spec new() :: t()
Create a new client from application config.
Create a new client with explicit credentials.
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
@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 (:formor: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