Metrics
Manage project-scoped metric definitions (create, list, get, update, delete).
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.
Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.
Harness account identifier. Required on all endpoints.
{{accountId}}Pattern: ^[-_A-Za-z0-9]+$Harness organization identifier.
defaultPattern: ^[-_A-Za-z0-9]+$Harness project identifier.
my_projectPattern: ^[-_A-Za-z0-9]+$Number of items to return per page. Defaults to 100, maximum 100.
100Example: 100Number of items to skip before the first returned result. Defaults to 0.
0Example: 0Case-insensitive substring match on metric name.
Filter to metrics of the given traffic type (by id).
Filter to metrics that measure any of the given event types (matched against the
metric's baseEventTypes[].eventTypeId). Repeat the parameter to pass multiple.
Filter to metrics that have any of the specified tags (by tag name).
Filter to the specified metric ids.
Sort direction by name.
ASCENDINGPossible values: OK — paginated list of metrics returned.
Paginated list of Metrics matching the query.
The page size used for this response.
The number of items skipped before the first result.
Total number of metrics matching the query.
Bad Request — validation errors or invalid state transition.
Unauthorized — the request is missing a valid API key, or the key has expired.
Forbidden — the caller is authenticated but not permitted to perform this operation.
Returned when the API can deny the operation without leaking whether a resource exists,
such as create, or write operations where the caller can already read the resource. When
returning 403 would reveal resource existence, the API returns 404 instead.
Environment-scoped mutations that require approval also return 403.
Too Many Requests — the caller has exceeded the rate limit for this endpoint.
Internal Server Error — an unexpected error occurred while processing the request.
GET /fme/api/v4/metrics?account_id={{accountId}}&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Accept: */*
{
"data": [
{
"type": "METRIC",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "checkout-conversion",
"description": "Conversion rate for the new checkout flow",
"trafficType": {
"id": "ad2eb8f0-9c3a-11ed-873c-e234abaad323",
"type": "TRAFFIC_TYPE",
"name": "user"
},
"format": "PERCENTAGE",
"aggregation": "COUNT",
"isPositive": true,
"spread": "PER",
"baseEventTypes": [
{
"eventTypeId": "checkout_completed",
"propertyFilters": [],
"propertyForValue": null
}
],
"filterEventType": null,
"triggerEventType": null,
"tags": [
{
"id": "checkout",
"type": "TAG",
"name": "checkout"
}
],
"owners": [
{
"id": "user-1",
"type": "USER",
"name": "Alice Example",
"email": "alice@example.com"
}
],
"metricSourceId": null,
"customFieldFilters": null,
"cap": null,
"createdAt": "2025-06-01T12:00:00Z",
"modifiedAt": "2025-06-02T09:30:00Z",
"status": "ACTIVE"
}
],
"limit": 1,
"offset": 1,
"totalCount": 1
}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).
Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.
Harness account identifier. Required on all endpoints.
{{accountId}}Pattern: ^[-_A-Za-z0-9]+$Harness organization identifier.
defaultPattern: ^[-_A-Za-z0-9]+$Harness project identifier.
my_projectPattern: ^[-_A-Za-z0-9]+$Request body for creating a new Metric.
Unique metric name within the project. Immutable after creation.
checkout-conversionPattern: ^[A-Za-z][-_A-Za-z0-9]*$Human-readable description of this metric.
Conversion rate for the new checkout flowTraffic type this metric measures, identified by its name (for example user or
account). Immutable after creation.
usertrue when an increase in this metric is a good outcome.
Whether the metric is computed per-unit or across the population. Optional — defaults to
PER when omitted (matching the current UI, which always sends PER).
Created — the metric was successfully created.
Metric mutation response envelope. Returned by create and update: the resulting entity
together with the OPA governance result. Metrics are not a governed entity type, so
governance is always present with status: NONE and empty details (no policy
evaluation occurs); the envelope is kept for response-shape consistency with other v4
resources.
Bad Request — validation errors or invalid state transition.
Unauthorized — the request is missing a valid API key, or the key has expired.
Forbidden — the caller is authenticated but not permitted to perform this operation.
Returned when the API can deny the operation without leaking whether a resource exists,
such as create, or write operations where the caller can already read the resource. When
returning 403 would reveal resource existence, the API returns 404 instead.
Environment-scoped mutations that require approval also return 403.
Conflict — the metric collides with an existing one. Two distinct causes are reported via
the RFC 7807 errorType:
resourceAlreadyExists— another metric already uses thisname.duplicateDefinition— a different-named metric with an equivalent definition already exists (metrics are de-duplicated by definition, not only by name).
Too Many Requests — the caller has exceeded the rate limit for this endpoint.
Internal Server Error — an unexpected error occurred while processing the request.
POST /fme/api/v4/metrics?account_id={{accountId}}&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 347
{
"name": "checkout-conversion",
"description": "Conversion rate for the new checkout flow",
"trafficType": "user",
"format": "PERCENTAGE",
"aggregation": "COUNT",
"isPositive": true,
"spread": "PER",
"baseEventTypes": [
{
"eventTypeId": "checkout_completed",
"propertyFilters": []
}
],
"tags": [
{
"name": "checkout"
}
],
"owners": [
{
"type": "USER",
"email": "alice@example.com"
}
]
}{
"entity": {
"type": "METRIC",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "checkout-conversion",
"description": "Conversion rate for the new checkout flow",
"trafficType": {
"id": "ad2eb8f0-9c3a-11ed-873c-e234abaad323",
"type": "TRAFFIC_TYPE",
"name": "user"
},
"format": "PERCENTAGE",
"aggregation": "COUNT",
"isPositive": true,
"spread": "PER",
"baseEventTypes": [
{
"eventTypeId": "checkout_completed",
"propertyFilters": [],
"propertyForValue": null
}
],
"filterEventType": null,
"triggerEventType": null,
"tags": [
{
"id": "checkout",
"type": "TAG",
"name": "checkout"
}
],
"owners": [
{
"id": "user-1",
"type": "USER",
"name": "Alice Example",
"email": "alice@example.com"
}
],
"metricSourceId": null,
"customFieldFilters": null,
"cap": null,
"createdAt": "2025-06-01T12:00:00Z",
"modifiedAt": "2025-06-02T09:30:00Z",
"status": "ACTIVE"
},
"governance": {
"status": "PASS",
"details": []
}
}Returns a single Metric by its system-assigned identifier. A deleted metric is removed permanently, so a GET for one returns 404.
Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.
The system-assigned identifier (UUID) of the metric.
a1b2c3d4-e5f6-7890-abcd-ef1234567890Harness account identifier. Required on all endpoints.
{{accountId}}Pattern: ^[-_A-Za-z0-9]+$Harness organization identifier.
defaultPattern: ^[-_A-Za-z0-9]+$Harness project identifier.
my_projectPattern: ^[-_A-Za-z0-9]+$OK — metric returned.
A project-scoped Metric definition, returned by GET, LIST, and inside the mutation
envelope. Some fields are read-only (metricSourceId, customFieldFilters).
Resource type discriminator. Always METRIC.
Unique system-assigned identifier for the metric. Use this as the path parameter in subsequent requests.
Unique metric name within the project.
checkout-conversionHuman-readable description of this metric.
Conversion rate for the new checkout flowDisplay/measurement format of the metric value.
How individual event values are aggregated per unit.
true when an increase in this metric is a good outcome.
Whether the metric is computed per-unit or across the population. Always present on read.
Warehouse-native metric source this metric reads from, when applicable.
Warehouse-native custom-field filters.
ISO-8601 timestamp when the metric was created.
2025-06-01T12:00:00ZISO-8601 timestamp when the metric was last modified.
2025-06-02T09:30:00ZLifecycle status of the metric. New metrics are always ACTIVE, and DELETE removes a
metric permanently rather than changing its status (see the delete endpoint). ARCHIVED
is a legacy value that may still appear on metrics created before archiving was replaced
by hard delete; this API never transitions a metric to ARCHIVED.
Unauthorized — the request is missing a valid API key, or the key has expired.
Not Found — the requested resource does not exist. Also returned when the caller lacks access to the resource (to avoid leaking resource existence).
Too Many Requests — the caller has exceeded the rate limit for this endpoint.
Internal Server Error — an unexpected error occurred while processing the request.
GET /fme/api/v4/metrics/{metric-id}?account_id={{accountId}}&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Accept: */*
{
"type": "METRIC",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "checkout-conversion",
"description": "Conversion rate for the new checkout flow",
"trafficType": {
"id": "ad2eb8f0-9c3a-11ed-873c-e234abaad323",
"type": "TRAFFIC_TYPE",
"name": "user"
},
"format": "PERCENTAGE",
"aggregation": "COUNT",
"isPositive": true,
"spread": "PER",
"baseEventTypes": [
{
"eventTypeId": "checkout_completed",
"propertyFilters": [],
"propertyForValue": null
}
],
"filterEventType": null,
"triggerEventType": null,
"tags": [
{
"id": "checkout",
"type": "TAG",
"name": "checkout"
}
],
"owners": [
{
"id": "user-1",
"type": "USER",
"name": "Alice Example",
"email": "alice@example.com"
}
],
"metricSourceId": null,
"customFieldFilters": null,
"cap": null,
"createdAt": "2025-06-01T12:00:00Z",
"modifiedAt": "2025-06-02T09:30:00Z",
"status": "ACTIVE"
}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.
Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.
The system-assigned identifier (UUID) of the metric.
a1b2c3d4-e5f6-7890-abcd-ef1234567890Harness account identifier. Required on all endpoints.
{{accountId}}Pattern: ^[-_A-Za-z0-9]+$Harness organization identifier.
defaultPattern: ^[-_A-Za-z0-9]+$Harness project identifier.
my_projectPattern: ^[-_A-Za-z0-9]+$OK — metric permanently deleted. Returns the governance result.
Response envelope for delete operations. Contains only the OPA governance result — no entity is returned. Shared by all FME resources so delete responses are consistent.
Unauthorized — the request is missing a valid API key, or the key has expired.
Forbidden — the caller is authenticated but not permitted to perform this operation.
Returned when the API can deny the operation without leaking whether a resource exists,
such as create, or write operations where the caller can already read the resource. When
returning 403 would reveal resource existence, the API returns 404 instead.
Environment-scoped mutations that require approval also return 403.
Not Found — the requested resource does not exist. Also returned when the caller lacks access to the resource (to avoid leaking resource existence).
Too Many Requests — the caller has exceeded the rate limit for this endpoint.
Internal Server Error — an unexpected error occurred while processing the request.
DELETE /fme/api/v4/metrics/{metric-id}?account_id={{accountId}}&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Accept: */*
{
"governance": {
"status": "PASS",
"details": []
}
}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).
Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.
The system-assigned identifier (UUID) of the metric.
a1b2c3d4-e5f6-7890-abcd-ef1234567890Harness account identifier. Required on all endpoints.
{{accountId}}Pattern: ^[-_A-Za-z0-9]+$Harness organization identifier.
defaultPattern: ^[-_A-Za-z0-9]+$Harness project identifier.
my_projectPattern: ^[-_A-Za-z0-9]+$JSON Merge Patch body (RFC 7386) for updating a Metric. Omitted fields are unchanged; null
clears a nullable field; array fields are replaced in full. See the endpoint description for
merge semantics and how to append to an array.
Updated description. null clears it.
Updated metric descriptionUpdated format. Required field — cannot be set to null.
Updated aggregation. Required field — cannot be set to null.
Updated direction. Required field — cannot be set to null.
Updated spread. Can be changed between PER and ACROSS, but cannot be cleared — a
metric always has a spread, so null is not accepted.
OK — metric updated.
Metric mutation response envelope. Returned by create and update: the resulting entity
together with the OPA governance result. Metrics are not a governed entity type, so
governance is always present with status: NONE and empty details (no policy
evaluation occurs); the envelope is kept for response-shape consistency with other v4
resources.
Bad Request — validation errors or invalid state transition.
Unauthorized — the request is missing a valid API key, or the key has expired.
Forbidden — the caller is authenticated but not permitted to perform this operation.
Returned when the API can deny the operation without leaking whether a resource exists,
such as create, or write operations where the caller can already read the resource. When
returning 403 would reveal resource existence, the API returns 404 instead.
Environment-scoped mutations that require approval also return 403.
Not Found — the requested resource does not exist. Also returned when the caller lacks access to the resource (to avoid leaking resource existence).
Conflict — the metric collides with an existing one. Two distinct causes are reported via
the RFC 7807 errorType:
resourceAlreadyExists— another metric already uses thisname.duplicateDefinition— a different-named metric with an equivalent definition already exists (metrics are de-duplicated by definition, not only by name).
Too Many Requests — the caller has exceeded the rate limit for this endpoint.
Internal Server Error — an unexpected error occurred while processing the request.
PATCH /fme/api/v4/metrics/{metric-id}?account_id={{accountId}}&organization_identifier=default&project_identifier=my_project HTTP/1.1
Host: app.harness.io
x-api-key: YOUR_API_KEY
Content-Type: application/merge-patch+json
Accept: */*
Content-Length: 144
{
"description": "Updated metric description",
"tags": [
{
"name": "checkout"
},
{
"name": "q3"
}
],
"owners": [
{
"type": "GROUP",
"identifier": "platform-team"
}
]
}{
"entity": {
"type": "METRIC",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "checkout-conversion",
"description": "Conversion rate for the new checkout flow",
"trafficType": {
"id": "ad2eb8f0-9c3a-11ed-873c-e234abaad323",
"type": "TRAFFIC_TYPE",
"name": "user"
},
"format": "PERCENTAGE",
"aggregation": "COUNT",
"isPositive": true,
"spread": "PER",
"baseEventTypes": [
{
"eventTypeId": "checkout_completed",
"propertyFilters": [],
"propertyForValue": null
}
],
"filterEventType": null,
"triggerEventType": null,
"tags": [
{
"id": "checkout",
"type": "TAG",
"name": "checkout"
}
],
"owners": [
{
"id": "user-1",
"type": "USER",
"name": "Alice Example",
"email": "alice@example.com"
}
],
"metricSourceId": null,
"customFieldFilters": null,
"cap": null,
"createdAt": "2025-06-01T12:00:00Z",
"modifiedAt": "2025-06-02T09:30:00Z",
"status": "ACTIVE"
},
"governance": {
"status": "PASS",
"details": []
}
}Last updated
Was this helpful?