For the complete documentation index, see llms.txt. This page is also available as Markdown.

Metrics

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

List Metrics

get
/v4/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.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
limitinteger · min: 1 · max: 100Optional

Number of items to return per page. Defaults to 100, maximum 100.

Default: 100Example: 100
offsetintegerOptional

Number of items to skip before the first returned result. Defaults to 0.

Default: 0Example: 0
namestringOptional

Case-insensitive substring match on metric name.

traffic_type_idstringOptional

Filter to metrics of the given traffic type (by id).

event_type_idsstring[]Optional

Filter to metrics that measure any of the given event types (matched against the metric's baseEventTypes[].eventTypeId). Repeat the parameter to pass multiple.

tagsstring[]Optional

Filter to metrics that have any of the specified tags (by tag name).

idsstring · uuid[]Optional

Filter to the specified metric ids.

sort_orderstring · enumOptional

Sort direction by name.

Default: ASCENDINGPossible values:
Responses
200

OK — paginated list of metrics returned.

application/json

Paginated list of Metrics matching the query.

limitintegerRequired

The page size used for this response.

offsetintegerRequired

The number of items skipped before the first result.

totalCountintegerRequired

Total number of metrics matching the query.

get/v4/metrics
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
}

Create a Metric

post
/v4/metrics

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).

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Body

Request body for creating a new Metric.

namestring · min: 1 · max: 100Required

Unique metric name within the project. Immutable after creation.

Example: checkout-conversionPattern: ^[A-Za-z][-_A-Za-z0-9]*$
descriptionstringOptional

Human-readable description of this metric.

Example: Conversion rate for the new checkout flow
trafficTypestringRequired

Traffic type this metric measures, identified by its name (for example user or account). Immutable after creation.

Example: user
formatstring · enumRequiredPossible values:
aggregationstring · enumRequiredPossible values:
isPositivebooleanRequired

true when an increase in this metric is a good outcome.

spreadstring · enumOptional

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).

Possible values:
Responses
201

Created — the metric was successfully created.

application/json

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.

post/v4/metrics
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": []
  }
}

Get a Metric

get
/v4/metrics/{metric-id}

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

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
metric-idstring · uuidRequired

The system-assigned identifier (UUID) of the metric.

Example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Responses
200

OK — metric returned.

application/json

A project-scoped Metric definition, returned by GET, LIST, and inside the mutation envelope. Some fields are read-only (metricSourceId, customFieldFilters).

typestring · enumRequired

Resource type discriminator. Always METRIC.

Possible values:
idstring · uuidRequired

Unique system-assigned identifier for the metric. Use this as the path parameter in subsequent requests.

namestringRequired

Unique metric name within the project.

Example: checkout-conversion
descriptionstring · nullableOptional

Human-readable description of this metric.

Example: Conversion rate for the new checkout flow
formatstring · enumRequired

Display/measurement format of the metric value.

Possible values:
aggregationstring · enumRequired

How individual event values are aggregated per unit.

Possible values:
isPositivebooleanRequired

true when an increase in this metric is a good outcome.

spreadstring · enumOptional

Whether the metric is computed per-unit or across the population. Always present on read.

Possible values:
metricSourceIdstring · uuid · nullableRead-onlyOptional

Warehouse-native metric source this metric reads from, when applicable.

customFieldFiltersobject · nullableRead-onlyOptional

Warehouse-native custom-field filters.

createdAtstring · date-timeRequired

ISO-8601 timestamp when the metric was created.

Example: 2025-06-01T12:00:00Z
modifiedAtstring · date-timeOptional

ISO-8601 timestamp when the metric was last modified.

Example: 2025-06-02T09:30:00Z
statusstring · enumRequired

Lifecycle 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.

Possible values:
get/v4/metrics/{metric-id}
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"
}

Delete a Metric

delete
/v4/metrics/{metric-id}

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.

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
metric-idstring · uuidRequired

The system-assigned identifier (UUID) of the metric.

Example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Responses
200

OK — metric permanently deleted. Returns the governance result.

application/json

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.

delete/v4/metrics/{metric-id}
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": []
  }
}

Update a Metric (partial)

patch
/v4/metrics/{metric-id}

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).

Authorizations
x-api-keystringRequired

Harness Service Account Token (SAT) or Personal Access Token (PAT). Generate tokens in Harness under Account Settings → Access Management.

Path parameters
metric-idstring · uuidRequired

The system-assigned identifier (UUID) of the metric.

Example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
Query parameters
account_idstring · max: 128Required

Harness account identifier. Required on all endpoints.

Example: {{accountId}}Pattern: ^[-_A-Za-z0-9]+$
organization_identifierstring · max: 128Required

Harness organization identifier.

Example: defaultPattern: ^[-_A-Za-z0-9]+$
project_identifierstring · max: 128Required

Harness project identifier.

Example: my_projectPattern: ^[-_A-Za-z0-9]+$
Body

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.

descriptionstring · nullableOptional

Updated description. null clears it.

Example: Updated metric description
formatstring · enumOptional

Updated format. Required field — cannot be set to null.

Possible values:
aggregationstring · enumOptional

Updated aggregation. Required field — cannot be set to null.

Possible values:
isPositivebooleanOptional

Updated direction. Required field — cannot be set to null.

spreadstring · enumOptional

Updated spread. Can be changed between PER and ACROSS, but cannot be cleared — a metric always has a spread, so null is not accepted.

Possible values:
Responses
200

OK — metric updated.

application/json

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.

patch/v4/metrics/{metric-id}
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?