Skip to content

This page is available as Markdown at https://developers.klaviyo.com/en/v2026-07-15/reference/create_custom_metric.md. Its OpenAPI document is at https://raw.githubusercontent.com/klaviyo/openapi/2026-07-15/openapi/stable/apis/create_custom_metric.json. An index of every page is at https://developers.klaviyo.com/llms.txt.

KlaviyoKlaviyoDevelopers
v2026-07-15

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.

Create Custom Metric

POSThttps://a.klaviyo.com/api/custom-metrics

Create a new custom metric.

Custom metric objects must include a name and definition.

Revision header
revision: 2026-07-15required
Scopes
metrics:write
Rate limits
Burst: 1/sSteady: 15/mDaily: 15/d

Query parameters

  • fields[custom-metric]#string[]

    For more information please visit API overview

    Allowed values:
    • created
    • definition
    • definition.aggregation_method
    • definition.metric_groups
    • id
    • name
    • updated

Headers

  • revision#stringrequired

    API endpoint revision (format: YYYY-MM-DD[.suffix])

    2026-07-15

Request body

Content type: application/vnd.api+jsonrequired

  • data#objectrequired
    Show 2 fields
    • type#stringrequired
      Allowed values:
      • custom-metric
    • attributes#objectrequired
      Show 2 fields
      • name#stringrequired

        The name for this custom metric. Names must be unique across the account. Attempting to create a metric with a duplicate name will return a 400 status code.

        Example: My custom metric

      • definition#objectrequired
        Show 2 fields
        • aggregation_method#stringrequired

          Method of aggregation for custom metric measurements. If a metric has a value aggregation method, it will be treated as a revenue metric, such as a Placed Order metric. If a metric has a count aggregation method, it will only be able to report on conversions like an Active on Site metric.

          Allowed values:
          • count
          • value
        • metric_groups#object[]required
          Show 3 fields
          • metric_id#stringrequired

            The ID of the metric that composes the custom metric.

          • metric_filters#object[]nullable

            An optional array of objects for filtering on properties of the metric.

            Show 2 fields
            • property#stringrequired
            • filter#oneOfrequired

              One of:

              1. Option 1: NumericOperatorNumericFilter
                • type#stringrequired
                  Allowed values:
                  • numeric
                • operator#stringrequired

                  Operators for numeric filters.

                  Allowed values:
                  • equals
                  • greater-than
                  • greater-than-or-equal
                  • less-than
                  • less-than-or-equal
                  • not-equals
                • value#integer | numberrequired
              2. Option 2: StringInArrayFilter
                • operator#stringrequired
                  Allowed values:
                  • in
                • value#string[]required
                • type#stringrequired
                  Allowed values:
                  • string
              3. Option 3: ExistenceOperatorExistenceFilter
                • type#stringrequired
                  Allowed values:
                  • existence
                • operator#stringrequired

                  Operators for existence filters.

                  Allowed values:
                  • is-set
                  • not-set
              4. Option 4: BooleanFilter
                • type#stringrequired
                  Allowed values:
                  • boolean
                • operator#stringrequired

                  Operators for boolean filters.

                  Allowed values:
                  • equals
                • value#booleanrequired
              5. Option 5: StringOperatorStringFilter
                • type#stringrequired
                  Allowed values:
                  • string
                • operator#stringrequired

                  Operators for string filters.

                  Show 10 allowed values
                  • contains
                  • ends-with
                  • equals
                  • not-contains
                  • not-ends-with
                  • not-equals
                  • not-starts-with
                  • nregex
                  • regex
                  • starts-with
                • value#stringrequirednullable
              6. Option 6: ListContainsOperatorListContainsFilter
                • type#stringrequired
                  Allowed values:
                  • list
                • operator#stringrequired

                  Operators for list contains filters.

                  Allowed values:
                  • contains
                  • not-contains
                • value#integer | stringrequirednullable
              7. Option 7: ListRegexOperatorListContainsFilter
                • type#stringrequired
                  Allowed values:
                  • list
                • operator#stringrequired

                  Operators for list regex filters.

                  Allowed values:
                  • contains-ends-with
                  • contains-starts-with
                  • not-contains-ends-with
                  • not-contains-starts-with
                • value#integer | stringrequirednullable
              8. Option 8: ListSubstringFilter
                • type#stringrequired
                  Allowed values:
                  • list
                • operator#stringrequired

                  Operators for list substring filters.

                  Allowed values:
                  • contains-substring
                  • not-contains-substring
                • value#stringrequirednullable
          • value_property#stringnullable

            If the custom metric has a value aggregation method, the value_property of each metric_group of the definition should specify the property to calculate the conversion value. If null, the default $value property will be used.

Responses

201Success

