Class: KlaviyoAPI::MetricsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo-api-sdk/api/metrics_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ MetricsApi

Returns a new instance of MetricsApi.



19
20
21
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_custom_metric(custom_metric_create_query, opts = {}) ⇒ Hash<String, Object>

Create Custom Metric Create a new custom metric. Custom metric objects must include a ‘name` and `definition`.
*Rate limits*:
Burst: `1/s`
Steady: `15/m`
Daily: `15/d` Scopes: `metrics:write`

Parameters:

  • custom_metric_create_query (CustomMetricCreateQuery)

    Create a custom metric.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


27
28
29
30
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 27

def create_custom_metric(custom_metric_create_query, opts = {})
  data, _status_code, _headers = create_custom_metric_with_http_info(custom_metric_create_query, opts)
  data
end

#create_custom_metric_with_http_info(custom_metric_create_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Create Custom Metric Create a new custom metric. Custom metric objects must include a &#x60;name&#x60; and &#x60;definition&#x60;.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60;&lt;br&gt;Daily: &#x60;15/d&#x60; Scopes: &#x60;metrics:write&#x60;

Parameters:

  • custom_metric_create_query (CustomMetricCreateQuery)

    Create a custom metric.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 37

def create_custom_metric_with_http_info(custom_metric_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.create_custom_metric ...'
  end
  # verify the required parameter 'custom_metric_create_query' is set
  if @api_client.config.client_side_validation && custom_metric_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'custom_metric_create_query' when calling MetricsApi.create_custom_metric"
  end
  # resource path
  local_var_path = '/api/custom-metrics'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(custom_metric_create_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.create_custom_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#create_custom_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_custom_metric(id, opts = {}) ⇒ nil

Delete Custom Metric Delete a custom metric with the given custom metric ID.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `metrics:write`

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


97
98
99
100
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 97

def delete_custom_metric(id, opts = {})
  delete_custom_metric_with_http_info(id, opts)
  nil
end

#delete_custom_metric_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Custom Metric Delete a custom metric with the given custom metric ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;metrics:write&#x60;

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 107

def delete_custom_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.delete_custom_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.delete_custom_metric"
  end
  # resource path
  local_var_path = '/api/custom-metrics/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.delete_custom_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#delete_custom_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_custom_metric(id, opts = {}) ⇒ Hash<String, Object>

Get Custom Metric Get a custom metric with the given custom metric ID.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


165
166
167
168
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 165

def get_custom_metric(id, opts = {})
  data, _status_code, _headers = get_custom_metric_with_http_info(id, opts)
  data
end

#get_custom_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Custom Metric Get a custom metric with the given custom metric ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 178

def get_custom_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_custom_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_custom_metric"
  end
  allowable_values = ["name", "created", "updated", "definition", "definition.aggregation_method", "definition.metric_groups"]
  if @api_client.config.client_side_validation && opts[:'fields_custom_metric'] && !opts[:'fields_custom_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_custom_metric\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "created", "updated", "integration"]
  if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}"
  end
  allowable_values = ["metrics"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/custom-metrics/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[custom-metric]'] = @api_client.build_collection_param(opts[:'fields_custom_metric'], :csv) if !opts[:'fields_custom_metric'].nil?
  query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_custom_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_custom_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_custom_metrics(opts = {}) ⇒ Hash<String, Object>

Get Custom Metrics Get all custom metrics in an account.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `metrics:read`

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


250
251
252
253
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 250

def get_custom_metrics(opts = {})
  data, _status_code, _headers = get_custom_metrics_with_http_info(opts)
  data
end

#get_custom_metrics_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Custom Metrics Get all custom metrics in an account.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 262

def get_custom_metrics_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_custom_metrics ...'
  end
  allowable_values = ["name", "created", "updated", "definition", "definition.aggregation_method", "definition.metric_groups"]
  if @api_client.config.client_side_validation && opts[:'fields_custom_metric'] && !opts[:'fields_custom_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_custom_metric\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "created", "updated", "integration"]
  if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}"
  end
  allowable_values = ["metrics"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/custom-metrics'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[custom-metric]'] = @api_client.build_collection_param(opts[:'fields_custom_metric'], :csv) if !opts[:'fields_custom_metric'].nil?
  query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_custom_metrics",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_custom_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_flows_triggered_by_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_flow_triggers_for_metric, get_metric_flow_triggers

Get Flows Triggered by Metric Get all flows where the given metric is being used as the trigger.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `flows:read` `metrics:read`

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


329
330
331
332
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 329

def get_flows_triggered_by_metric(id, opts = {})
  data, _status_code, _headers = get_flows_triggered_by_metric_with_http_info(id, opts)
  data
end

#get_flows_triggered_by_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_flow_triggers_for_metric_with_http_info, get_metric_flow_triggers_with_http_info

Get Flows Triggered by Metric Get all flows where the given metric is being used as the trigger.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;flows:read&#x60; &#x60;metrics:read&#x60;

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 346

def get_flows_triggered_by_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_flows_triggered_by_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_flows_triggered_by_metric"
  end
  allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"]
  if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/metrics/{id}/flow-triggers'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_flows_triggered_by_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_flows_triggered_by_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ids_for_flows_triggered_by_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_flow_trigger_ids_for_metric, get_metric_relationships_flow_triggers

Get IDs for Flows Triggered by Metric Get the IDs of all flows where the given metric is being used as the trigger.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `flows:read` `metrics:read`

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


412
413
414
415
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 412

def get_ids_for_flows_triggered_by_metric(id, opts = {})
  data, _status_code, _headers = get_ids_for_flows_triggered_by_metric_with_http_info(id, opts)
  data
end

#get_ids_for_flows_triggered_by_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_flow_trigger_ids_for_metric_with_http_info, get_metric_relationships_flow_triggers_with_http_info

Get IDs for Flows Triggered by Metric Get the IDs of all flows where the given metric is being used as the trigger.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;flows:read&#x60; &#x60;metrics:read&#x60;

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 428

def get_ids_for_flows_triggered_by_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_ids_for_flows_triggered_by_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_ids_for_flows_triggered_by_metric"
  end
  # resource path
  local_var_path = '/api/metrics/{id}/relationships/flow-triggers'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_ids_for_flows_triggered_by_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_ids_for_flows_triggered_by_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_metric(id, opts = {}) ⇒ Hash<String, Object>

Get Metric Get a metric with the given metric ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    Metric ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


492
493
494
495
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 492

def get_metric(id, opts = {})
  data, _status_code, _headers = get_metric_with_http_info(id, opts)
  data
end

#get_metric_for_metric_property(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_property_metric

Get Metric for Metric Property Get the metric for the given metric property ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the metric property

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


576
577
578
579
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 576

def get_metric_for_metric_property(id, opts = {})
  data, _status_code, _headers = get_metric_for_metric_property_with_http_info(id, opts)
  data
end

#get_metric_for_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_property_metric_with_http_info

Get Metric for Metric Property Get the metric for the given metric property ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the metric property

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 590

def get_metric_for_metric_property_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_for_metric_property ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric_for_metric_property"
  end
  allowable_values = ["name", "created", "updated", "integration"]
  if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/metric-properties/{id}/metric'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_metric_for_metric_property",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metric_for_metric_property\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_metric_id_for_metric_property(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_property_relationships_metric

Get Metric ID for Metric Property Get the ID of the metric for the given metric property.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the metric property

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


653
654
655
656
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 653

def get_metric_id_for_metric_property(id, opts = {})
  data, _status_code, _headers = get_metric_id_for_metric_property_with_http_info(id, opts)
  data
end

#get_metric_id_for_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_property_relationships_metric_with_http_info

Get Metric ID for Metric Property Get the ID of the metric for the given metric property.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the metric property

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 666

def get_metric_id_for_metric_property_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_id_for_metric_property ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric_id_for_metric_property"
  end
  # resource path
  local_var_path = '/api/metric-properties/{id}/relationships/metric'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_metric_id_for_metric_property",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metric_id_for_metric_property\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_metric_ids_for_custom_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_custom_metric_relationships_metrics

Get Metric IDs for Custom Metric Get all metrics for the given custom metric ID.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


724
725
726
727
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 724

def get_metric_ids_for_custom_metric(id, opts = {})
  data, _status_code, _headers = get_metric_ids_for_custom_metric_with_http_info(id, opts)
  data
end

#get_metric_ids_for_custom_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_custom_metric_relationships_metrics_with_http_info

Get Metric IDs for Custom Metric Get all metrics for the given custom metric ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 737

def get_metric_ids_for_custom_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_ids_for_custom_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric_ids_for_custom_metric"
  end
  # resource path
  local_var_path = '/api/custom-metrics/{id}/relationships/metrics'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_metric_ids_for_custom_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metric_ids_for_custom_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_metric_property(id, opts = {}) ⇒ Hash<String, Object>

Get Metric Property Get a metric property with the given metric property ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the metric property

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


799
800
801
802
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 799

def get_metric_property(id, opts = {})
  data, _status_code, _headers = get_metric_property_with_http_info(id, opts)
  data
end

#get_metric_property_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Metric Property Get a metric property with the given metric property ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the metric property

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 813

def get_metric_property_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_property ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric_property"
  end
  allowable_values = ["sample_values"]
  if @api_client.config.client_side_validation && opts[:'additional_fields_metric_property'] && !opts[:'additional_fields_metric_property'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"additional_fields_metric_property\", must include one of #{allowable_values}"
  end
  allowable_values = ["label", "property", "inferred_type", "sample_values"]
  if @api_client.config.client_side_validation && opts[:'fields_metric_property'] && !opts[:'fields_metric_property'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric_property\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "created", "updated", "integration"]
  if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}"
  end
  allowable_values = ["metric"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/metric-properties/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'additional-fields[metric-property]'] = @api_client.build_collection_param(opts[:'additional_fields_metric_property'], :csv) if !opts[:'additional_fields_metric_property'].nil?
  query_params[:'fields[metric-property]'] = @api_client.build_collection_param(opts[:'fields_metric_property'], :csv) if !opts[:'fields_metric_property'].nil?
  query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_metric_property",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metric_property\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Metric Get a metric with the given metric ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    Metric ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 505

def get_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metric"
  end
  allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"]
  if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "created", "updated", "integration"]
  if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}"
  end
  allowable_values = ["flow-triggers"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/metrics/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil?
  query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_metrics(opts = {}) ⇒ Hash<String, Object>

Get Metrics Get all metrics in an account. Requests can be filtered by the following fields: integration ‘name`, integration `category` Returns a maximum of 200 results per page.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `metrics:read`

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


