HTTP client for the WorkOS API.
Usage
client = WorkOS.Client.new(api_key: "sk_...")The API key falls back to the WORKOS_API_KEY environment variable.
Options for new/1
:api_key— API key (required unless the env var is set):client_id— client ID used by authentication flows and URL builders (falls back to theWORKOS_CLIENT_IDenvironment variable):base_url— override the API base URL:timeout— receive timeout in milliseconds:max_retries— maximum retry attempts for retryable failures:req_options— extraReqoptions merged into every request (advanced; used by tests to injectplug: {Req.Test, ...})
Summary
Functions
Builds a fully-qualified URL for browser-redirect flows. No HTTP request
is made. params become the query string; nil values are dropped.
Builds a new client. See the module documentation for options.
Performs an HTTP request against the API.
Types
@type t() :: %WorkOS.Client{ api_key: String.t(), base_url: String.t(), client_id: String.t() | nil, max_retries: non_neg_integer(), req_options: keyword(), timeout: pos_integer() }
Functions
Builds a fully-qualified URL for browser-redirect flows. No HTTP request
is made. params become the query string; nil values are dropped.
Builds a new client. See the module documentation for options.
@spec request(t(), atom(), String.t(), map(), keyword()) :: {:ok, term()} | {:error, WorkOS.Error.error()}
Performs an HTTP request against the API.
params is sent as query parameters for GET/DELETE/HEAD requests and as a
JSON body otherwise. Per-request options:
:headers— extra headers, as a list of{name, value}tuples:idempotency_key— explicit idempotency key header value:timeout— per-request receive timeout in milliseconds:max_retries— per-request retry ceiling, overriding the client's:base_url— per-request base URL, overriding the client's:query— extra query parameters for requests whoseparamsis a body