In this article you’ll learn how to transfer leads to Klaviyo using API node.
Step 1: Add a custom field and name it {id}
The custom field id is required for the next steps that we will be doing inside the API node. You can check this KB article for more information on How to Create and Add Custom Fields.
Step 2: Get List ID and API Key from your Klaviyo account
You can check these articles from https://help.klaviyo.com/ on how to obtain these information:
- How to Find a List ID: https://help.klaviyo.com/hc/en-us/articles/115005078647-How-to-Find-a-List-ID
- How to Find your API keys: https://help.klaviyo.com/hc/en-us/articles/115005062267-How-to-Manage-Your-Account-s-API-Keys#find-your-api-keys1
Difference Between Public and Private API Keys
Your public API key is also called your Site ID. This is a short alphanumeric value. This public key is a unique identifier for your Klaviyo account, and there is only one per account. It is safe to expose your public API key, as this key cannot be used to access data in your Klaviyo account.
Your Private API Key is the one you need for Klaviyo integration. Private API keys are used for reading data from Klaviyo and manipulating some sensitive objects such as lists. Treat private API keys like passwords kept in a safe place and never exposed to the public. A Klaviyo account can generate as many private API keys as needed.
In case you have trouble finding your List ID or API Key, please contact Klaviyo Support
Step 3: Add an API node to your Decision Tree
You will find the API node on the list of nodes when you click Add New Module. For more information about using API nodes you can refer to this KB article on How to Use the API Node.
Please refer to the image and instructions below on how to setup the API node.
- Method: POST
- Request URL: https://a.klaviyo.com/api/v2/list/LIST_ID/members?api_key=PRIVATE_API_KEY
- Body: JSON
- JSON content:
{
"profiles": [
{
"email": "{email}",
"first_name": "{first_name}",
"last_name": "{last_name}"
}
]
}
- Headers: Accept: application/json, Content–Type: application/json
Input the data you want to send to Klaviyo in the JSON code. Each object in the profiles array must have an email or phone_number. You can also provide additional properties as key-value pairs.
Step 4: Map Response Property to Custom Field {id}
Scroll down to the bottom of the API node to see Fieldmapper section.
Enter response property “id” and enter field name “id”.
This is the custom field we created on Step 1 of this article.
Step 5: Test and Save API node
You can use the Test Request button to test the API request. Save your API node and proceed to the Results node (or whichever is the next node) on your DT.
For more information about using API nodes you can refer to this KB article on How to Use the API Node.
You can also refer to Klaviyo API documentation regarding Adding Members to a List for more information.