892
893
894
895
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 892

def get_metrics(opts = {})
  data, _status_code, _headers = get_metrics_with_http_info(opts)
  data
end

#get_metrics_for_custom_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_custom_metric_metrics

Get Metrics for Custom Metric Get all metrics for the given custom metric ID.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


975
976
977
978
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 975

def get_metrics_for_custom_metric(id, opts = {})
  data, _status_code, _headers = get_metrics_for_custom_metric_with_http_info(id, opts)
  data
end

#get_metrics_for_custom_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_custom_metric_metrics_with_http_info

Get Metrics for Custom Metric Get all metrics for the given custom metric ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the custom metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 989

def get_metrics_for_custom_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metrics_for_custom_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_metrics_for_custom_metric"
  end
  allowable_values = ["name", "created", "updated", "integration"]
  if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/custom-metrics/{id}/metrics'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_metrics_for_custom_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metrics_for_custom_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_metrics_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Metrics Get all metrics in an account. Requests can be filtered by the following fields: integration &#x60;name&#x60;, integration &#x60;category&#x60; Returns a maximum of 200 results per page.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 906

def get_metrics_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_metrics ...'
  end
  allowable_values = ["name", "status", "archived", "created", "updated", "trigger_type"]
  if @api_client.config.client_side_validation && opts[:'fields_flow'] && !opts[:'fields_flow'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_flow\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "created", "updated", "integration"]
  if @api_client.config.client_side_validation && opts[:'fields_metric'] && !opts[:'fields_metric'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric\", must include one of #{allowable_values}"
  end
  allowable_values = ["flow-triggers"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/metrics'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[flow]'] = @api_client.build_collection_param(opts[:'fields_flow'], :csv) if !opts[:'fields_flow'].nil?
  query_params[:'fields[metric]'] = @api_client.build_collection_param(opts[:'fields_metric'], :csv) if !opts[:'fields_metric'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_metrics",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_properties_for_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_metric_properties, get_metric_properties

Get Properties for Metric Get the metric properties for the given metric ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


1054
1055
1056
1057
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1054

def get_properties_for_metric(id, opts = {})
  data, _status_code, _headers = get_properties_for_metric_with_http_info(id, opts)
  data
end

#get_properties_for_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_metric_properties_with_http_info, get_metric_properties_with_http_info

Get Properties for Metric Get the metric properties for the given metric ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1072

def get_properties_for_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_properties_for_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_properties_for_metric"
  end
  allowable_values = ["sample_values"]
  if @api_client.config.client_side_validation && opts[:'additional_fields_metric_property'] && !opts[:'additional_fields_metric_property'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"additional_fields_metric_property\", must include one of #{allowable_values}"
  end
  allowable_values = ["label", "property", "inferred_type", "sample_values"]
  if @api_client.config.client_side_validation && opts[:'fields_metric_property'] && !opts[:'fields_metric_property'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_metric_property\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/metrics/{id}/metric-properties'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'additional-fields[metric-property]'] = @api_client.build_collection_param(opts[:'additional_fields_metric_property'], :csv) if !opts[:'additional_fields_metric_property'].nil?
  query_params[:'fields[metric-property]'] = @api_client.build_collection_param(opts[:'fields_metric_property'], :csv) if !opts[:'fields_metric_property'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_properties_for_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_properties_for_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_property_ids_for_metric(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_metric_relationships_metric_properties, get_metric_relationships_properties

Get Property IDs for Metric Get the IDs of metric properties for the given metric.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m` Scopes: `metrics:read`

Parameters:

  • id (String)

    The ID of the metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


1143
1144
1145
1146
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1143

def get_property_ids_for_metric(id, opts = {})
  data, _status_code, _headers = get_property_ids_for_metric_with_http_info(id, opts)
  data
end

#get_property_ids_for_metric_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_metric_relationships_metric_properties_with_http_info, get_metric_relationships_properties_with_http_info

Get Property IDs for Metric Get the IDs of metric properties for the given metric.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • id (String)

    The ID of the metric

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1159

def get_property_ids_for_metric_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.get_property_ids_for_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.get_property_ids_for_metric"
  end
  # resource path
  local_var_path = '/api/metrics/{id}/relationships/metric-properties'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.get_property_ids_for_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#get_property_ids_for_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#query_metric_aggregates(metric_aggregate_query, opts = {}) ⇒ Hash<String, Object> Also known as: create_metric_aggregate

Query Metric Aggregates Query and aggregate event data associated with a metric, including native Klaviyo metrics, integration-specific metrics, and custom events (not to be confused with [custom metrics](developers.klaviyo.com/en/reference/custom_metrics_api_overview), which are not supported at this time). Queries must be passed in the JSON body of your ‘POST` request. To request campaign and flow performance data that matches the data shown in Klaviyo’s UI, we recommend the [Reporting API](developers.klaviyo.com/en/reference/reporting_api_overview). Results can be filtered and grouped by time, event, or profile dimensions. To learn more about how to use this endpoint, check out our new [Using the Query Metric Aggregates Endpoint guide](developers.klaviyo.com/en/docs/using-the-query-metric-aggregates-endpoint). For a comprehensive list of request body parameters, native Klaviyo metrics, and their associated attributes for grouping and filtering, please refer to the [metrics attributes guide](developers.klaviyo.com/en/docs/supported_metrics_and_attributes).
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `metrics:read`

Parameters:

  • metric_aggregate_query (MetricAggregateQuery)

    Retrieve Metric Aggregations

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


1220
1221
1222
1223
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1220

def query_metric_aggregates(metric_aggregate_query, opts = {})
  data, _status_code, _headers = query_metric_aggregates_with_http_info(metric_aggregate_query, opts)
  data
end

#query_metric_aggregates_with_http_info(metric_aggregate_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: create_metric_aggregate_with_http_info

Query Metric Aggregates Query and aggregate event data associated with a metric, including native Klaviyo metrics, integration-specific metrics, and custom events (not to be confused with [custom metrics](developers.klaviyo.com/en/reference/custom_metrics_api_overview), which are not supported at this time). Queries must be passed in the JSON body of your &#x60;POST&#x60; request. To request campaign and flow performance data that matches the data shown in Klaviyo&#39;s UI, we recommend the [Reporting API](developers.klaviyo.com/en/reference/reporting_api_overview). Results can be filtered and grouped by time, event, or profile dimensions. To learn more about how to use this endpoint, check out our new [Using the Query Metric Aggregates Endpoint guide](developers.klaviyo.com/en/docs/using-the-query-metric-aggregates-endpoint). For a comprehensive list of request body parameters, native Klaviyo metrics, and their associated attributes for grouping and filtering, please refer to the [metrics attributes guide](developers.klaviyo.com/en/docs/supported_metrics_and_attributes).&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;metrics:read&#x60;

Parameters:

  • metric_aggregate_query (MetricAggregateQuery)

    Retrieve Metric Aggregations

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1233

def query_metric_aggregates_with_http_info(metric_aggregate_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.query_metric_aggregates ...'
  end
  # verify the required parameter 'metric_aggregate_query' is set
  if @api_client.config.client_side_validation && metric_aggregate_query.nil?
    fail ArgumentError, "Missing the required parameter 'metric_aggregate_query' when calling MetricsApi.query_metric_aggregates"
  end
  # resource path
  local_var_path = '/api/metric-aggregates'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(metric_aggregate_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.query_metric_aggregates",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#query_metric_aggregates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_custom_metric(id, custom_metric_partial_update_query, opts = {}) ⇒ Hash<String, Object>

Update Custom Metric Update a custom metric with the given custom metric ID.
*Rate limits*:
Burst: ‘1/s`
Steady: `15/m`
Daily: `15/d` Scopes: `metrics:write`

Parameters:

  • id (String)

    The ID of the custom metric

  • custom_metric_partial_update_query (CustomMetricPartialUpdateQuery)

    Update a custom metric by ID.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


1297
1298
1299
1300
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1297

def update_custom_metric(id, custom_metric_partial_update_query, opts = {})
  data, _status_code, _headers = update_custom_metric_with_http_info(id, custom_metric_partial_update_query, opts)
  data
end

#update_custom_metric_with_http_info(id, custom_metric_partial_update_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Update Custom Metric Update a custom metric with the given custom metric ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;1/s&#x60;&lt;br&gt;Steady: &#x60;15/m&#x60;&lt;br&gt;Daily: &#x60;15/d&#x60; Scopes: &#x60;metrics:write&#x60;

Parameters:

  • id (String)

    The ID of the custom metric

  • custom_metric_partial_update_query (CustomMetricPartialUpdateQuery)

    Update a custom metric by ID.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
# File 'lib/klaviyo-api-sdk/api/metrics_api.rb', line 1308

def update_custom_metric_with_http_info(id, custom_metric_partial_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsApi.update_custom_metric ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling MetricsApi.update_custom_metric"
  end
  # verify the required parameter 'custom_metric_partial_update_query' is set
  if @api_client.config.client_side_validation && custom_metric_partial_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'custom_metric_partial_update_query' when calling MetricsApi.update_custom_metric"
  end
  # resource path
  local_var_path = '/api/custom-metrics/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(custom_metric_partial_update_query)

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

  new_options = opts.merge(
    :operation => :"MetricsApi.update_custom_metric",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: MetricsApi#update_custom_metric\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end