Use Postman to make GET requests
Before you proceed, make sure you have worked through the preceding lessons. If you have set up your development environment and forked Klaviyo's Postman collection, you are ready to try the hands-on activities below.
For these exercises, imagine you are working for Beantown Coffee to set up a custom "Booked seminar" event that fires when customers book educational coffee seminars. Beantown also wants to maintain a list of all customers that have ever signed up for a seminar.
Before you begin, make sure to:
- Navigate to your Klaviyo account.
- Create a list titled Seminar attendees.
- Add your test profile to this list.
Find the list ID
The list you just created prior to starting this exercise will contain all customers who signed up for a coffee seminar.
Your goal is to set up a way to quickly check how many customers have signed up for a seminar.
To do so, first use the Get Lists endpoint to return all lists in your account.
Use these results to determine the list ID of the Seminar attendees list. This is the 6-digit id that is associated with the list name:
Get the number of seminar attendees
Use the Get List endpoint and the list ID you just found to get the number of people who have signed up for a seminar. In the Params tab, check the box next to the additional-fields[list] query parameter to make sure the request returns the number of profiles in each list.
Please note that unless you have manually added profiles to the list, this should show that there are 0 profiles in the list.
Make a POST request
Beantown's ultimate goal is to send a custom "Booked seminar" event into their Klaviyo account after customers book.
To do so, they will make a POST request to the Create Event endpoint.
For this exercise, select the Create Event endpoint in Postman and then click Send. Do you think this API call went through? Why or why not?
Stuck? Check out these resources
If you get stuck, follow along with the steps in our tutorial on Getting Started with Klaviyo APIs.
If you receive a response from Postman that is not in the 200s, check out Postman’s guide to HTTP Status Codes for guidelines on how to resolve errors within your API call. One common error is a 401 Unauthorized error, which indicates that the authentication is incorrect. To resolve this, look at the Headers tab in Postman and double check that the authorization matches the required format.
If you are still stuck, have any questions, or want to share your work, please post in our Developer Group on Klaviyo Community.
Solutions
Get Lists
You should not have to make any changes to the default Get Lists API call from the Klaviyo collection.
- Click the Get Lists endpoint on the left.
- Click Send.
- In the response, copy the ID that is located above Seminar attendees.
This will look like:
Get the number of people who signed up for a seminar
- Click on the Get List endpoint in Postman.
- In the Params tab, add the Seminar attendees list ID that you just copied in the id field of the Path Variables section.
- Check the box next to additional-fields[list] and set the Value as profile_count.
- Click Send.
The number of profiles will show up after profile_count in the response body.
Make a POST request
- Click on Create Event on the left.
- Click Send:
After making this call, you should see the following error:
We will go over what this error means and how to properly create a custom event in the coming lessons.