> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/api-reference/more-products-apis/feature-management-and-experimentation/metrics.md).

# Metrics

Manage project-scoped metric definitions (create, list, get, update, delete).

## List Metrics

> Returns a paginated list of Metrics in the specified project workspace. Results can be\
> filtered by name, traffic type, event type, tags, or metric identifiers, and are sorted by\
> name. Only live metrics are returned; deleted metrics are removed permanently and never\
> appear in the list.<br>

```json
{"openapi":"3.0.3","info":{"title":"Harness Feature Management & Experimentation API","version":"4.0.0"},"tags":[{"name":"Metrics","description":"Manage project-scoped metric definitions (create, list, get, update, delete)."}],"servers":[{"url":"https://app.harness.io/fme/api","description":"Harness SaaS (production)"},{"url":"https://app3.harness.io/fme/api","description":"Harness SaaS (US-3)"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Harness Service Account Token (SAT) or Personal Access Token (PAT).\nGenerate tokens in Harness under Account Settings → Access Management.\n"}},"parameters":{"AccountId":{"name":"account_id","in":"query","required":true,"description":"Harness account identifier. Required on all endpoints.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"OrganizationIdentifier":{"name":"organization_identifier","in":"query","required":true,"description":"Harness organization identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"ProjectIdentifier":{"name":"project_identifier","in":"query","required":true,"description":"Harness project identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"PaginationLimitParam":{"name":"limit","in":"query","required":false,"description":"Number of items to return per page. Defaults to 100, maximum 100.","schema":{"type":"integer","minimum":1,"maximum":100,"default":100}},"PaginationOffsetParam":{"name":"offset","in":"query","required":false,"description":"Number of items to skip before the first returned result. Defaults to 0.","schema":{"type":"integer","minimum":0,"default":0}}},"schemas":{"MetricListResponse":{"type":"object","description":"Paginated list of Metrics matching the query.","required":["data","limit","offset","totalCount"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Metric"}},"limit":{"type":"integer","description":"The page size used for this response."},"offset":{"type":"integer","description":"The number of items skipped before the first result."},"totalCount":{"type":"integer","description":"Total number of metrics matching the query."}}},"Metric":{"type":"object","description":"A project-scoped Metric definition, returned by GET, LIST, and inside the mutation\nenvelope. Some fields are read-only (`metricSourceId`, `customFieldFilters`).\n","required":["type","id","name","trafficType","format","aggregation","isPositive","createdAt","status","baseEventTypes","tags","owners"],"properties":{"type":{"type":"string","enum":["METRIC"],"description":"Resource type discriminator. Always `METRIC`."},"id":{"type":"string","format":"uuid","description":"Unique system-assigned identifier for the metric. Use this as the path parameter in subsequent requests."},"name":{"type":"string","description":"Unique metric name within the project."},"description":{"type":"string","nullable":true,"description":"Human-readable description of this metric."},"trafficType":{"allOf":[{"$ref":"#/components/schemas/ReferenceObject"}],"description":"Reference to the traffic type this metric measures (`type` is `TRAFFIC_TYPE`)."},"format":{"type":"string","enum":["NUMBER","DOLLAR","PERCENTAGE","SECONDS","MILLISECONDS","BYTES"],"description":"Display/measurement format of the metric value."},"aggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"description":"How individual event values are aggregated per unit."},"isPositive":{"type":"boolean","description":"`true` when an increase in this metric is a good outcome."},"spread":{"type":"string","enum":["PER","ACROSS"],"description":"Whether the metric is computed per-unit or across the population. Always present on read."},"baseEventTypes":{"type":"array","description":"The base event type(s) this metric measures. At least one.","items":{"$ref":"#/components/schemas/BaseEventType"}},"filterEventType":{"allOf":[{"$ref":"#/components/schemas/FilterEventType"}],"type":"object","nullable":true,"description":"Optional filter/trigger event that scopes which units are counted."},"triggerEventType":{"allOf":[{"$ref":"#/components/schemas/TriggerEventType"}],"type":"object","nullable":true,"description":"Optional trigger event (HAS_DONE_BEFORE): the unit must have done this event before the\nbase event for it to be counted.\n"},"tags":{"type":"array","description":"Tags associated with this metric (each `type` is `TAG`).","items":{"$ref":"#/components/schemas/ReferenceObject"}},"owners":{"type":"array","description":"Users or groups that own this metric. `USER` owners include `email`; `GROUP` owners do not.","items":{"$ref":"#/components/schemas/OwnerReference"}},"metricSourceId":{"type":"string","format":"uuid","nullable":true,"readOnly":true,"description":"Warehouse-native metric source this metric reads from, when applicable."},"customFieldFilters":{"type":"object","nullable":true,"readOnly":true,"description":"Warehouse-native custom-field filters."},"cap":{"allOf":[{"$ref":"#/components/schemas/MetricCap"}],"type":"object","nullable":true,"description":"Outlier/cap configuration. `null` (or all-zero fields) means no cap is applied."},"createdAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was created."},"modifiedAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was last modified."},"status":{"type":"string","enum":["ACTIVE","ARCHIVED"],"description":"Lifecycle status of the metric. New metrics are always `ACTIVE`, and `DELETE` removes a\nmetric permanently rather than changing its status (see the delete endpoint). `ARCHIVED`\nis a legacy value that may still appear on metrics created before archiving was replaced\nby hard delete; this API never transitions a metric to `ARCHIVED`.\n"}}},"ReferenceObject":{"type":"object","description":"Generic reference to another resource, returned in responses. `id` is the stable\npublic identifier, `type` disambiguates the referenced entity kind, and `name` is the\nhuman-readable label.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the referenced resource."},"type":{"type":"string","description":"The kind of entity this reference points to (for example `TRAFFIC_TYPE`, `TAG`,\n`USER`, `GROUP`, `ROLLOUT_STATUS`, `FEATURE_FLAG`, `ENVIRONMENT`, or `SEGMENT`).\nEach resource API returns only the kinds relevant to that API.\n"},"name":{"type":"string","description":"Human-readable name of the referenced resource."}}},"BaseEventType":{"type":"object","description":"A base event type the metric measures, with optional per-event property filters.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the event type."},"propertyFilters":{"type":"array","description":"Optional property filters applied to this base event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}},"propertyForValue":{"type":"string","nullable":true,"description":"Event property whose value is measured (for value-based aggregations)."}}},"EventPropertyFilter":{"type":"object","description":"A filter on an event property. The operand field must match the `operator` (validated\nserver-side; a mismatch is rejected with `400`, `errorType: operatorOperandMismatch`):\n- scalar operators (`EQUAL`, `GREATER_THAN`, `LESS_THAN`, `STRING_EQUAL`, `CONTAINS`,\n  `STARTS_WITH`, `BOOLEAN_EQUAL`) use `secondOperand`;\n- `STRING_IN_LIST` uses `stringInListOperand` (non-empty);\n- `BETWEEN` uses `numberRangeOperand` as exactly two values `[lower, upper]`.\n","required":["property","operator"],"properties":{"property":{"type":"string","description":"The event property to filter on."},"operator":{"type":"string","enum":["EQUAL","GREATER_THAN","LESS_THAN","BETWEEN","STRING_EQUAL","CONTAINS","STARTS_WITH","STRING_IN_LIST","BOOLEAN_EQUAL"],"description":"Comparison operator."},"inverted":{"type":"boolean","description":"When `true`, the operator is negated (e.g. NOT EQUAL).","default":false},"secondOperand":{"type":"string","nullable":true,"description":"Single-value operand (for scalar operators)."},"stringInListOperand":{"type":"array","nullable":true,"minItems":1,"description":"Operand for the list operator (`STRING_IN_LIST`). Required and non-empty for that operator.","items":{"type":"string"}},"numberRangeOperand":{"type":"array","nullable":true,"minItems":2,"maxItems":2,"description":"Operand for the range operator (`BETWEEN`) — exactly two values, `[lower, upper]`.","items":{"type":"number","format":"double"}}}},"FilterEventType":{"type":"object","description":"A filter/trigger event that scopes which units the metric counts.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the filter/trigger event type."},"filterAggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"nullable":true,"description":"Aggregation applied to the filter event."},"propertyFilters":{"type":"array","description":"Optional property filters applied to the filter event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}}}},"TriggerEventType":{"type":"object","description":"A trigger event (HAS_DONE_BEFORE): the unit must have done this event before the base event.\nUnlike `FilterEventType`, a trigger event has no aggregation or property filters.\n","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the trigger event type."}}},"OwnerReference":{"type":"object","description":"Reference to an owner (user or group), returned in responses. Extends the generic reference\nwith an optional `email`: a `USER` owner MAY carry `email` where the resource populates it;\na `GROUP` owner never has one. Use `id` for subsequent API calls; `name`/`email` are\ninformational (they let clients that keyed on a user's email at write time correlate the\nresponse without a lookup). Shared across FME v4 resources that expose owners.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the owner — the Harness user id (for `USER`) or group id (for `GROUP`)."},"type":{"type":"string","enum":["USER","GROUP"],"description":"Owner kind."},"name":{"type":"string","description":"Human-readable display name of the user or group."},"email":{"type":"string","format":"email","nullable":true,"description":"Email address of the owner. Optionally populated for `USER` owners where the resource\nsupports it; `null`/absent for `GROUP` owners and for resources that do not return it.\n"}}},"MetricCap":{"type":"object","description":"Optional outlier/cap configuration. Each field bounds a specific measured quantity when the\nmetric is computed; a field value of `0` (the default) means that cap is not applied, so any\nfield may be omitted. In practice only the field matching the metric's `aggregation` is\nmeaningful — setting caps that don't correspond to the aggregation has no effect rather than\nbeing rejected. `granularity` is the time window the caps apply over.\n","properties":{"baseEventCountCap":{"type":"number","format":"double","description":"Upper bound on the base-event count. `0` = no cap."},"baseEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed base-event value. `0` = no cap."},"baseEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual base-event value. `0` = no cap."},"filterEventCountCap":{"type":"number","format":"double","description":"Upper bound on the filter-event count. `0` = no cap."},"filterEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed filter-event value. `0` = no cap."},"filterEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual filter-event value. `0` = no cap."},"metricValueCap":{"type":"number","format":"double","description":"Upper bound on the final per-unit metric value. `0` = no cap."},"granularity":{"type":"string","enum":["MINUTES","HOURS","DAYS","WEEKS"],"default":"DAYS","description":"Time window the caps apply over."}}},"ErrorResponse":{"type":"object","description":"Standard error response following RFC 7807 Problem Details format (Harness ADR 57).\n","required":["type","status","title","errorType"],"properties":{"type":{"type":"string","format":"uri","description":"URI reference to documentation for this error type."},"status":{"type":"integer","description":"HTTP status code."},"title":{"type":"string","description":"Short human-readable summary of the problem."},"errorType":{"type":"string","description":"Machine-readable error type identifier."},"detail":{"type":"string","description":"Detailed human-readable explanation specific to this occurrence."},"instance":{"type":"string","description":"URI reference identifying the specific occurrence (usually the request path)."},"errors":{"type":"array","description":"List of specific sub-errors (useful for multi-field validation failures). Governance\npolicy failures are also surfaced here — each failing policy is reported as an entry\nwith `errorType: \"governancePolicy\"` — rather than in a separate top-level field.\n","items":{"$ref":"#/components/schemas/ErrorDetail"}}}},"ErrorDetail":{"type":"object","description":"Details about a single sub-error.","required":["errorType","title"],"properties":{"errorType":{"type":"string","description":"Machine-readable error type for this specific error."},"title":{"type":"string","description":"Short summary of this specific error."},"detail":{"type":"string","description":"Detailed explanation of this specific error."},"field":{"type":"string","description":"Name of the request field this error applies to, when the error is field-specific\n(for example a validation failure). Omitted for errors not tied to a single field.\n"}}}},"responses":{"BadRequest":{"description":"Bad Request — validation errors or invalid state transition.\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Unauthorized":{"description":"Unauthorized — the request is missing a valid API key, or the key has expired.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Forbidden — the caller is authenticated but not permitted to perform this operation.\nReturned when the API can deny the operation without leaking whether a resource exists,\nsuch as create, or write operations where the caller can already read the resource. When\nreturning `403` would reveal resource existence, the API returns `404` instead.\n\nEnvironment-scoped mutations that require approval also return `403`.\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"TooManyRequests":{"description":"Too Many Requests — the caller has exceeded the rate limit for this endpoint.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"Internal Server Error — an unexpected error occurred while processing the request.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v4/metrics":{"get":{"tags":["Metrics"],"operationId":"listMetrics","summary":"List Metrics","description":"Returns a paginated list of Metrics in the specified project workspace. Results can be\nfiltered by name, traffic type, event type, tags, or metric identifiers, and are sorted by\nname. Only live metrics are returned; deleted metrics are removed permanently and never\nappear in the list.\n","parameters":[{"$ref":"#/components/parameters/AccountId"},{"$ref":"#/components/parameters/OrganizationIdentifier"},{"$ref":"#/components/parameters/ProjectIdentifier"},{"$ref":"#/components/parameters/PaginationLimitParam"},{"$ref":"#/components/parameters/PaginationOffsetParam"},{"name":"name","in":"query","required":false,"description":"Case-insensitive substring match on metric name.","schema":{"type":"string"}},{"name":"traffic_type_id","in":"query","required":false,"description":"Filter to metrics of the given traffic type (by id).","schema":{"type":"string"}},{"name":"event_type_ids","in":"query","required":false,"description":"Filter to metrics that measure any of the given event types (matched against the\nmetric's `baseEventTypes[].eventTypeId`). Repeat the parameter to pass multiple.\n","schema":{"type":"array","items":{"type":"string"}},"style":"form","explode":true},{"name":"tags","in":"query","required":false,"description":"Filter to metrics that have any of the specified tags (by tag name).","schema":{"type":"array","items":{"type":"string"}},"style":"form","explode":true},{"name":"ids","in":"query","required":false,"description":"Filter to the specified metric ids.","schema":{"type":"array","items":{"type":"string","format":"uuid"}},"style":"form","explode":true},{"name":"sort_order","in":"query","required":false,"description":"Sort direction by name.","schema":{"type":"string","enum":["ASCENDING","DESCENDING"],"default":"ASCENDING"}}],"responses":{"200":{"description":"OK — paginated list of metrics returned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricListResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```

## Create a Metric

> Creates a new Metric in the specified project workspace. The metric name must be unique\
> within the project and is immutable after creation.\
> \
> \*\*Validation (beyond what the request schema enforces):\*\* a \`filterEventType\` may not target\
> the same event type as any \`baseEventTypes\` entry \*\*unless\*\* their property filters differ;\
> an exact overlap is rejected with \`400\` (\`errorType: filterEventMatchesBaseEvent\`).<br>

```json
{"openapi":"3.0.3","info":{"title":"Harness Feature Management & Experimentation API","version":"4.0.0"},"tags":[{"name":"Metrics","description":"Manage project-scoped metric definitions (create, list, get, update, delete)."}],"servers":[{"url":"https://app.harness.io/fme/api","description":"Harness SaaS (production)"},{"url":"https://app3.harness.io/fme/api","description":"Harness SaaS (US-3)"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Harness Service Account Token (SAT) or Personal Access Token (PAT).\nGenerate tokens in Harness under Account Settings → Access Management.\n"}},"parameters":{"AccountId":{"name":"account_id","in":"query","required":true,"description":"Harness account identifier. Required on all endpoints.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"OrganizationIdentifier":{"name":"organization_identifier","in":"query","required":true,"description":"Harness organization identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"ProjectIdentifier":{"name":"project_identifier","in":"query","required":true,"description":"Harness project identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}}},"schemas":{"CreateMetricRequest":{"type":"object","description":"Request body for creating a new Metric.","required":["name","trafficType","format","aggregation","isPositive","baseEventTypes"],"properties":{"name":{"type":"string","pattern":"^[A-Za-z][-_A-Za-z0-9]*$","minLength":1,"maxLength":100,"description":"Unique metric name within the project. Immutable after creation."},"description":{"type":"string","description":"Human-readable description of this metric."},"trafficType":{"type":"string","description":"Traffic type this metric measures, identified by its name (for example `user` or\n`account`). Immutable after creation.\n"},"format":{"type":"string","enum":["NUMBER","DOLLAR","PERCENTAGE","SECONDS","MILLISECONDS","BYTES"]},"aggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"]},"isPositive":{"type":"boolean","description":"`true` when an increase in this metric is a good outcome."},"spread":{"type":"string","enum":["PER","ACROSS"],"description":"Whether the metric is computed per-unit or across the population. Optional — defaults to\n`PER` when omitted (matching the current UI, which always sends `PER`).\n"},"baseEventTypes":{"type":"array","minItems":1,"description":"The base event type(s) this metric measures. At least one.","items":{"$ref":"#/components/schemas/BaseEventType"}},"filterEventType":{"allOf":[{"$ref":"#/components/schemas/FilterEventType"}],"type":"object","nullable":true},"triggerEventType":{"allOf":[{"$ref":"#/components/schemas/TriggerEventType"}],"type":"object","nullable":true,"description":"Optional trigger event (HAS_DONE_BEFORE): the unit must have done this event before the\nbase event for it to be counted.\n"},"tags":{"type":"array","description":"Initial tags to associate with the metric. Uses the shared `TagReferenceInput`\n(`{ name }`); tags are returned as full `{ type, id, name }` refs on read.\n","items":{"$ref":"#/components/schemas/TagReferenceInput"}},"owners":{"type":"array","description":"Owners for this metric (optional). Uses the shared `OwnerReferenceInput`: a `USER` owner\nis `{ type: USER, id | email }`, a `GROUP` owner is `{ type: GROUP, identifier }`. Owners\nare returned as full `{ type, id, name, email }` refs on read (`email` for users only).\n","items":{"$ref":"#/components/schemas/OwnerReferenceInput"}},"cap":{"allOf":[{"$ref":"#/components/schemas/MetricCap"}],"description":"Optional outlier/cap configuration. Set the field matching the metric's `aggregation`\n(the others stay `0` = no cap); omit entirely for an uncapped metric.\n"}}},"BaseEventType":{"type":"object","description":"A base event type the metric measures, with optional per-event property filters.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the event type."},"propertyFilters":{"type":"array","description":"Optional property filters applied to this base event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}},"propertyForValue":{"type":"string","nullable":true,"description":"Event property whose value is measured (for value-based aggregations)."}}},"EventPropertyFilter":{"type":"object","description":"A filter on an event property. The operand field must match the `operator` (validated\nserver-side; a mismatch is rejected with `400`, `errorType: operatorOperandMismatch`):\n- scalar operators (`EQUAL`, `GREATER_THAN`, `LESS_THAN`, `STRING_EQUAL`, `CONTAINS`,\n  `STARTS_WITH`, `BOOLEAN_EQUAL`) use `secondOperand`;\n- `STRING_IN_LIST` uses `stringInListOperand` (non-empty);\n- `BETWEEN` uses `numberRangeOperand` as exactly two values `[lower, upper]`.\n","required":["property","operator"],"properties":{"property":{"type":"string","description":"The event property to filter on."},"operator":{"type":"string","enum":["EQUAL","GREATER_THAN","LESS_THAN","BETWEEN","STRING_EQUAL","CONTAINS","STARTS_WITH","STRING_IN_LIST","BOOLEAN_EQUAL"],"description":"Comparison operator."},"inverted":{"type":"boolean","description":"When `true`, the operator is negated (e.g. NOT EQUAL).","default":false},"secondOperand":{"type":"string","nullable":true,"description":"Single-value operand (for scalar operators)."},"stringInListOperand":{"type":"array","nullable":true,"minItems":1,"description":"Operand for the list operator (`STRING_IN_LIST`). Required and non-empty for that operator.","items":{"type":"string"}},"numberRangeOperand":{"type":"array","nullable":true,"minItems":2,"maxItems":2,"description":"Operand for the range operator (`BETWEEN`) — exactly two values, `[lower, upper]`.","items":{"type":"number","format":"double"}}}},"FilterEventType":{"type":"object","description":"A filter/trigger event that scopes which units the metric counts.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the filter/trigger event type."},"filterAggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"nullable":true,"description":"Aggregation applied to the filter event."},"propertyFilters":{"type":"array","description":"Optional property filters applied to the filter event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}}}},"TriggerEventType":{"type":"object","description":"A trigger event (HAS_DONE_BEFORE): the unit must have done this event before the base event.\nUnlike `FilterEventType`, a trigger event has no aggregation or property filters.\n","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the trigger event type."}}},"TagReferenceInput":{"type":"object","description":"Tag input used in request bodies. Identified by `name`.","required":["name"],"properties":{"name":{"type":"string","description":"Tag name."}}},"OwnerReferenceInput":{"oneOf":[{"$ref":"#/components/schemas/UserOwnerReferenceInput"},{"$ref":"#/components/schemas/GroupOwnerReferenceInput"}],"discriminator":{"propertyName":"type","mapping":{"USER":"#/components/schemas/UserOwnerReferenceInput","GROUP":"#/components/schemas/GroupOwnerReferenceInput"}},"description":"Owner input. Use `USER` for users and `GROUP` for groups."},"UserOwnerReferenceInput":{"type":"object","description":"User owner input. Prefer `email`; `id` is also accepted for compatibility when the caller\nalready has the Harness user id.\n","required":["type"],"anyOf":[{"required":["email"]},{"required":["id"]}],"properties":{"type":{"type":"string","enum":["USER"],"description":"Owner type discriminator. Always `USER`."},"id":{"type":"string","description":"Harness user id."},"email":{"type":"string","format":"email","description":"User email address."}}},"GroupOwnerReferenceInput":{"type":"object","description":"Group owner input.","required":["type","identifier"],"properties":{"type":{"type":"string","enum":["GROUP"],"description":"Owner type discriminator. Always `GROUP`."},"identifier":{"type":"string","description":"Group identifier."}}},"MetricCap":{"type":"object","description":"Optional outlier/cap configuration. Each field bounds a specific measured quantity when the\nmetric is computed; a field value of `0` (the default) means that cap is not applied, so any\nfield may be omitted. In practice only the field matching the metric's `aggregation` is\nmeaningful — setting caps that don't correspond to the aggregation has no effect rather than\nbeing rejected. `granularity` is the time window the caps apply over.\n","properties":{"baseEventCountCap":{"type":"number","format":"double","description":"Upper bound on the base-event count. `0` = no cap."},"baseEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed base-event value. `0` = no cap."},"baseEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual base-event value. `0` = no cap."},"filterEventCountCap":{"type":"number","format":"double","description":"Upper bound on the filter-event count. `0` = no cap."},"filterEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed filter-event value. `0` = no cap."},"filterEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual filter-event value. `0` = no cap."},"metricValueCap":{"type":"number","format":"double","description":"Upper bound on the final per-unit metric value. `0` = no cap."},"granularity":{"type":"string","enum":["MINUTES","HOURS","DAYS","WEEKS"],"default":"DAYS","description":"Time window the caps apply over."}}},"MetricResponse":{"type":"object","description":"Metric mutation response envelope. Returned by create and update: the resulting entity\ntogether with the OPA governance result. Metrics are not a governed entity type, so\n`governance` is always present with `status: NONE` and empty `details` (no policy\nevaluation occurs); the envelope is kept for response-shape consistency with other v4\nresources.\n","required":["entity","governance"],"properties":{"entity":{"$ref":"#/components/schemas/Metric"},"governance":{"allOf":[{"$ref":"#/components/schemas/GovernanceResult"}],"description":"OPA governance result for the mutation. For metrics this is always `{ \"status\": \"NONE\",\n\"details\": [] }` — `METRIC` is not a governed entity type, so no policy evaluation\noccurs. Present (never `null`) for response-shape consistency with other v4 resources.\n"}}},"Metric":{"type":"object","description":"A project-scoped Metric definition, returned by GET, LIST, and inside the mutation\nenvelope. Some fields are read-only (`metricSourceId`, `customFieldFilters`).\n","required":["type","id","name","trafficType","format","aggregation","isPositive","createdAt","status","baseEventTypes","tags","owners"],"properties":{"type":{"type":"string","enum":["METRIC"],"description":"Resource type discriminator. Always `METRIC`."},"id":{"type":"string","format":"uuid","description":"Unique system-assigned identifier for the metric. Use this as the path parameter in subsequent requests."},"name":{"type":"string","description":"Unique metric name within the project."},"description":{"type":"string","nullable":true,"description":"Human-readable description of this metric."},"trafficType":{"allOf":[{"$ref":"#/components/schemas/ReferenceObject"}],"description":"Reference to the traffic type this metric measures (`type` is `TRAFFIC_TYPE`)."},"format":{"type":"string","enum":["NUMBER","DOLLAR","PERCENTAGE","SECONDS","MILLISECONDS","BYTES"],"description":"Display/measurement format of the metric value."},"aggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"description":"How individual event values are aggregated per unit."},"isPositive":{"type":"boolean","description":"`true` when an increase in this metric is a good outcome."},"spread":{"type":"string","enum":["PER","ACROSS"],"description":"Whether the metric is computed per-unit or across the population. Always present on read."},"baseEventTypes":{"type":"array","description":"The base event type(s) this metric measures. At least one.","items":{"$ref":"#/components/schemas/BaseEventType"}},"filterEventType":{"allOf":[{"$ref":"#/components/schemas/FilterEventType"}],"type":"object","nullable":true,"description":"Optional filter/trigger event that scopes which units are counted."},"triggerEventType":{"allOf":[{"$ref":"#/components/schemas/TriggerEventType"}],"type":"object","nullable":true,"description":"Optional trigger event (HAS_DONE_BEFORE): the unit must have done this event before the\nbase event for it to be counted.\n"},"tags":{"type":"array","description":"Tags associated with this metric (each `type` is `TAG`).","items":{"$ref":"#/components/schemas/ReferenceObject"}},"owners":{"type":"array","description":"Users or groups that own this metric. `USER` owners include `email`; `GROUP` owners do not.","items":{"$ref":"#/components/schemas/OwnerReference"}},"metricSourceId":{"type":"string","format":"uuid","nullable":true,"readOnly":true,"description":"Warehouse-native metric source this metric reads from, when applicable."},"customFieldFilters":{"type":"object","nullable":true,"readOnly":true,"description":"Warehouse-native custom-field filters."},"cap":{"allOf":[{"$ref":"#/components/schemas/MetricCap"}],"type":"object","nullable":true,"description":"Outlier/cap configuration. `null` (or all-zero fields) means no cap is applied."},"createdAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was created."},"modifiedAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was last modified."},"status":{"type":"string","enum":["ACTIVE","ARCHIVED"],"description":"Lifecycle status of the metric. New metrics are always `ACTIVE`, and `DELETE` removes a\nmetric permanently rather than changing its status (see the delete endpoint). `ARCHIVED`\nis a legacy value that may still appear on metrics created before archiving was replaced\nby hard delete; this API never transitions a metric to `ARCHIVED`.\n"}}},"ReferenceObject":{"type":"object","description":"Generic reference to another resource, returned in responses. `id` is the stable\npublic identifier, `type` disambiguates the referenced entity kind, and `name` is the\nhuman-readable label.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the referenced resource."},"type":{"type":"string","description":"The kind of entity this reference points to (for example `TRAFFIC_TYPE`, `TAG`,\n`USER`, `GROUP`, `ROLLOUT_STATUS`, `FEATURE_FLAG`, `ENVIRONMENT`, or `SEGMENT`).\nEach resource API returns only the kinds relevant to that API.\n"},"name":{"type":"string","description":"Human-readable name of the referenced resource."}}},"OwnerReference":{"type":"object","description":"Reference to an owner (user or group), returned in responses. Extends the generic reference\nwith an optional `email`: a `USER` owner MAY carry `email` where the resource populates it;\na `GROUP` owner never has one. Use `id` for subsequent API calls; `name`/`email` are\ninformational (they let clients that keyed on a user's email at write time correlate the\nresponse without a lookup). Shared across FME v4 resources that expose owners.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the owner — the Harness user id (for `USER`) or group id (for `GROUP`)."},"type":{"type":"string","enum":["USER","GROUP"],"description":"Owner kind."},"name":{"type":"string","description":"Human-readable display name of the user or group."},"email":{"type":"string","format":"email","nullable":true,"description":"Email address of the owner. Optionally populated for `USER` owners where the resource\nsupports it; `null`/absent for `GROUP` owners and for resources that do not return it.\n"}}},"GovernanceResult":{"type":"object","description":"OPA policy evaluation result for the operation. `PASS`, `WARNING`, and `ERROR` mean\ngovernance ran; `NONE` means governance was not evaluated (for example off or not linked).\n","required":["status","details"],"properties":{"status":{"type":"string","enum":["PASS","WARNING","ERROR","NONE"],"description":"Overall governance result. `NONE` when governance did not run; otherwise the aggregate\nacross evaluated policies.\n"},"details":{"type":"array","description":"Per-policy results. Empty array when all policies pass cleanly or when status is `NONE`.","items":{"$ref":"#/components/schemas/GovernancePolicyDetail"}}}},"GovernancePolicyDetail":{"type":"object","description":"Per-policy OPA evaluation result.","required":["policyName","status","message"],"properties":{"policyName":{"type":"string","description":"Name of the OPA policy that was evaluated."},"status":{"type":"string","enum":["PASS","WARNING","ERROR"],"description":"Result of evaluating this specific policy."},"message":{"type":"string","description":"Human-readable explanation of the policy result."}}},"ErrorResponse":{"type":"object","description":"Standard error response following RFC 7807 Problem Details format (Harness ADR 57).\n","required":["type","status","title","errorType"],"properties":{"type":{"type":"string","format":"uri","description":"URI reference to documentation for this error type."},"status":{"type":"integer","description":"HTTP status code."},"title":{"type":"string","description":"Short human-readable summary of the problem."},"errorType":{"type":"string","description":"Machine-readable error type identifier."},"detail":{"type":"string","description":"Detailed human-readable explanation specific to this occurrence."},"instance":{"type":"string","description":"URI reference identifying the specific occurrence (usually the request path)."},"errors":{"type":"array","description":"List of specific sub-errors (useful for multi-field validation failures). Governance\npolicy failures are also surfaced here — each failing policy is reported as an entry\nwith `errorType: \"governancePolicy\"` — rather than in a separate top-level field.\n","items":{"$ref":"#/components/schemas/ErrorDetail"}}}},"ErrorDetail":{"type":"object","description":"Details about a single sub-error.","required":["errorType","title"],"properties":{"errorType":{"type":"string","description":"Machine-readable error type for this specific error."},"title":{"type":"string","description":"Short summary of this specific error."},"detail":{"type":"string","description":"Detailed explanation of this specific error."},"field":{"type":"string","description":"Name of the request field this error applies to, when the error is field-specific\n(for example a validation failure). Omitted for errors not tied to a single field.\n"}}}},"responses":{"BadRequest":{"description":"Bad Request — validation errors or invalid state transition.\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Unauthorized":{"description":"Unauthorized — the request is missing a valid API key, or the key has expired.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Forbidden — the caller is authenticated but not permitted to perform this operation.\nReturned when the API can deny the operation without leaking whether a resource exists,\nsuch as create, or write operations where the caller can already read the resource. When\nreturning `403` would reveal resource existence, the API returns `404` instead.\n\nEnvironment-scoped mutations that require approval also return `403`.\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"MetricConflict":{"description":"Conflict — the metric collides with an existing one. Two distinct causes are reported via\nthe RFC 7807 `errorType`:\n- `resourceAlreadyExists` — another metric already uses this `name`.\n- `duplicateDefinition` — a different-named metric with an equivalent definition already\n  exists (metrics are de-duplicated by definition, not only by name).\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"TooManyRequests":{"description":"Too Many Requests — the caller has exceeded the rate limit for this endpoint.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"Internal Server Error — an unexpected error occurred while processing the request.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v4/metrics":{"post":{"tags":["Metrics"],"operationId":"createMetric","summary":"Create a Metric","description":"Creates a new Metric in the specified project workspace. The metric name must be unique\nwithin the project and is immutable after creation.\n\n**Validation (beyond what the request schema enforces):** a `filterEventType` may not target\nthe same event type as any `baseEventTypes` entry **unless** their property filters differ;\nan exact overlap is rejected with `400` (`errorType: filterEventMatchesBaseEvent`).\n","parameters":[{"$ref":"#/components/parameters/AccountId"},{"$ref":"#/components/parameters/OrganizationIdentifier"},{"$ref":"#/components/parameters/ProjectIdentifier"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateMetricRequest"}}}},"responses":{"201":{"description":"Created — the metric was successfully created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/MetricConflict"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```

## Get a Metric

> Returns a single Metric by its system-assigned identifier. A deleted metric is removed\
> permanently, so a \`GET\` for one returns \`404\`.<br>

```json
{"openapi":"3.0.3","info":{"title":"Harness Feature Management & Experimentation API","version":"4.0.0"},"tags":[{"name":"Metrics","description":"Manage project-scoped metric definitions (create, list, get, update, delete)."}],"servers":[{"url":"https://app.harness.io/fme/api","description":"Harness SaaS (production)"},{"url":"https://app3.harness.io/fme/api","description":"Harness SaaS (US-3)"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Harness Service Account Token (SAT) or Personal Access Token (PAT).\nGenerate tokens in Harness under Account Settings → Access Management.\n"}},"parameters":{"MetricIdPath":{"name":"metric-id","in":"path","required":true,"description":"The system-assigned identifier (UUID) of the metric.","schema":{"type":"string","format":"uuid"}},"AccountId":{"name":"account_id","in":"query","required":true,"description":"Harness account identifier. Required on all endpoints.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"OrganizationIdentifier":{"name":"organization_identifier","in":"query","required":true,"description":"Harness organization identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"ProjectIdentifier":{"name":"project_identifier","in":"query","required":true,"description":"Harness project identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}}},"schemas":{"Metric":{"type":"object","description":"A project-scoped Metric definition, returned by GET, LIST, and inside the mutation\nenvelope. Some fields are read-only (`metricSourceId`, `customFieldFilters`).\n","required":["type","id","name","trafficType","format","aggregation","isPositive","createdAt","status","baseEventTypes","tags","owners"],"properties":{"type":{"type":"string","enum":["METRIC"],"description":"Resource type discriminator. Always `METRIC`."},"id":{"type":"string","format":"uuid","description":"Unique system-assigned identifier for the metric. Use this as the path parameter in subsequent requests."},"name":{"type":"string","description":"Unique metric name within the project."},"description":{"type":"string","nullable":true,"description":"Human-readable description of this metric."},"trafficType":{"allOf":[{"$ref":"#/components/schemas/ReferenceObject"}],"description":"Reference to the traffic type this metric measures (`type` is `TRAFFIC_TYPE`)."},"format":{"type":"string","enum":["NUMBER","DOLLAR","PERCENTAGE","SECONDS","MILLISECONDS","BYTES"],"description":"Display/measurement format of the metric value."},"aggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"description":"How individual event values are aggregated per unit."},"isPositive":{"type":"boolean","description":"`true` when an increase in this metric is a good outcome."},"spread":{"type":"string","enum":["PER","ACROSS"],"description":"Whether the metric is computed per-unit or across the population. Always present on read."},"baseEventTypes":{"type":"array","description":"The base event type(s) this metric measures. At least one.","items":{"$ref":"#/components/schemas/BaseEventType"}},"filterEventType":{"allOf":[{"$ref":"#/components/schemas/FilterEventType"}],"type":"object","nullable":true,"description":"Optional filter/trigger event that scopes which units are counted."},"triggerEventType":{"allOf":[{"$ref":"#/components/schemas/TriggerEventType"}],"type":"object","nullable":true,"description":"Optional trigger event (HAS_DONE_BEFORE): the unit must have done this event before the\nbase event for it to be counted.\n"},"tags":{"type":"array","description":"Tags associated with this metric (each `type` is `TAG`).","items":{"$ref":"#/components/schemas/ReferenceObject"}},"owners":{"type":"array","description":"Users or groups that own this metric. `USER` owners include `email`; `GROUP` owners do not.","items":{"$ref":"#/components/schemas/OwnerReference"}},"metricSourceId":{"type":"string","format":"uuid","nullable":true,"readOnly":true,"description":"Warehouse-native metric source this metric reads from, when applicable."},"customFieldFilters":{"type":"object","nullable":true,"readOnly":true,"description":"Warehouse-native custom-field filters."},"cap":{"allOf":[{"$ref":"#/components/schemas/MetricCap"}],"type":"object","nullable":true,"description":"Outlier/cap configuration. `null` (or all-zero fields) means no cap is applied."},"createdAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was created."},"modifiedAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was last modified."},"status":{"type":"string","enum":["ACTIVE","ARCHIVED"],"description":"Lifecycle status of the metric. New metrics are always `ACTIVE`, and `DELETE` removes a\nmetric permanently rather than changing its status (see the delete endpoint). `ARCHIVED`\nis a legacy value that may still appear on metrics created before archiving was replaced\nby hard delete; this API never transitions a metric to `ARCHIVED`.\n"}}},"ReferenceObject":{"type":"object","description":"Generic reference to another resource, returned in responses. `id` is the stable\npublic identifier, `type` disambiguates the referenced entity kind, and `name` is the\nhuman-readable label.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the referenced resource."},"type":{"type":"string","description":"The kind of entity this reference points to (for example `TRAFFIC_TYPE`, `TAG`,\n`USER`, `GROUP`, `ROLLOUT_STATUS`, `FEATURE_FLAG`, `ENVIRONMENT`, or `SEGMENT`).\nEach resource API returns only the kinds relevant to that API.\n"},"name":{"type":"string","description":"Human-readable name of the referenced resource."}}},"BaseEventType":{"type":"object","description":"A base event type the metric measures, with optional per-event property filters.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the event type."},"propertyFilters":{"type":"array","description":"Optional property filters applied to this base event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}},"propertyForValue":{"type":"string","nullable":true,"description":"Event property whose value is measured (for value-based aggregations)."}}},"EventPropertyFilter":{"type":"object","description":"A filter on an event property. The operand field must match the `operator` (validated\nserver-side; a mismatch is rejected with `400`, `errorType: operatorOperandMismatch`):\n- scalar operators (`EQUAL`, `GREATER_THAN`, `LESS_THAN`, `STRING_EQUAL`, `CONTAINS`,\n  `STARTS_WITH`, `BOOLEAN_EQUAL`) use `secondOperand`;\n- `STRING_IN_LIST` uses `stringInListOperand` (non-empty);\n- `BETWEEN` uses `numberRangeOperand` as exactly two values `[lower, upper]`.\n","required":["property","operator"],"properties":{"property":{"type":"string","description":"The event property to filter on."},"operator":{"type":"string","enum":["EQUAL","GREATER_THAN","LESS_THAN","BETWEEN","STRING_EQUAL","CONTAINS","STARTS_WITH","STRING_IN_LIST","BOOLEAN_EQUAL"],"description":"Comparison operator."},"inverted":{"type":"boolean","description":"When `true`, the operator is negated (e.g. NOT EQUAL).","default":false},"secondOperand":{"type":"string","nullable":true,"description":"Single-value operand (for scalar operators)."},"stringInListOperand":{"type":"array","nullable":true,"minItems":1,"description":"Operand for the list operator (`STRING_IN_LIST`). Required and non-empty for that operator.","items":{"type":"string"}},"numberRangeOperand":{"type":"array","nullable":true,"minItems":2,"maxItems":2,"description":"Operand for the range operator (`BETWEEN`) — exactly two values, `[lower, upper]`.","items":{"type":"number","format":"double"}}}},"FilterEventType":{"type":"object","description":"A filter/trigger event that scopes which units the metric counts.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the filter/trigger event type."},"filterAggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"nullable":true,"description":"Aggregation applied to the filter event."},"propertyFilters":{"type":"array","description":"Optional property filters applied to the filter event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}}}},"TriggerEventType":{"type":"object","description":"A trigger event (HAS_DONE_BEFORE): the unit must have done this event before the base event.\nUnlike `FilterEventType`, a trigger event has no aggregation or property filters.\n","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the trigger event type."}}},"OwnerReference":{"type":"object","description":"Reference to an owner (user or group), returned in responses. Extends the generic reference\nwith an optional `email`: a `USER` owner MAY carry `email` where the resource populates it;\na `GROUP` owner never has one. Use `id` for subsequent API calls; `name`/`email` are\ninformational (they let clients that keyed on a user's email at write time correlate the\nresponse without a lookup). Shared across FME v4 resources that expose owners.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the owner — the Harness user id (for `USER`) or group id (for `GROUP`)."},"type":{"type":"string","enum":["USER","GROUP"],"description":"Owner kind."},"name":{"type":"string","description":"Human-readable display name of the user or group."},"email":{"type":"string","format":"email","nullable":true,"description":"Email address of the owner. Optionally populated for `USER` owners where the resource\nsupports it; `null`/absent for `GROUP` owners and for resources that do not return it.\n"}}},"MetricCap":{"type":"object","description":"Optional outlier/cap configuration. Each field bounds a specific measured quantity when the\nmetric is computed; a field value of `0` (the default) means that cap is not applied, so any\nfield may be omitted. In practice only the field matching the metric's `aggregation` is\nmeaningful — setting caps that don't correspond to the aggregation has no effect rather than\nbeing rejected. `granularity` is the time window the caps apply over.\n","properties":{"baseEventCountCap":{"type":"number","format":"double","description":"Upper bound on the base-event count. `0` = no cap."},"baseEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed base-event value. `0` = no cap."},"baseEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual base-event value. `0` = no cap."},"filterEventCountCap":{"type":"number","format":"double","description":"Upper bound on the filter-event count. `0` = no cap."},"filterEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed filter-event value. `0` = no cap."},"filterEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual filter-event value. `0` = no cap."},"metricValueCap":{"type":"number","format":"double","description":"Upper bound on the final per-unit metric value. `0` = no cap."},"granularity":{"type":"string","enum":["MINUTES","HOURS","DAYS","WEEKS"],"default":"DAYS","description":"Time window the caps apply over."}}},"ErrorResponse":{"type":"object","description":"Standard error response following RFC 7807 Problem Details format (Harness ADR 57).\n","required":["type","status","title","errorType"],"properties":{"type":{"type":"string","format":"uri","description":"URI reference to documentation for this error type."},"status":{"type":"integer","description":"HTTP status code."},"title":{"type":"string","description":"Short human-readable summary of the problem."},"errorType":{"type":"string","description":"Machine-readable error type identifier."},"detail":{"type":"string","description":"Detailed human-readable explanation specific to this occurrence."},"instance":{"type":"string","description":"URI reference identifying the specific occurrence (usually the request path)."},"errors":{"type":"array","description":"List of specific sub-errors (useful for multi-field validation failures). Governance\npolicy failures are also surfaced here — each failing policy is reported as an entry\nwith `errorType: \"governancePolicy\"` — rather than in a separate top-level field.\n","items":{"$ref":"#/components/schemas/ErrorDetail"}}}},"ErrorDetail":{"type":"object","description":"Details about a single sub-error.","required":["errorType","title"],"properties":{"errorType":{"type":"string","description":"Machine-readable error type for this specific error."},"title":{"type":"string","description":"Short summary of this specific error."},"detail":{"type":"string","description":"Detailed explanation of this specific error."},"field":{"type":"string","description":"Name of the request field this error applies to, when the error is field-specific\n(for example a validation failure). Omitted for errors not tied to a single field.\n"}}}},"responses":{"Unauthorized":{"description":"Unauthorized — the request is missing a valid API key, or the key has expired.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"Not Found — the requested resource does not exist. Also returned when the caller lacks\naccess to the resource (to avoid leaking resource existence).\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"TooManyRequests":{"description":"Too Many Requests — the caller has exceeded the rate limit for this endpoint.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"Internal Server Error — an unexpected error occurred while processing the request.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v4/metrics/{metric-id}":{"get":{"tags":["Metrics"],"operationId":"getMetric","summary":"Get a Metric","description":"Returns a single Metric by its system-assigned identifier. A deleted metric is removed\npermanently, so a `GET` for one returns `404`.\n","parameters":[{"$ref":"#/components/parameters/MetricIdPath"},{"$ref":"#/components/parameters/AccountId"},{"$ref":"#/components/parameters/OrganizationIdentifier"},{"$ref":"#/components/parameters/ProjectIdentifier"}],"responses":{"200":{"description":"OK — metric returned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Metric"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```

## Delete a Metric

> Permanently deletes a Metric. This is a hard delete — the metric is removed, is not\
> recoverable, and afterward a \`GET\` by id returns \`404\` and it no longer appears in \`LIST\`.\
> There is no archive or restore. Any references to the metric (for example from experiments'\
> key-metric lists) are cleaned up as part of the delete.<br>

```json
{"openapi":"3.0.3","info":{"title":"Harness Feature Management & Experimentation API","version":"4.0.0"},"tags":[{"name":"Metrics","description":"Manage project-scoped metric definitions (create, list, get, update, delete)."}],"servers":[{"url":"https://app.harness.io/fme/api","description":"Harness SaaS (production)"},{"url":"https://app3.harness.io/fme/api","description":"Harness SaaS (US-3)"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Harness Service Account Token (SAT) or Personal Access Token (PAT).\nGenerate tokens in Harness under Account Settings → Access Management.\n"}},"parameters":{"MetricIdPath":{"name":"metric-id","in":"path","required":true,"description":"The system-assigned identifier (UUID) of the metric.","schema":{"type":"string","format":"uuid"}},"AccountId":{"name":"account_id","in":"query","required":true,"description":"Harness account identifier. Required on all endpoints.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"OrganizationIdentifier":{"name":"organization_identifier","in":"query","required":true,"description":"Harness organization identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"ProjectIdentifier":{"name":"project_identifier","in":"query","required":true,"description":"Harness project identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}}},"schemas":{"DeleteResponse":{"type":"object","description":"Response envelope for delete operations. Contains only the OPA governance result — no\nentity is returned. Shared by all FME resources so delete responses are consistent.\n","required":["governance"],"properties":{"governance":{"allOf":[{"$ref":"#/components/schemas/GovernanceResult"}],"description":"OPA governance result for the delete operation."}}},"GovernanceResult":{"type":"object","description":"OPA policy evaluation result for the operation. `PASS`, `WARNING`, and `ERROR` mean\ngovernance ran; `NONE` means governance was not evaluated (for example off or not linked).\n","required":["status","details"],"properties":{"status":{"type":"string","enum":["PASS","WARNING","ERROR","NONE"],"description":"Overall governance result. `NONE` when governance did not run; otherwise the aggregate\nacross evaluated policies.\n"},"details":{"type":"array","description":"Per-policy results. Empty array when all policies pass cleanly or when status is `NONE`.","items":{"$ref":"#/components/schemas/GovernancePolicyDetail"}}}},"GovernancePolicyDetail":{"type":"object","description":"Per-policy OPA evaluation result.","required":["policyName","status","message"],"properties":{"policyName":{"type":"string","description":"Name of the OPA policy that was evaluated."},"status":{"type":"string","enum":["PASS","WARNING","ERROR"],"description":"Result of evaluating this specific policy."},"message":{"type":"string","description":"Human-readable explanation of the policy result."}}},"ErrorResponse":{"type":"object","description":"Standard error response following RFC 7807 Problem Details format (Harness ADR 57).\n","required":["type","status","title","errorType"],"properties":{"type":{"type":"string","format":"uri","description":"URI reference to documentation for this error type."},"status":{"type":"integer","description":"HTTP status code."},"title":{"type":"string","description":"Short human-readable summary of the problem."},"errorType":{"type":"string","description":"Machine-readable error type identifier."},"detail":{"type":"string","description":"Detailed human-readable explanation specific to this occurrence."},"instance":{"type":"string","description":"URI reference identifying the specific occurrence (usually the request path)."},"errors":{"type":"array","description":"List of specific sub-errors (useful for multi-field validation failures). Governance\npolicy failures are also surfaced here — each failing policy is reported as an entry\nwith `errorType: \"governancePolicy\"` — rather than in a separate top-level field.\n","items":{"$ref":"#/components/schemas/ErrorDetail"}}}},"ErrorDetail":{"type":"object","description":"Details about a single sub-error.","required":["errorType","title"],"properties":{"errorType":{"type":"string","description":"Machine-readable error type for this specific error."},"title":{"type":"string","description":"Short summary of this specific error."},"detail":{"type":"string","description":"Detailed explanation of this specific error."},"field":{"type":"string","description":"Name of the request field this error applies to, when the error is field-specific\n(for example a validation failure). Omitted for errors not tied to a single field.\n"}}}},"responses":{"Unauthorized":{"description":"Unauthorized — the request is missing a valid API key, or the key has expired.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Forbidden — the caller is authenticated but not permitted to perform this operation.\nReturned when the API can deny the operation without leaking whether a resource exists,\nsuch as create, or write operations where the caller can already read the resource. When\nreturning `403` would reveal resource existence, the API returns `404` instead.\n\nEnvironment-scoped mutations that require approval also return `403`.\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"Not Found — the requested resource does not exist. Also returned when the caller lacks\naccess to the resource (to avoid leaking resource existence).\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"TooManyRequests":{"description":"Too Many Requests — the caller has exceeded the rate limit for this endpoint.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"Internal Server Error — an unexpected error occurred while processing the request.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v4/metrics/{metric-id}":{"delete":{"tags":["Metrics"],"operationId":"deleteMetric","summary":"Delete a Metric","description":"Permanently deletes a Metric. This is a hard delete — the metric is removed, is not\nrecoverable, and afterward a `GET` by id returns `404` and it no longer appears in `LIST`.\nThere is no archive or restore. Any references to the metric (for example from experiments'\nkey-metric lists) are cleaned up as part of the delete.\n","parameters":[{"$ref":"#/components/parameters/MetricIdPath"},{"$ref":"#/components/parameters/AccountId"},{"$ref":"#/components/parameters/OrganizationIdentifier"},{"$ref":"#/components/parameters/ProjectIdentifier"}],"responses":{"200":{"description":"OK — metric permanently deleted. Returns the governance result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```

## Update a Metric (partial)

> Partially updates a Metric using JSON Merge Patch (RFC 7386,\
> \`Content-Type: application/merge-patch+json\`). Fields omitted from the body are left\
> unchanged; sending \`null\` clears a nullable field. Arrays (\`baseEventTypes\`, \`tags\`,\
> \`owners\`) are replaced in full — there is no element-level merge, so to add or remove one\
> entry, send the complete list. \`name\` and \`trafficType\` are immutable.\
> \
> Because array fields are replaced in full and the input shapes differ from the rich objects\
> returned on read, appending to an array means re-sending the existing entries in \*\*input\*\*\
> shape: \`tags\` as \`{ name }\` (from each tag's \`name\`), \`owners\` as \`{ type, id | email }\` for\
> users or \`{ type, identifier }\` for groups (from each owner's \`id\`/\`identifier\`). Example — a\
> metric that returns \`tags: \[{ type, id, name: "checkout" }]\`, adding \`q3\`:\
> \`{ "tags": \[ { "name": "checkout" }, { "name": "q3" } ] }\`.\
> \
> Updatable fields: \`description\`, \`format\`, \`aggregation\`, \`isPositive\`, \`spread\`,\
> \`baseEventTypes\`, \`filterEventType\`, \`triggerEventType\`, \`tags\`, \`owners\`, \`cap\`.\
> \
> \*\*Validation (beyond what the request schema enforces):\*\* a \`filterEventType\` may not target\
> the same event type as any \`baseEventTypes\` entry \*\*unless\*\* their property filters differ;\
> an exact overlap is rejected with \`400\` (\`errorType: filterEventMatchesBaseEvent\`).<br>

```json
{"openapi":"3.0.3","info":{"title":"Harness Feature Management & Experimentation API","version":"4.0.0"},"tags":[{"name":"Metrics","description":"Manage project-scoped metric definitions (create, list, get, update, delete)."}],"servers":[{"url":"https://app.harness.io/fme/api","description":"Harness SaaS (production)"},{"url":"https://app3.harness.io/fme/api","description":"Harness SaaS (US-3)"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Harness Service Account Token (SAT) or Personal Access Token (PAT).\nGenerate tokens in Harness under Account Settings → Access Management.\n"}},"parameters":{"MetricIdPath":{"name":"metric-id","in":"path","required":true,"description":"The system-assigned identifier (UUID) of the metric.","schema":{"type":"string","format":"uuid"}},"AccountId":{"name":"account_id","in":"query","required":true,"description":"Harness account identifier. Required on all endpoints.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"OrganizationIdentifier":{"name":"organization_identifier","in":"query","required":true,"description":"Harness organization identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}},"ProjectIdentifier":{"name":"project_identifier","in":"query","required":true,"description":"Harness project identifier.","schema":{"type":"string","pattern":"^[-_A-Za-z0-9]+$","maxLength":128}}},"schemas":{"UpdateMetricRequest":{"type":"object","description":"JSON Merge Patch body (RFC 7386) for updating a Metric. Omitted fields are unchanged; `null`\nclears a nullable field; array fields are replaced in full. See the endpoint description for\nmerge semantics and how to append to an array.\n","properties":{"description":{"type":"string","nullable":true,"description":"Updated description. `null` clears it."},"format":{"type":"string","enum":["NUMBER","DOLLAR","PERCENTAGE","SECONDS","MILLISECONDS","BYTES"],"description":"Updated format. Required field — cannot be set to `null`."},"aggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"description":"Updated aggregation. Required field — cannot be set to `null`."},"isPositive":{"type":"boolean","description":"Updated direction. Required field — cannot be set to `null`."},"spread":{"type":"string","enum":["PER","ACROSS"],"description":"Updated spread. Can be changed between `PER` and `ACROSS`, but cannot be cleared — a\nmetric always has a spread, so `null` is not accepted.\n"},"baseEventTypes":{"type":"array","minItems":1,"description":"Replacement base-event list (full replacement — each element must be complete; there is\nno element-level merge). At least one element.\n","items":{"$ref":"#/components/schemas/BaseEventType"}},"filterEventType":{"allOf":[{"$ref":"#/components/schemas/FilterEventType"}],"type":"object","nullable":true,"description":"Replacement filter event, or `null` to clear."},"triggerEventType":{"allOf":[{"$ref":"#/components/schemas/TriggerEventType"}],"type":"object","nullable":true,"description":"Replacement trigger event (HAS_DONE_BEFORE), or `null` to clear."},"tags":{"type":"array","nullable":true,"description":"Replacement tag list (full replacement), using the shared `TagReferenceInput` (`{ name }`).\n`null` or `[]` clears all tags. Tags are returned as full `{ type, id, name }` refs on read.\n","items":{"$ref":"#/components/schemas/TagReferenceInput"}},"owners":{"type":"array","nullable":true,"description":"Replacement owner list (full replacement), using the shared `OwnerReferenceInput`\n(`{ type: USER, id | email }` or `{ type: GROUP, identifier }`). `null` or `[]` clears all\nowners. Owners are returned as full `{ type, id, name, email }` refs on read (`email` for\nusers only).\n","items":{"$ref":"#/components/schemas/OwnerReferenceInput"}},"cap":{"allOf":[{"$ref":"#/components/schemas/MetricCap"}],"type":"object","nullable":true,"description":"Replacement cap configuration, or `null` to clear it (reset to no cap). Set the field\nmatching the metric's `aggregation`; the others stay `0`.\n"}}},"BaseEventType":{"type":"object","description":"A base event type the metric measures, with optional per-event property filters.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the event type."},"propertyFilters":{"type":"array","description":"Optional property filters applied to this base event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}},"propertyForValue":{"type":"string","nullable":true,"description":"Event property whose value is measured (for value-based aggregations)."}}},"EventPropertyFilter":{"type":"object","description":"A filter on an event property. The operand field must match the `operator` (validated\nserver-side; a mismatch is rejected with `400`, `errorType: operatorOperandMismatch`):\n- scalar operators (`EQUAL`, `GREATER_THAN`, `LESS_THAN`, `STRING_EQUAL`, `CONTAINS`,\n  `STARTS_WITH`, `BOOLEAN_EQUAL`) use `secondOperand`;\n- `STRING_IN_LIST` uses `stringInListOperand` (non-empty);\n- `BETWEEN` uses `numberRangeOperand` as exactly two values `[lower, upper]`.\n","required":["property","operator"],"properties":{"property":{"type":"string","description":"The event property to filter on."},"operator":{"type":"string","enum":["EQUAL","GREATER_THAN","LESS_THAN","BETWEEN","STRING_EQUAL","CONTAINS","STARTS_WITH","STRING_IN_LIST","BOOLEAN_EQUAL"],"description":"Comparison operator."},"inverted":{"type":"boolean","description":"When `true`, the operator is negated (e.g. NOT EQUAL).","default":false},"secondOperand":{"type":"string","nullable":true,"description":"Single-value operand (for scalar operators)."},"stringInListOperand":{"type":"array","nullable":true,"minItems":1,"description":"Operand for the list operator (`STRING_IN_LIST`). Required and non-empty for that operator.","items":{"type":"string"}},"numberRangeOperand":{"type":"array","nullable":true,"minItems":2,"maxItems":2,"description":"Operand for the range operator (`BETWEEN`) — exactly two values, `[lower, upper]`.","items":{"type":"number","format":"double"}}}},"FilterEventType":{"type":"object","description":"A filter/trigger event that scopes which units the metric counts.","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the filter/trigger event type."},"filterAggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"nullable":true,"description":"Aggregation applied to the filter event."},"propertyFilters":{"type":"array","description":"Optional property filters applied to the filter event.","items":{"$ref":"#/components/schemas/EventPropertyFilter"}}}},"TriggerEventType":{"type":"object","description":"A trigger event (HAS_DONE_BEFORE): the unit must have done this event before the base event.\nUnlike `FilterEventType`, a trigger event has no aggregation or property filters.\n","required":["eventTypeId"],"properties":{"eventTypeId":{"type":"string","description":"Identifier of the trigger event type."}}},"TagReferenceInput":{"type":"object","description":"Tag input used in request bodies. Identified by `name`.","required":["name"],"properties":{"name":{"type":"string","description":"Tag name."}}},"OwnerReferenceInput":{"oneOf":[{"$ref":"#/components/schemas/UserOwnerReferenceInput"},{"$ref":"#/components/schemas/GroupOwnerReferenceInput"}],"discriminator":{"propertyName":"type","mapping":{"USER":"#/components/schemas/UserOwnerReferenceInput","GROUP":"#/components/schemas/GroupOwnerReferenceInput"}},"description":"Owner input. Use `USER` for users and `GROUP` for groups."},"UserOwnerReferenceInput":{"type":"object","description":"User owner input. Prefer `email`; `id` is also accepted for compatibility when the caller\nalready has the Harness user id.\n","required":["type"],"anyOf":[{"required":["email"]},{"required":["id"]}],"properties":{"type":{"type":"string","enum":["USER"],"description":"Owner type discriminator. Always `USER`."},"id":{"type":"string","description":"Harness user id."},"email":{"type":"string","format":"email","description":"User email address."}}},"GroupOwnerReferenceInput":{"type":"object","description":"Group owner input.","required":["type","identifier"],"properties":{"type":{"type":"string","enum":["GROUP"],"description":"Owner type discriminator. Always `GROUP`."},"identifier":{"type":"string","description":"Group identifier."}}},"MetricCap":{"type":"object","description":"Optional outlier/cap configuration. Each field bounds a specific measured quantity when the\nmetric is computed; a field value of `0` (the default) means that cap is not applied, so any\nfield may be omitted. In practice only the field matching the metric's `aggregation` is\nmeaningful — setting caps that don't correspond to the aggregation has no effect rather than\nbeing rejected. `granularity` is the time window the caps apply over.\n","properties":{"baseEventCountCap":{"type":"number","format":"double","description":"Upper bound on the base-event count. `0` = no cap."},"baseEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed base-event value. `0` = no cap."},"baseEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual base-event value. `0` = no cap."},"filterEventCountCap":{"type":"number","format":"double","description":"Upper bound on the filter-event count. `0` = no cap."},"filterEventSumCap":{"type":"number","format":"double","description":"Upper bound on the summed filter-event value. `0` = no cap."},"filterEventValueCap":{"type":"number","format":"double","description":"Upper bound on an individual filter-event value. `0` = no cap."},"metricValueCap":{"type":"number","format":"double","description":"Upper bound on the final per-unit metric value. `0` = no cap."},"granularity":{"type":"string","enum":["MINUTES","HOURS","DAYS","WEEKS"],"default":"DAYS","description":"Time window the caps apply over."}}},"MetricResponse":{"type":"object","description":"Metric mutation response envelope. Returned by create and update: the resulting entity\ntogether with the OPA governance result. Metrics are not a governed entity type, so\n`governance` is always present with `status: NONE` and empty `details` (no policy\nevaluation occurs); the envelope is kept for response-shape consistency with other v4\nresources.\n","required":["entity","governance"],"properties":{"entity":{"$ref":"#/components/schemas/Metric"},"governance":{"allOf":[{"$ref":"#/components/schemas/GovernanceResult"}],"description":"OPA governance result for the mutation. For metrics this is always `{ \"status\": \"NONE\",\n\"details\": [] }` — `METRIC` is not a governed entity type, so no policy evaluation\noccurs. Present (never `null`) for response-shape consistency with other v4 resources.\n"}}},"Metric":{"type":"object","description":"A project-scoped Metric definition, returned by GET, LIST, and inside the mutation\nenvelope. Some fields are read-only (`metricSourceId`, `customFieldFilters`).\n","required":["type","id","name","trafficType","format","aggregation","isPositive","createdAt","status","baseEventTypes","tags","owners"],"properties":{"type":{"type":"string","enum":["METRIC"],"description":"Resource type discriminator. Always `METRIC`."},"id":{"type":"string","format":"uuid","description":"Unique system-assigned identifier for the metric. Use this as the path parameter in subsequent requests."},"name":{"type":"string","description":"Unique metric name within the project."},"description":{"type":"string","nullable":true,"description":"Human-readable description of this metric."},"trafficType":{"allOf":[{"$ref":"#/components/schemas/ReferenceObject"}],"description":"Reference to the traffic type this metric measures (`type` is `TRAFFIC_TYPE`)."},"format":{"type":"string","enum":["NUMBER","DOLLAR","PERCENTAGE","SECONDS","MILLISECONDS","BYTES"],"description":"Display/measurement format of the metric value."},"aggregation":{"type":"string","enum":["TOTAL","COUNT","RATE","AVERAGE","NONE"],"description":"How individual event values are aggregated per unit."},"isPositive":{"type":"boolean","description":"`true` when an increase in this metric is a good outcome."},"spread":{"type":"string","enum":["PER","ACROSS"],"description":"Whether the metric is computed per-unit or across the population. Always present on read."},"baseEventTypes":{"type":"array","description":"The base event type(s) this metric measures. At least one.","items":{"$ref":"#/components/schemas/BaseEventType"}},"filterEventType":{"allOf":[{"$ref":"#/components/schemas/FilterEventType"}],"type":"object","nullable":true,"description":"Optional filter/trigger event that scopes which units are counted."},"triggerEventType":{"allOf":[{"$ref":"#/components/schemas/TriggerEventType"}],"type":"object","nullable":true,"description":"Optional trigger event (HAS_DONE_BEFORE): the unit must have done this event before the\nbase event for it to be counted.\n"},"tags":{"type":"array","description":"Tags associated with this metric (each `type` is `TAG`).","items":{"$ref":"#/components/schemas/ReferenceObject"}},"owners":{"type":"array","description":"Users or groups that own this metric. `USER` owners include `email`; `GROUP` owners do not.","items":{"$ref":"#/components/schemas/OwnerReference"}},"metricSourceId":{"type":"string","format":"uuid","nullable":true,"readOnly":true,"description":"Warehouse-native metric source this metric reads from, when applicable."},"customFieldFilters":{"type":"object","nullable":true,"readOnly":true,"description":"Warehouse-native custom-field filters."},"cap":{"allOf":[{"$ref":"#/components/schemas/MetricCap"}],"type":"object","nullable":true,"description":"Outlier/cap configuration. `null` (or all-zero fields) means no cap is applied."},"createdAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was created."},"modifiedAt":{"type":"string","format":"date-time","description":"ISO-8601 timestamp when the metric was last modified."},"status":{"type":"string","enum":["ACTIVE","ARCHIVED"],"description":"Lifecycle status of the metric. New metrics are always `ACTIVE`, and `DELETE` removes a\nmetric permanently rather than changing its status (see the delete endpoint). `ARCHIVED`\nis a legacy value that may still appear on metrics created before archiving was replaced\nby hard delete; this API never transitions a metric to `ARCHIVED`.\n"}}},"ReferenceObject":{"type":"object","description":"Generic reference to another resource, returned in responses. `id` is the stable\npublic identifier, `type` disambiguates the referenced entity kind, and `name` is the\nhuman-readable label.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the referenced resource."},"type":{"type":"string","description":"The kind of entity this reference points to (for example `TRAFFIC_TYPE`, `TAG`,\n`USER`, `GROUP`, `ROLLOUT_STATUS`, `FEATURE_FLAG`, `ENVIRONMENT`, or `SEGMENT`).\nEach resource API returns only the kinds relevant to that API.\n"},"name":{"type":"string","description":"Human-readable name of the referenced resource."}}},"OwnerReference":{"type":"object","description":"Reference to an owner (user or group), returned in responses. Extends the generic reference\nwith an optional `email`: a `USER` owner MAY carry `email` where the resource populates it;\na `GROUP` owner never has one. Use `id` for subsequent API calls; `name`/`email` are\ninformational (they let clients that keyed on a user's email at write time correlate the\nresponse without a lookup). Shared across FME v4 resources that expose owners.\n","required":["id","type","name"],"properties":{"id":{"type":"string","description":"Identifier of the owner — the Harness user id (for `USER`) or group id (for `GROUP`)."},"type":{"type":"string","enum":["USER","GROUP"],"description":"Owner kind."},"name":{"type":"string","description":"Human-readable display name of the user or group."},"email":{"type":"string","format":"email","nullable":true,"description":"Email address of the owner. Optionally populated for `USER` owners where the resource\nsupports it; `null`/absent for `GROUP` owners and for resources that do not return it.\n"}}},"GovernanceResult":{"type":"object","description":"OPA policy evaluation result for the operation. `PASS`, `WARNING`, and `ERROR` mean\ngovernance ran; `NONE` means governance was not evaluated (for example off or not linked).\n","required":["status","details"],"properties":{"status":{"type":"string","enum":["PASS","WARNING","ERROR","NONE"],"description":"Overall governance result. `NONE` when governance did not run; otherwise the aggregate\nacross evaluated policies.\n"},"details":{"type":"array","description":"Per-policy results. Empty array when all policies pass cleanly or when status is `NONE`.","items":{"$ref":"#/components/schemas/GovernancePolicyDetail"}}}},"GovernancePolicyDetail":{"type":"object","description":"Per-policy OPA evaluation result.","required":["policyName","status","message"],"properties":{"policyName":{"type":"string","description":"Name of the OPA policy that was evaluated."},"status":{"type":"string","enum":["PASS","WARNING","ERROR"],"description":"Result of evaluating this specific policy."},"message":{"type":"string","description":"Human-readable explanation of the policy result."}}},"ErrorResponse":{"type":"object","description":"Standard error response following RFC 7807 Problem Details format (Harness ADR 57).\n","required":["type","status","title","errorType"],"properties":{"type":{"type":"string","format":"uri","description":"URI reference to documentation for this error type."},"status":{"type":"integer","description":"HTTP status code."},"title":{"type":"string","description":"Short human-readable summary of the problem."},"errorType":{"type":"string","description":"Machine-readable error type identifier."},"detail":{"type":"string","description":"Detailed human-readable explanation specific to this occurrence."},"instance":{"type":"string","description":"URI reference identifying the specific occurrence (usually the request path)."},"errors":{"type":"array","description":"List of specific sub-errors (useful for multi-field validation failures). Governance\npolicy failures are also surfaced here — each failing policy is reported as an entry\nwith `errorType: \"governancePolicy\"` — rather than in a separate top-level field.\n","items":{"$ref":"#/components/schemas/ErrorDetail"}}}},"ErrorDetail":{"type":"object","description":"Details about a single sub-error.","required":["errorType","title"],"properties":{"errorType":{"type":"string","description":"Machine-readable error type for this specific error."},"title":{"type":"string","description":"Short summary of this specific error."},"detail":{"type":"string","description":"Detailed explanation of this specific error."},"field":{"type":"string","description":"Name of the request field this error applies to, when the error is field-specific\n(for example a validation failure). Omitted for errors not tied to a single field.\n"}}}},"responses":{"BadRequest":{"description":"Bad Request — validation errors or invalid state transition.\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Unauthorized":{"description":"Unauthorized — the request is missing a valid API key, or the key has expired.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Forbidden — the caller is authenticated but not permitted to perform this operation.\nReturned when the API can deny the operation without leaking whether a resource exists,\nsuch as create, or write operations where the caller can already read the resource. When\nreturning `403` would reveal resource existence, the API returns `404` instead.\n\nEnvironment-scoped mutations that require approval also return `403`.\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"Not Found — the requested resource does not exist. Also returned when the caller lacks\naccess to the resource (to avoid leaking resource existence).\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"MetricConflict":{"description":"Conflict — the metric collides with an existing one. Two distinct causes are reported via\nthe RFC 7807 `errorType`:\n- `resourceAlreadyExists` — another metric already uses this `name`.\n- `duplicateDefinition` — a different-named metric with an equivalent definition already\n  exists (metrics are de-duplicated by definition, not only by name).\n","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"TooManyRequests":{"description":"Too Many Requests — the caller has exceeded the rate limit for this endpoint.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"Internal Server Error — an unexpected error occurred while processing the request.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v4/metrics/{metric-id}":{"patch":{"tags":["Metrics"],"operationId":"updateMetric","summary":"Update a Metric (partial)","description":"Partially updates a Metric using JSON Merge Patch (RFC 7386,\n`Content-Type: application/merge-patch+json`). Fields omitted from the body are left\nunchanged; sending `null` clears a nullable field. Arrays (`baseEventTypes`, `tags`,\n`owners`) are replaced in full — there is no element-level merge, so to add or remove one\nentry, send the complete list. `name` and `trafficType` are immutable.\n\nBecause array fields are replaced in full and the input shapes differ from the rich objects\nreturned on read, appending to an array means re-sending the existing entries in **input**\nshape: `tags` as `{ name }` (from each tag's `name`), `owners` as `{ type, id | email }` for\nusers or `{ type, identifier }` for groups (from each owner's `id`/`identifier`). Example — a\nmetric that returns `tags: [{ type, id, name: \"checkout\" }]`, adding `q3`:\n`{ \"tags\": [ { \"name\": \"checkout\" }, { \"name\": \"q3\" } ] }`.\n\nUpdatable fields: `description`, `format`, `aggregation`, `isPositive`, `spread`,\n`baseEventTypes`, `filterEventType`, `triggerEventType`, `tags`, `owners`, `cap`.\n\n**Validation (beyond what the request schema enforces):** a `filterEventType` may not target\nthe same event type as any `baseEventTypes` entry **unless** their property filters differ;\nan exact overlap is rejected with `400` (`errorType: filterEventMatchesBaseEvent`).\n","parameters":[{"$ref":"#/components/parameters/MetricIdPath"},{"$ref":"#/components/parameters/AccountId"},{"$ref":"#/components/parameters/OrganizationIdentifier"},{"$ref":"#/components/parameters/ProjectIdentifier"}],"requestBody":{"required":true,"content":{"application/merge-patch+json":{"schema":{"$ref":"#/components/schemas/UpdateMetricRequest"}}}},"responses":{"200":{"description":"OK — metric updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/MetricConflict"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```
