---
title: "Create experiment metric group"
method: POST
path: "/api/v2/experiments/{experiment_id}/metric-groups"
tags: ["Experiments"]
---

# Create experiment metric group

`POST /api/v2/experiments/{experiment_id}/metric-groups`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/experiments/{experiment_id}/metric-groups`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `product_analytics_experiments_write`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/experiments/:experiment_id/metric-groups/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a non-decision metric group. The optional metrics array is ordered. Decision groups remain managed through decision_metrics on the experiment resource. This operation does not synchronously recompute results.

## Path parameters

- `experiment_id` string, uuid, required: The UUID of the experiment.

## Request body

- ExperimentsCreateExperimentMetricGroupV2Request: Request to create a metric group on an experiment.
  - `data` ExperimentsCreateExperimentMetricGroupV2RequestData, required: Metric group resource to create on the experiment.
    - `attributes` ExperimentsCreateExperimentMetricGroupV2RequestDataAttributes, required: Name and metric selection for the new experiment metric group.
      - `metrics` ExperimentsCreateExperimentMetricGroupV2RequestDataAttributesMetricsItems[]: Metrics to include in the experiment metric group.
        - `metric_id` string, uuid, required: Identifier of the metric to include in the group.
      - `migration_metadata` unknown
      - `name` string, required: Display name of the experiment metric group.
    - `id` string: Optional JSON:API resource identifier field.
    - `type` 'experiment-metric-groups', required: Experiment metric groups resource type.

## Response `201`

Created

- ExperimentsExperimentMetricGroupMutationV2: Response containing the saved experiment metric group and result refresh information.
  - `data` ExperimentsExperimentMetricGroupMutationV2Data, required: Experiment metric group resource with its identifier and metric selection.
    - `attributes` ExperimentsExperimentMetricGroupV2DTODataAttributes: Name, purpose, and selected metrics of an experiment metric group.
      - `is_decision` boolean: Whether this group contains the experiment decision metrics.
      - `metrics` ExperimentsExperimentMetricGroupMutationV2DataAttributesMetricsItems[]: Metrics selected for this experiment metric group.
        - `is_primary` boolean, required: Whether this is the experiment primary metric.
        - `metric_id` string, required: Identifier of the metric in the group.
        - `metric_name` string, required: Display name of the metric in the group.
      - `migration_metadata` unknown
      - `name` string: Display name of the experiment metric group.
    - `id` string, uuid, required: Identifier of the experiment metric group.
    - `type` 'experiment-metric-groups', required: Experiment metric groups resource type.
  - `meta` ExperimentsPatchExperimentV2MetaDTO: Refresh requirements and warnings returned by an experiment update.
    - `needs_pipeline_refresh` boolean, required: Whether this edit needs a full or non-full pipeline run. This operation does not start the run. A later false value does not clear a refresh required by an earlier edit.
    - `refresh_endpoint` string: POST to this endpoint after finishing your edits. The full_refresh query parameter selects the required run type. Across multiple edits any full_refresh=true requirement takes priority.
    - `warnings` ExperimentsPatchExperimentV2MetaDTOWarningsItems[]: Warnings returned after the experiment update.
      - `code` string, required: Code that identifies the warning.
      - `detail` string, required: Explanation of the warning and its effect on the update.

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `409`: Conflict
- `415`: Request body sent with a media type other than application/json or application/vnd.api+json.
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/3f70db624329?raw)
