---
title: "POST /app/metrics/"
method: POST
path: "/app/metrics/"
tags: ["app"]
---

# POST /app/metrics/

`POST /app/metrics/`

A simple ViewSet for viewing and editing Billable Metrics.

## Request body

- MetricCreateRequest
  - `event_name` string — Name of the event that this metric is tracking.
  - `property_name` string, nullable — The name of the property of the event that should be used for this metric. Doesn't apply if the metric is of type 'counter' with an aggregation of count.
  - `usage_aggregation_type` 'count' | 'sum' | 'max' | 'unique' | 'latest' | 'average' | 'null', nullable — The type of aggregation that should be used for this metric. Please refer to our documentation for an explanation of the different types.
  - `billable_aggregation_type` 'count' | 'sum' | 'max' | 'unique' | 'latest' | 'average' | 'null', nullable
  - `granularity` 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'quarters' | 'years' | 'total' | 'null', nullable — The granularity of the metric. Only applies to metrics of type 'gauge' or 'rate'.
  - `event_type` 'delta' | 'total' | 'null', nullable — Used only for metrics of type 'gauge'. Please refer to our documentation for an explanation of the different types.
  - `metric_type` 'counter' | 'rate' | 'custom' | 'gauge', required — The type of metric that this is. Please refer to our documentation for an explanation of the different types.
  - `metric_name` string, required
  - `proration` 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'quarters' | 'years' | 'total' | 'null', nullable — The proration of the metric. Only applies to metrics of type 'gauge'.
  - `properties` object, nullable
  - `is_cost_metric` boolean — Whether or not this metric is a cost metric (used to track costs to your business).
  - `custom_sql` string, nullable — A custom SQL query that can be used to define the metric. Please refer to our documentation for more information.

## Response `201`

- Metric
  - `metric_id` string, required
  - `event_name` string, required — Name of the event that this metric is tracking.
  - `property_name` string, nullable, required — The name of the property of the event that should be used for this metric. Doesn't apply if the metric is of type 'counter' with an aggregation of count.
  - `aggregation_type` string, required
  - `granularity` 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'quarters' | 'years' | 'total' | 'null', nullable, required — The granularity of the metric. Only applies to metrics of type 'gauge' or 'rate'.
  - `event_type` 'delta' | 'total' | 'null', nullable, required — Used only for metrics of type 'gauge'. Please refer to our documentation for an explanation of the different types.
  - `metric_type` 'counter' | 'rate' | 'custom' | 'gauge', required — The type of metric that this is. Please refer to our documentation for an explanation of the different types.
  - `metric_name` string, required
  - `numeric_filters` NumericFilter[], required
    - `property_name` string, required
    - `operator` 'gte' | 'gt' | 'eq' | 'lt' | 'lte', required
    - `comparison_value` number, double, required
  - `categorical_filters` CategoricalFilter[], required
    - `property_name` string, required
    - `operator` 'isin' | 'isnotin', required
    - `comparison_value` string[], required
  - `is_cost_metric` boolean, required — Whether or not this metric is a cost metric (used to track costs to your business).
  - `custom_sql` string, nullable, required — A custom SQL query that can be used to define the metric. Please refer to our documentation for more information.
  - `proration` 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'quarters' | 'years' | 'total' | 'null', nullable, required — The proration of the metric. Only applies to metrics of type 'gauge'.

## Changes

- **2023-01-16** `36b48cae00a3` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/uselotus/apis/lotus-api/changes/app/metrics/post.md)

---

[API](https://skmtc.dev/uselotus/apis/lotus-api.md) · [All operations](https://skmtc.dev/uselotus/apis/lotus-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/uselotus/lotus-api/revisions/36b48cae00a3/schema)
