You're reading the reference for API revision 2026-07-15. The latest revision is 2026-10-15. See this page in the latest revision.
Before you begin
Check out our general API overview before getting started with specific endpoints.
Our Metrics API enables a zoomed out view of your metric data so that you can dive deeper into your business’s performance with Klaviyo. A metric is a category of event, or action a person can take. For example, when a customer places an order, a Placed Order event is created for the profile, that event being an instance of the Placed Order metric. All Placed Order events collected or sent via the same mechanism (a given integration or our APIs) will share the same Placed Order metric represented by its metric_id.
The Metrics API allows you to fetch metric information, including a given metric’s metric_id, which can then be used to query aggregate metric data. These metrics include:
- Native Klaviyo metrics.
- Other integration-specific (e.g., Shopify) metrics.
- API metrics.
Use cases
Here are some example use cases supported by the Metrics API:
- Retrieve a metric’s ID (
metric_id)and use it to query and aggregate event data associated with the metric. - Filter metrics by integration name and/or category, e.g., Shopify-created metrics.
- Query aggregate event data associated with a metric by passing a JSON request body with metric attributes and filters (e.g., aggregate Placed Order events that span over a holiday weekend).
Data model
A retrieved metric will have the following:
idThe metric id.
nameThe metric name, e.g, Opened Email.
createdThe timestamp of when the metric was created.
updatedThe timestamp of when the metric was last updated.
integrationThe integration object used to capture the metric, e.g., Klaviyo.
idThe integration ID.
nameThe name of the integration, e.g.,
Klaviyo.categoryThe category of the integration, e.g.,
Internalfor Klaviyo.
Get Metrics
The Get Metrics endpoint is useful for retrieving information about multiple metrics on your account, including their names, IDs, and the integrations used to capture them. Similarly, the Get Metric endpoint is useful for fetching the same information about a single metric at a time.
You can use sparse fieldsets to only show the desired fields in your response. See the example request to Get Metrics below:
curl --request GET \
--url 'https://a.klaviyo.com/api/metrics/?filter=equals(integration.name,"Klaviyo")&fields%5Bmetric%5D=name,integration' \
--header 'Authorization: Klaviyo-API-Key your-private-api-key' \
--header 'accept: application/json' \
--header 'revision: 2023-10-15'{
"data": [
{
"type": "metric",
"id": "REcTBe",
"attributes": {
"name": "Sent SMS",
"integration": {
"id": "0rG4eQ",
"name": "Klaviyo"
}
},
"links": {
"self": "https://a.klaviyo.com/api/metrics/REcTBe/"
}
},
{
"type": "metric",
"id": "RcsmFp",
"attributes": {
"name": "Marked Email as Spam",
"integration": {
"id": "0rG4eQ",
"name": "Klaviyo"
}
},
"links": {
"self": "https://a.klaviyo.com/api/metrics/RcsmFp/"
}
},
...
}Note that an equals filter, ?filter=equals(integration.name,"Klaviyo"), has been applied to only include native Klaviyo metrics in the response. Sparse fieldsets are also used to only display the metric’s name, integration.id, and integration.name.
Query metrics
The Metrics API allows for filtering and including certain metric data, such as filtering by native Klaviyo metrics like Opened Email or Clicked Email. Check out the supported query parameters below and test them out with our latest Postman collection. Note that support for given operators and fields is endpoint-specific. Review the API reference documentation for more information on allowed fields and query operators.
| Integration | integration.name |
integration.category |
|---|---|---|
| Klaviyo | "Klaviyo" |
"Internal" |
| API | "API" |
"API" |
| Other core integrations (Shopify, PrestaShop, BigCommerce, etc.) |
"Shopify""PrestaShop""BigCommerce" |
"eCommerce" |
Query Metric Aggregates
The Query Metrics Aggregates endpoint is useful for pulling aggregated metric data out of Klaviyo and creating your own custom reports. For example, if you wanted to directly retrieve a count of how many orders had been placed on a monthly basis for the past year, you can make a query for a Placed Order metric:
curl --request POST \
--url https://a.klaviyo.com/api/metric-aggregates/ \
--header 'Authorization: Klaviyo-API-Key your-private-api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'revision: 2023-10-15' \
--data '
{
"data": {
"type": "metric-aggregate",
"attributes": {
"measurements": ["count"],
"filter": [
"greater-or-equal(datetime,2023-01-01T00:00:00Z)",
"less-than(datetime,2024-01-01T00:00:00Z)"
],
"metric_id": "XWKwsS",
"interval": "month",
"page_size": 500,
"timezone": "UTC"
}
}
}
'Our Query Metrics Aggregates endpoint offers robust support for filtering results and grouping by time, event, or profile. Some use cases include:
- Extracting email engagement or ecommerce event data from Klaviyo to send to a data warehouse (e.g., syncing event data to Snowflake).
- Analyzing a count of SMS events by timezone.
- Reviewing Clicked Email events to compare engagement between different email versions sent out for A/B testing.
For a comprehensive list of native Klaviyo metrics and their associated attributes for grouping and filtering, refer to the list of supported attributes.
Next steps
Try out the following:
- Retrieve a
metric_idfrom a call to Get Metrics with your Klaviyo test account via Postman. - Use the Create Event endpoint to create events for this metric over a period of time.
- Use the retrieved
metric_idto make a call to the Query Metric Aggregates endpoint. Try out the endpoint with native Klaviyo metrics and/or other integrations.
Additional resources
Endpoints
Metrics
- GETGet Metrics
/api/metrics - GETGet Metric
/api/metrics/{id} - GETGet Metric Property
/api/metric-properties/{id} - POSTQuery Metric Aggregates
/api/metric-aggregates - GETGet Flows Triggered by Metric
/api/metrics/{id}/flow-triggers - GETGet IDs for Flows Triggered by Metric
/api/metrics/{id}/relationships/flow-triggers - GETGet Properties for Metric
/api/metrics/{id}/metric-properties - GETGet Property IDs for Metric
/api/metrics/{id}/relationships/metric-properties - GETGet Metric for Metric Property
/api/metric-properties/{id}/metric - GETGet Metric ID for Metric Property
/api/metric-properties/{id}/relationships/metric
Custom Metrics
Before you begin
Check out our general API overview before getting started with specific endpoints.
Before you can create custom metrics:
- Ensure you have metrics (e.g., Placed Order) in your account and real event data for those metrics.
- Use Get Metrics to fetch the set of available metrics in an account and Get Properties for Metric to confirm a metric’s available properties that can be used in custom metric filters.
You’ll then be able to use the Custom Metrics API to create custom metrics based on the existing metrics in an account.
Using custom metrics
By default, Klaviyo provides metrics that track your business’s performance and measure success (e.g., a Placed Order event from a Klaviyo e-commerce integration). However, there may be instances where you need to create custom metrics to more accurately capture how your business runs. For examples of useful custom metrics, check out our strategic guide on using custom metrics.
Our Custom Metrics API allows you to manage custom metrics programmatically, i.e., custom conversion metrics that are based off of metrics in your account (native Klaviyo, integration-specific, and API metrics).
Use cases
Here are some example use cases supported by the Custom Metrics API:
- Create a custom metric to better model the important conversion metrics that are specific to an account's business, e.g., a custom metric based on Placed Order that filters out recurring subscriptions or an “Ordered Product - Retail” metric for products ordered online (vs. in-person).
- Update the definition for a custom metric.
- Use a custom metric "Revenue" as the conversion metric in our campaign & flow Reporting APIs to understand attributed revenue for flows & campaigns (see Use the Reporting API on custom metrics).
- Delete a custom metric.
- Fetch metrics related to a custom metric, i.e., metrics that define a given custom metric.
Data model
A custom metric has the following structure:
idThe ID of the custom metric.
attributesnameThe name of the custom metric.
definitionThe definition of a custom metric. It is composed of a list of
metric_groups, which are combined with a logical AND.aggregation_methodMethod of aggregation for custom metric measurements (
valueorcount). A metric with avalueaggregation method is treated as a revenue metric, e.g., Placed Order; the metric must have a"$value"property to use this kind of aggregation. A metric with acountaggregation method is used for reporting on the count of the metric.metric_groupsAn array of objects that defines which events the custom metric should include. For each metric group, you must provide an identifier for an existing metric, e.g., Placed Order. Then, you may filter the metric’s properties to further define which events should be included.
metric_idThe ID of the metric that composes the custom metric.
metric_filtersAn optional array of objects for filtering on properties of the metric.
propertyThe property for the given metric that you’d like to filter on, e.g.,
ItemNames.filterThe filter that is to be applied to the property, e.g., a filter that checks if a specific item is present in a list. See the API reference documentation for a complete list of filters.
value_propertyThe property that calculates the conversion value (only used for custom metrics with an
aggregation_methodofvalue). If null, the default$valueproperty will be used.
Get Custom Metrics
The Get Custom Metrics endpoint is useful for retrieving information about custom metrics in an account. You can include related metrics in your response and use sparse fieldsets to request only specific fields in your response, e.g., only show aggregation method fields for custom metrics in your account. Similarly, Get Custom Metric is useful for fetching data for a given custom metric.
Use sparse fieldsets to only show the desired fields in your response. See the example request to Get Custom Metrics below:
curl --request GET \
--url 'https://a.klaviyo.com/api/custom-metrics/?fields%5Bcustom-metric%5D=name,definition.aggregation_method' \
--header 'Authorization: Klaviyo-API-Key your-private-api-key' \
--header 'accept: application/json' \
--header 'revision: 2025-04-15'{
"data": [
{
"type": "custom-metric",
"id": "01J2EZE52CT203GP5BGJPP9H5A",
"attributes": {
"name": "Placed Order - Online",
"definition": {
"metric_groups": [
{
"metric_id": "SDXgcj",
"metric_filters": [
{
"property": "Source Name",
"filter": {
"type": "list",
"operator": "not-contains",
"value": "pos"
}
}
],
"value_property": "$value"
}
],
"aggregation_method": "value"
}
},
"relationships": {
"metrics": {
"data": [
{
"type": "metric",
"id": "SDXgcj"
}
],
"links": {
"self": "https://a.klaviyo.com/api/custom-metrics/01J2EZE52CT203GP5BGJPP9H5A/relationships/metrics/",
"related": "https://a.klaviyo.com/api/custom-metrics/01J2EZE52CT203GP5BGJPP9H5A/metrics/"
}
}
},
"links": {
"self": "https://a.klaviyo.com/api/custom-metrics/01J2EZE52CT203GP5BGJPP9H5A/"
}
},
{
"type": "custom-metric",
"id": "01J2EZE4YJQCCZ4NTTA6RSPY24",
"attributes": {
"name": "Ordered Product - Count",
"definition": {
"metric_groups": [
{
"metric_id": "RaFtaN",
"metric_filters": [],
"value_property": null
}
],
"aggregation_method": "count"
}
},
"relationships": {
"metrics": {
"data": [
{
"type": "metric",
"id": "RaFtaN"
}
],
"links": {
"self": "https://a.klaviyo.com/api/custom-metrics/01J2EZE4YJQCCZ4NTTA6RSPY24/relationships/metrics/",
"related": "https://a.klaviyo.com/api/custom-metrics/01J2EZE4YJQCCZ4NTTA6RSPY24/metrics/"
}
}
},
"links": {
"self": "https://a.klaviyo.com/api/custom-metrics/01J2EZE4YJQCCZ4NTTA6RSPY24/"
}
}
],
"links": {
"self": "https://a.klaviyo.com/api/custom-metrics?fields[custom-metric]=name,definition.metric_groups,definition.aggregation_method"
}
}Create Custom Metric
To create a custom metric, you’ll need to provide a definition object that includes the aggregation method and metric groups that define what events your custom metric includes.
The example request payload below for Create Custom Metric creates a custom metric based on Placed Order that filters out recurring subscriptions:
{
"data": {
"type": "custom-metric",
"attributes": {
"name": "Placed Order - Ecommerce",
"definition": {
"aggregation_method": "value",
"metric_groups": [{
"metric_id": "T4kAe8",
"value_property": "Revenue",
"metric_filters": [{
"property": "Source Name",
"filter": {
"type": "string",
"operator": "does not equal",
"value": "subscription"
}
}]
}]
}
}
}
}Here’s how the resulting custom metric definition appears in Klaviyo’s custom metric builder (Metrics > Create custom metric):

Use the Reporting API on custom metrics
You can use the Reporting API on custom metrics to retrieve attributed value for campaigns and flows.
- Use Get Custom Metrics to get the metric ID for the custom metric you’d like to use for calculating conversion-based statistics.
- Then, create a campaigns or flows report to request statistics for a given campaign or flow using the Reporting API.
The example below is a request payload to Query Campaign Values that fetches campaign performance data using a custom metric for calculating conversion-based statistics:
curl --request POST \
--url https://a.klaviyo.com/api/campaign-values-reports/ \
--header 'Authorization: Klaviyo-API-Key your-private-api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'revision: 2025-04-15' \
--data '
{
"data": {
"type": "campaign-values-report",
"attributes": {
"timeframe": {
"key": "last_12_months"
},
"conversion_metric_id": "01J2EZE52CT203GP5BGJPP9H5A",
"filter": "equals(campaign_id",\"01GMRWDSA0ARTAKE1SFX8JGXAY\")",
"statistics": [
"opens",
"open_rate"
]
}
}
}
'Limitations
- Accounts can only have one custom metric. To access up to 50 custom metrics, the Advanced Klaviyo Data Platform is required.
- A custom metric group can contain up to 5 metrics.
- A metric defined within the custom metric group can have up to 3 filters on its properties.
Common errors
| Status code | Reasons |
|---|---|
| 400 |
|
| 403 |
|
| 429 |
|
Additional resources
- GETGet Custom Metrics
/api/custom-metrics - GETGet Custom Metric
/api/custom-metrics/{id} - POSTCreate Custom Metric
/api/custom-metrics - PATCHUpdate Custom Metric
/api/custom-metrics/{id} - DELETEDelete Custom Metric
/api/custom-metrics/{id} - GETGet Metrics for Custom Metric
/api/custom-metrics/{id}/metrics - GETGet Metric IDs for Custom Metric
/api/custom-metrics/{id}/relationships/metrics
Mapped Metrics
- GETGet Mapped Metrics
/api/mapped-metrics - GETGet Mapped Metric
/api/mapped-metrics/{id} - PATCHUpdate Mapped Metric
/api/mapped-metrics/{id} - GETGet Metric for Mapped Metric
/api/mapped-metrics/{id}/metric - GETGet Metric ID for Mapped Metric
/api/mapped-metrics/{id}/relationships/metric - GETGet Custom Metric for Mapped Metric
/api/mapped-metrics/{id}/custom-metric - GETGet Custom Metric ID for Mapped Metric
/api/mapped-metrics/{id}/relationships/custom-metric