---
title: "Associate a Metric with a Feature"
method: POST
path: "/v1/projects/{project}/metric-associations"
tags: ["Metric Associations"]
---

# Associate a Metric with a Feature

`POST /v1/projects/{project}/metric-associations`

## Path parameters

- `project` string, required

## Request body

- CreateMetricAssociationDto
  - `metric` string, required
  - `feature` string, required

## Response `201`

- MetricAssociation
  - `_project` string, required
  - `feature` Feature, required
    - `_id` string, required — A unique Feature ID
    - `_project` string, required — The Project owning the Feature
    - `source` 'api' | 'dashboard' | 'importer' | 'github.code_usages' | 'github.pr_insights' | 'gitlab.code_usages' | 'gitlab.pr_insights' | 'bitbucket.code_usages' | 'bitbucket.pr_insights' | 'terraform' | 'cli' | 'slack' | 'mcp', required — Source that created the Feature
    - `status` 'active' | 'complete' | 'archived', required — Status of the Feature
    - `type` 'release' | 'experiment' | 'permission' | 'ops' — The Feature type
    - `name` string, required — Name of the Feature
    - `key` string, required — Unique key by Project, can be used in the SDK / API to reference by 'key' rather than _id. Must only contain lower-case characters and `_`, `-` or `.`.
    - `description` string — Feature description.
    - `_createdBy` string — ID of the User who created the Feature
    - `createdAt` string, date-time, required — The date the Feature was created
    - `updatedAt` string, date-time, required — The date the Feature was last updated
    - `prodTargetingUpdatedAt` string, date-time — The date the Feature had an update that impacted production targeting
    - `variations` Variation[] — Variation configurations to be used by feature configurations.
      - `key` string, required — Unique key by Feature, can be used in the SDK / API to reference by 'key' rather than _id. Must only contain lower-case characters and `_`, `-` or `.`.
      - `name` string, required — Variation display name.
      - `variables` object — A key-value map of variables to their value for this variation
      - `_id` string, required — A unique Variation ID
    - `controlVariation` string, required — The key of the variation that is used as the control variation for Metrics
    - `staticVariation` string — The key of the variation that is set when the Feature's status is set to complete
    - `variables` Variable[] — Variable definitions to be referenced in variations
      - `name` string — Variable name
      - `description` string — A description of the Variable
      - `key` string, required — Unique Variable identifier, can be used in the SDK / API to reference by key rather then ID. Must only contain lower-case characters and `_`, `-` or `.`.
      - `_id` string, required — A unique Variable ID
      - `_project` string, required — The ID of the Project this Variable belongs to
      - `_feature` string — The ID of the Feature this Variable belongs to
      - `type` 'String' | 'Boolean' | 'Number' | 'JSON', required — The type of Variable. Must be one of [String | Boolean | Number | JSON]
      - `status` 'active' | 'archived', required — The status of a Variable. Must be one of [active | archived]
      - `source` 'api' | 'dashboard' | 'importer' | 'github.code_usages' | 'github.pr_insights' | 'gitlab.code_usages' | 'gitlab.pr_insights' | 'bitbucket.code_usages' | 'bitbucket.pr_insights' | 'terraform' | 'cli' | 'slack' | 'mcp', required — The system that was used for the creation of the Variable.
      - `_createdBy` string — ID of the User who created the Variable.
      - `createdAt` string, date-time, required — The date the Variable was created
      - `updatedAt` string, date-time, required — The date the Variable was last updated
      - `validationSchema` VariableValidationEntity
        - `schemaType` object, required
        - `enumValues` object
        - `regexPattern` string
        - `jsonSchema` string
        - `description` string, required
        - `exampleValue` object, required
      - `persistent` boolean — Boolean indicating if the variable is intended to be long-lived within a feature
      - `tags` string[] — Tags to organize Variables on the dashboard
    - `tags` string[] — Tags to organize Features on the dashboard
    - `ldLink` string — A link to the feature on LaunchDarkly if it has importedByLD type
    - `readonly` boolean, required — Controls whether the feature is editable for a given user
    - `settings` FeatureSettings
      - `publicName` string, required
      - `publicDescription` string, required
      - `optInEnabled` boolean, required
    - `sdkVisibility` FeatureSDKVisibility
      - `mobile` boolean, required
      - `client` boolean, required
      - `server` boolean, required
    - `configurations` FeatureConfig[], required — An array of targeting configurations for the associated environments
      - `_feature` string, required — ID of the Feature owning the Configuration
      - `_environment` string, required — ID of the Environment owning the Configuration
      - `_createdBy` string — User who created the Feature Configuration
      - `status` 'active' | 'inactive', required — Status of the Feature Configuration
      - `startedAt` string, date-time — Date the Feature Configuration was started
      - `updatedAt` string, date-time, required — The date the Feature Configuration was last updated
      - `targets` Target[], required — The targets to evaluate what variation a user should be delivered
        - `_id` string, required — A unique Target ID
        - `name` string — Target name
        - `audience` TargetAudience, required
          - `name` string — Audience display name, must be set for project-level audiences.
          - `filters` AudienceOperatorWithAudienceMatchFilter, required
            - `filters` union[], required — Filters to apply using the "operator" operation
              - …
            - `operator` 'and' | 'or', required — Operator type if this object represents an operator, and not a filter
        - `rollout` Rollout
          - `startPercentage` number — Rollout start percentage
          - `type` 'schedule' | 'gradual' | 'stepped', required — Type of rollout
          - `startDate` string, date-time, required — Date to start rollout
          - `stages` RolloutStage[] — Stages of rollout
            - `percentage` number, required — Target percentage to reach by the step date
            - `type` 'linear' | 'discrete', required — Defines the transition into this percentage level
            - `date` string, date-time, required — Date the target percentage should be fully applied
        - `distribution` TargetDistribution[], required — Specifies variation distribution percentages for features
          - `percentage` number, required — Distribution percentage for the variation
          - `_variation` string, required — Variation ID or key from `feature.variations`
        - `bucketingKey` string — String to bucket users into a specific variation
      - `readonly` boolean, required — Controls whether the feature configuration is editable for a given user
      - `hasStaticConfig` boolean, required — Flag to indicate if the Feature owning the configuration has been marked as complete. If true, the user targeting rules are ignored and the static variation is always used.
    - `latestUpdate` AuditLogEntity
      - `date` string, date-time, required
      - `a0_user` string, required
      - `changes` object[], required
    - `changeRequests` object[] — Pending change requests for this Feature
    - `staleness` FeatureStaleness
    - `customStatus` FeatureCustomStatus
      - `_status` string — Custom status ID reference
      - `updatedAt` string, date-time — Timestamp when the custom status was last updated
    - `summary` FeatureSummary, required
      - `maintainers` string[], required — Auth0 maintainers of this feature
      - `links` Link[], required
        - `url` string, required
        - `title` string, required
      - `markdown` string, required
  - `metric` Metric, required
    - `name` string, required — Name of the Metric
    - `key` string, required — Unique key by Project, can be used in the SDK / API to reference by 'key' rather than _id. Must only contain lower-case characters and `_`, `-` or `.`.
    - `description` string — Metric description.
    - `_id` string, required — A unique Metric ID
    - `_project` string, required — The Project owning the Metric
    - `source` 'api' | 'dashboard' | 'importer' | 'github.code_usages' | 'github.pr_insights' | 'gitlab.code_usages' | 'gitlab.pr_insights' | 'bitbucket.code_usages' | 'bitbucket.pr_insights' | 'terraform' | 'cli' | 'slack' | 'mcp' — Source that created the Metric
    - `event` string, required — Event associated with metric
    - `dimension` 'COUNT_PER_UNIQUE_USER' | 'COUNT_PER_VARIABLE_EVALUATION' | 'SUM_PER_UNIQUE_USER' | 'AVERAGE_PER_UNIQUE_USER' | 'TOTAL_AVERAGE' | 'TOTAL_SUM', required — Metric dimension
    - `optimize` 'increase' | 'decrease', required — Indicates whether the metric is optimized for increase or decreasae
    - `createdAt` string, date-time, required — The date the Metric was created
    - `updatedAt` string, date-time, required — The date the Metric was last updated
  - `createdAt` string, date-time, required

## Other responses

- `401`
- `403`
- `404`

---

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