---
title: "Create metric collection"
method: POST
path: "/api/v2/experiments/metric-collections"
tags: ["Experiments"]
---

# Create metric collection

`POST /api/v2/experiments/metric-collections`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/experiments/metric-collections`
- 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_metrics_write`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/experiments/metric-collections/post.ts> (a function with typed inputs; its response is checked against the schema)

Create metric collection.

## Request body

- ExperimentsCreateMetricCollectionV2Request: Request to create a reusable collection of metrics.
  - `data` ExperimentsCreateMetricCollectionV2RequestData, required: Metric collection resource to create.
    - `attributes` ExperimentsCreateMetricCollectionV2RequestDataAttributes, required: Name, description, and metric selection for the new collection.
      - `description` string, nullable: Description of the metric collection.
      - `is_guardrail` boolean: Whether the collection is designated as a guardrail collection.
      - `metrics` ExperimentsCreateMetricCollectionV2RequestDataAttributesMetricsItems[]: Metrics to include in the collection.
        - `metric_id` string, uuid, required: Identifier of the metric to include in the collection.
      - `name` string, required: Display name of the metric collection.
    - `id` string: Optional JSON:API resource identifier field.
    - `type` 'metric-collections', required: Metric collections resource type.

## Response `201`

Created

- ExperimentsMetricCollectionV2DTO: Response containing the metric collection.
  - `data` ExperimentsMetricCollectionV2DTOData, required: JSON:API resource containing the metric collection identity and fields.
    - `attributes` ExperimentsMetricCollectionV2DTODataAttributes: Details of the metric collection.
      - `created_at` string, date-time: Time when this resource was created.
      - `description` string, nullable: Text that explains the metric collection.
      - `is_guardrail` boolean: Whether the collection is used for guardrail metrics.
      - `metric_count` integer: Number of metrics in this collection.
      - `metrics` ExperimentsMetricCollectionV2DTODataAttributesMetricsItems[]: Metrics included in this collection.
        - `metric_id` string: ID of the metric represented by this entry.
        - `metric_name` string: Display name of the metric represented by this entry.
      - `name` string: Display name of the metric collection.
      - `updated_at` string, date-time: Time when this resource was last updated.
    - `id` string, uuid, required: ID of the metric collection.
    - `type` 'metric-collections', required: Metric collections resource type.

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `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)
