How To Get Started With Klaviyo – A Developer’s Guide

Klaviyo is a software service that provides marketing capability to clients. It is designed for email automation, promotion, marketing campaigns and more. Its default form of communication is email while SMS is available also in selected locations. It also has integration with ecommerce platforms such as Shopify, WooCommerce, Wix and others.

This guide is intended mainly for developers. Klaviyo provides an API capability to integrate with existing or new softwares through the use of REST endpoints. The full documentation can be found here. Their models or data objects are Profiles, Metrics and Events, Catalogs and Web feeds.

In the following example, we will take you through the creation of an Account, creating a private access key and testing it through cURL.

Create a new Account

01: Create a Klaviyo account. Open Klaviyo in a browser: https://www.klaviyo.com, and click the “Sign up” button on the upper-right corner of the page. 

Klaviyo Homepage Signup

02: Enter the required information and click on the “Create Account” button.

  • Email address
  • Password
  • Company name
  • Company website
  • Phone number
  • Use case for Klaviyo

03: Answer a series of questions, mainly how you intend to use Klaviyo and the nature of your business/clients. Select the appropriate answers and continue.

Nature of Business

04: Main focus of business

05: Business platform. You can opt to not select any by using the “I don’t use a platform” option at the bottom.

06: Number of contacts. These are the number of clients or contacts you have. 

07: Set the business address

08: Sender information

09: How to contact subscribers

10: A confirmation message will be sent to your email. Confirm the account by opening your mailbox.

11: Confirm the email

12: Upon opening the link, you will be redirected to the login page with a notification that the email address and account has been confirmed.

13: Login to your account. On your first login to a device, a confirmation code will be required.

14: You will now see the home page or the dashboard of your Klaviyo account. 


Klaviyo Private Access Key

01: Once logged in to the Klaviyo Dashboard. Select the Account name on the lower right. This will open a sub-menu, then select the “Settings” menu.

02: Select the “API keys” under the “Account” tab.

03: Then select the “Create Private API Key” button.

04: Set the name for the key and the appropriate access control. In this example, only the “Profiles” scope will be enabled. 

It is good practice to select the minimum account of credentials needed.

05: The Private API key has now been created. This will be used by the CRM API to call the Klaviyo API.


Testing the API Access Key

In this example we will be adding a Profile.

Path: https://a.klaviyo.com/api/profiles/

HTTP method: POST

Example request:

curl --request POST \
     --url https://a.klaviyo.com/api/profiles/ \
     --header 'Authorization: Klaviyo-API-Key {private-api-key-here}' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'revision: 2023-12-15' \
     --data '
{
  "data": {
    "type": "profile",
    "attributes": {
      "email": "john.reese@cyberpogo.com",
      "phone_number": "+12345678999",
      "first_name": "John",
      "last_name": "Reese",
      "properties": {
        "date_of_birth": "2011-09-22"
      }
    }
  }
}

An example result if the record is added. Note that some output have been omitted or masked.

{
  "data": {
    "type": "profile",
    "id": "...",
    "attributes": {
      "email": "john.reese@cyberpogo.com",
      "phone_number": "+12345678999",
      "external_id": null,
      "anonymous_id": null,
      "first_name": "John",
      "last_name": "Reese",
      "organization": null,
      "title": null,
      "image": null,
      "created": "2024-01-22T21:43:58.511450+00:00",
      "updated": "2024-01-22T21:43:58.511494+00:00",
      "last_event_date": null,
      "location": {
        "address1": null,
        "address2": null,
        "city": null,
        "country": null,
        "latitude": null,
        "longitude": null,
        "region": null,
        "zip": null,
        "timezone": null,
        "ip": null
      },
      "properties": {
        "date_of_birth": "2011-09-22"
      }
    },
    "relationships": {
      "lists": {
        "links": {
          "self": "https://a.klaviyo.com/api/profiles/…/relationships/lists/",
          "related": "https://a.klaviyo.com/api/profiles/…/lists/"
        }
      },
      "segments": {
        "links": {
          "self": "https://a.klaviyo.com/api/profiles/…/relationships/segments/",
          "related": "https://a.klaviyo.com/api/profiles/…/segments/"
        }
      }
    },
    "links": {
      "self": "https://a.klaviyo.com/api/profiles/…/"
    }
  }
}

Another example if the profile already exists

{
  "errors": [
    {
      "id": "ABC…",
      "status": 409,
      "code": "duplicate_profile",
      "title": "Conflict.",
      "detail": "A profile already exists with one of these identifiers.",
      "source": {
        "pointer": "/data/attributes"
      },
      "meta": {
        "duplicate_profile_id": "XYZ…"
      }
    }
  ]
}


For enquiries, product placements, sponsorships, and collaborations, connect with us at hello@globalcloudplatforms.com. We'd love to hear from you!


Our humans need coffee too! Your support is highly appreciated, thank you!

Total
0
Shares
Previous Article
Netherlands

How We Can Identify Climate-Vulnerable Neighbourhoods And Protect Inhabitants

Next Article
Ruby

How To Get Started With A Ruby On Rails Project - A Developer's Guide

Related Posts