Klaviyo

An Elixir library for working with the Klaviyo REST API.

Installation

def deps do
[
{:klaviyo, "~> 2.0"},
{:hackney, "~> 1.15"},
{:jason, "~> 1.1"}
]
end

Note that usage of hackney and jason are optional. You may implement support for your own HTTP library and JSON codec.

Usage

You make a request to the Klaviyo API by passing the request description created by resource endpoint functions (e.g. Klaviyo.Campaign.send/1 or Klaviyo.track/1) to the Klaviyo.request/2 function.

All requests that get a response from the Klaviyo API will be returned as either {:ok, %Klaviyo.Response{}} or {:error, %Klaviyo.Response{}}. In the event of a client error {:error, _reason} will be returned.

iex> Klaviyo.Campaign.send("dqQnNW") |> Klaviyo.request(%{ private_api_key: "..." })
{:ok, %Klaviyo.Response{body: _, headers: _, status_code: 200}}

Configuration

Configuration is passed as a map to the second argument of Klaviyo.request/2.

Supported Endpoint Functions

Server-Side

Campaign

List

Metric

Person

Template