Content type: application/vnd.api+json

  • data#objectrequired
    Show 5 fields
    • type#stringrequired
      Allowed values:
      • custom-metric
    • id#stringrequired

      The ID of the custom metric

      Example: 925e385b52fb405715f3616c337cc65c

    • attributes#objectrequired
      Show 4 fields
      • name#stringrequired

        The name for this custom metric. Names must be unique across the account. Attempting to create a metric with a duplicate name will return a 400 status code.

        Example: My custom metric

      • created#string<date-time>required

        The datetime when this custom metric was created.

        Example: 2025-04-15T00:00:00Z

      • updated#string<date-time>required

        The datetime when this custom metric was updated.

        Example: 2025-04-15T00:00:00Z

      • definition#objectrequired
        Show 2 fields
        • aggregation_method#stringrequired

          Method of aggregation for custom metric measurements. If a metric has a value aggregation method, it will be treated as a revenue metric, such as a Placed Order metric. If a metric has a count aggregation method, it will only be able to report on conversions like an Active on Site metric.

          Allowed values:
          • count
          • value
        • metric_groups#object[]required
          Show 3 fields
          • metric_id#stringrequired

            The ID of the metric that composes the custom metric.

          • metric_filters#object[]nullable

            An optional array of objects for filtering on properties of the metric.

            Show 2 fields
            • property#stringrequired
            • filter#oneOfrequired

              One of:

              1. Option 1: NumericOperatorNumericFilter
                • type#stringrequired
                  Allowed values:
                  • numeric
                • operator#stringrequired

                  Operators for numeric filters.

                  Allowed values:
                  • equals
                  • greater-than
                  • greater-than-or-equal
                  • less-than
                  • less-than-or-equal
                  • not-equals
                • value#integer | numberrequired
              2. Option 2: StringInArrayFilter
                • operator#stringrequired
                  Allowed values:
                  • in
                • value#string[]required
                • type#stringrequired
                  Allowed values:
                  • string
              3. Option 3: ExistenceOperatorExistenceFilter
                • type#stringrequired
                  Allowed values:
                  • existence
                • operator#stringrequired

                  Operators for existence filters.

                  Allowed values:
                  • is-set
                  • not-set
              4. Option 4: BooleanFilter
                • type#stringrequired
                  Allowed values:
                  • boolean
                • operator#stringrequired

                  Operators for boolean filters.

                  Allowed values:
                  • equals
                • value#booleanrequired
              5. Option 5: StringOperatorStringFilter
                • type#stringrequired
                  Allowed values:
                  • string
                • operator#stringrequired

                  Operators for string filters.

                  Show 10 allowed values
                  • contains
                  • ends-with
                  • equals
                  • not-contains
                  • not-ends-with
                  • not-equals
                  • not-starts-with
                  • nregex
                  • regex
                  • starts-with
                • value#stringrequirednullable
              6. Option 6: ListContainsOperatorListContainsFilter
                • type#stringrequired
                  Allowed values:
                  • list
                • operator#stringrequired

                  Operators for list contains filters.

                  Allowed values:
                  • contains
                  • not-contains
                • value#integer | stringrequirednullable
              7. Option 7: ListRegexOperatorListContainsFilter
                • type#stringrequired
                  Allowed values:
                  • list
                • operator#stringrequired

                  Operators for list regex filters.

                  Allowed values:
                  • contains-ends-with
                  • contains-starts-with
                  • not-contains-ends-with
                  • not-contains-starts-with
                • value#integer | stringrequirednullable
              8. Option 8: ListSubstringFilter
                • type#stringrequired
                  Allowed values:
                  • list
                • operator#stringrequired

                  Operators for list substring filters.

                  Allowed values:
                  • contains-substring
                  • not-contains-substring
                • value#stringrequirednullable
          • value_property#stringnullable

            If the custom metric has a value aggregation method, the value_property of each metric_group of the definition should specify the property to calculate the conversion value. If null, the default $value property will be used.

    • relationships#object
      Show 1 field
      • metrics#object
        Show 2 fields
        • data#object[]
          Show 2 fields
          • type#stringrequired
            Allowed values:
            • metric
          • id#stringrequired

            Related metrics

  • meta#object

    Response-level metadata

    Show 1 field
    • agent_hints#object

      Optional hints emitted by the API for agent callers

      Show 1 field
      • next_steps#string[]

        Suggested follow-up actions for agents to take after this response

4XXClient Error

Content type: application/vnd.api+json

  • errors#object[]required
    Show 5 fields
    • id#stringrequired
    • code#stringrequired
    • title#stringrequired
    • detail#stringrequired
    • source#object
      Show 2 fields
      • pointer#string
      • parameter#string

5XXServer Error

Content type: application/vnd.api+json

  • errors#object[]required
    Show 5 fields
    • id#stringrequired
    • code#stringrequired
    • title#stringrequired
    • detail#stringrequired
    • source#object
      Show 2 fields
      • pointer#string
      • parameter#string