---
source_url: https://www.pubnub.com/docs/admin-api/update-metric
title: Update metric
---

# Update metric

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

Updates an existing metric.

> **Warning:** All associated decisions must be deactivated before updating a metric. The API rejects updates if any referencing decision has `enabled: true`.

> **Note:** Changing the `function` type may require adding or removing `measureId`. For example, switching from `COUNT` to `AVG` requires adding a `measureId` referencing a `NUMERIC` field.

### Field behavior on PUT

| Field | PUT behavior |
| --- | --- |
| `filters[].id` | **Required** for existing filters — omit only for new filters being added |
| `measureId` | Include if function requires it; omit if switching to `COUNT`/`COUNT_DISTINCT` |

## Request

Example

```
{
  "id": "string",
  "name": "string",
  "measureId": "string",
  "businessObjectId": "string",
  "evaluationWindow": 0,
  "function": "string",
  "dimensionIds": [
    "string"
  ],
  "dimensions": [
    {
      "id": "string",
      "name": "string",
      "jsonPath": "string",
      "jsonFieldType": "TEXT",
      "isKeyset": false,
      "source": "JSONPATH",
      "derivation": {
        "operation": "TIME_DIFF",
        "params": {}
      }
    }
  ],
  "filters": [
    {
      "id": "string",
      "sourceType": "MEASURE",
      "sourceId": "string",
      "operation": "NUMERIC_GREATER_THAN",
      "arguments": [
        "string"
      ]
    }
  ],
  "businessObject": {
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-01T00:00:00.000Z",
    "createdBy": "string",
    "updatedBy": "string",
    "id": "string",
    "name": "string",
    "isActive": false,
    "description": "string",
    "fields": [
      {
        "id": "string",
        "name": "string",
        "jsonPath": "string",
        "jsonFieldType": "TEXT",
        "isKeyset": false,
        "source": "JSONPATH",
        "derivation": {}
      }
    ],
    "accountId": "string",
    "subkeys": [
      "string"
    ],
    "metrics": [],
    "decisions": [
      {
        "createdAt": "2024-01-01T00:00:00.000Z",
        "updatedAt": "2024-01-01T00:00:00.000Z",
        "createdBy": "string",
        "updatedBy": "string",
        "id": "string",
        "name": "string",
        "description": "string",
        "accountId": "string",
        "businessObjectId": "string",
        "sourceType": "BUSINESSOBJECT",
        "sourceId": "string",
        "hitType": "SINGLE",
        "enabled": false,
        "activeFrom": "2024-01-01T00:00:00.000Z",
        "activeUntil": "2024-01-01T00:00:00.000Z",
        "executeOnce": false,
        "executionFrequency": 0,
        "inputFields": [],
        "outputFields": [],
        "rules": [],
        "actions": [],
        "query": {},
        "customer": {}
      }
    ],
    "dashboards": [
      {
        "createdAt": "2024-01-01T00:00:00.000Z",
        "updatedAt": "2024-01-01T00:00:00.000Z",
        "createdBy": "string",
        "updatedBy": "string",
        "id": "string",
        "name": "string",
        "accountId": "string",
        "dateRange": "30 minutes",
        "startDate": "2024-01-01T00:00:00.000Z",
        "endDate": "2024-01-01T00:00:00.000Z",
        "charts": [],
        "customer": {}
      }
    ],
    "queries": [
      {
        "createdAt": "2024-01-01T00:00:00.000Z",
        "updatedAt": "2024-01-01T00:00:00.000Z",
        "createdBy": "string",
        "updatedBy": "string",
        "decisions": [],
        "customer": {},
        "businessObjects": [],
        "id": "string",
        "name": "string",
        "description": "string",
        "definition": {},
        "template": "string",
        "accountId": "string"
      }
    ],
    "customers": [
      {
        "id": "string",
        "name": "string"
      }
    ]
  }
}
```
