---
title: "Create a RUM-based metric"
method: POST
path: "/api/v2/rum/config/metrics"
tags: ["Rum Metrics"]
---

# Create a RUM-based metric

`POST /api/v2/rum/config/metrics`

Create a metric based on your organization's RUM data.
Returns the RUM-based metric object from the request body when the request is successful.

## Request body

- RumMetricCreateRequest — The new RUM-based metric body.
  - `data` RumMetricCreateData, required — The new RUM-based metric properties.
    - `attributes` RumMetricCreateAttributes, required — The object describing the Datadog RUM-based metric to create.
      - `compute` RumMetricCompute, required — The compute rule to compute the RUM-based metric.
        - `aggregation_type` 'count' | 'distribution', required — The type of aggregation to use.
        - `include_percentiles` boolean — Toggle to include or exclude percentile aggregations for distribution metrics. Only present when `aggregation_type` is `distribution`.
        - `path` string — The path to the value the RUM-based metric will aggregate on. Only present when `aggregation_type` is `distribution`.
      - `event_type` 'session' | 'view' | 'action' | 'error' | 'resource' | 'long_task' | 'vital', required — The type of RUM events to filter on.
      - `filter` RumMetricFilter — The RUM-based metric filter. Events matching this filter will be aggregated in this metric.
        - `query` string, required — The search query - following the RUM search syntax.
      - `group_by` RumMetricGroupBy[] — The rules for the group by.
        - `path` string, required — The path to the value the RUM-based metric will be aggregated over.
        - `tag_name` string — Eventual name of the tag that gets created. By default, `path` is used as the tag name.
      - `uniqueness` RumMetricUniqueness — The rule to count updatable events. Is only set if `event_type` is `sessions` or `views`.
        - `when` 'match' | 'end', required — When to count updatable events. `match` when the event is first seen, or `end` when the event is complete.
    - `id` string, required — The name of the RUM-based metric.
    - `type` 'rum_metrics', required — The type of the resource. The value should always be rum_metrics.

## Response `201`

Created

- RumMetricResponse — The RUM-based metric object.
  - `data` RumMetricResponseData — The RUM-based metric properties.
    - `attributes` RumMetricResponseAttributes — The object describing a Datadog RUM-based metric.
      - `compute` RumMetricResponseCompute — The compute rule to compute the RUM-based metric.
        - `aggregation_type` 'count' | 'distribution' — The type of aggregation to use.
        - `include_percentiles` boolean — Toggle to include or exclude percentile aggregations for distribution metrics. Only present when `aggregation_type` is `distribution`.
        - `path` string — The path to the value the RUM-based metric will aggregate on. Only present when `aggregation_type` is `distribution`.
      - `event_type` 'session' | 'view' | 'action' | 'error' | 'resource' | 'long_task' | 'vital' — The type of RUM events to filter on.
      - `filter` RumMetricResponseFilter — The RUM-based metric filter. RUM events matching this filter will be aggregated in this metric.
        - `query` string — The search query - following the RUM search syntax.
      - `group_by` RumMetricResponseGroupBy[] — The rules for the group by.
        - `path` string — The path to the value the RUM-based metric will be aggregated over.
        - `tag_name` string — Eventual name of the tag that gets created. By default, `path` is used as the tag name.
      - `uniqueness` RumMetricResponseUniqueness — The rule to count updatable events. Is only set if `event_type` is `session` or `view`.
        - `when` 'match' | 'end' — When to count updatable events. `match` when the event is first seen, or `end` when the event is complete.
    - `id` string — The name of the RUM-based metric.
    - `type` 'rum_metrics' — The type of the resource. The value should always be rum_metrics.

## Other responses

- `400` — Bad Request
- `403` — Not Authorized
- `409` — Conflict
- `429` — Too many requests

---

[API](https://skmtc.net/datadog/apis/api-v2.md) · [All operations](https://skmtc.net/datadog/apis/api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/datadog/api-v2/revisions/da68bf029e4c/schema)
