---
title: Update rules
slug: monitor/update-rules
docTags: 
createdAt: 2025-04-16T07:33:21.765Z
---

:::ApiMethodV2
```json
{
  "name": "Update rules",
  "method": "PUT",
  "url": "https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules",
  "description": "Update the rules set of monitor",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "HqgiwH9MEZFpD-2JOJlOe",
        "language": "curl",
        "code": "curl --location --globoff --request PUT 'https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}' \\\n--header 'Authorization: string' \\\n--data '{\n    \"rule\":\n    {\n        \"relation\": \"and\",\n        \"children\":\n        [\n            {\n                \"field\": \"BALANCE_INCREASE\",\n                \"value\": 12,\n                \"operator\": \">=\"\n            },\n            {\n                \"field\": \"BALANCE_AMOUNT\",\n                \"value\": 12,\n                \"operator\": \">=\"\n            }\n        ]\n    }\n}'",
        "customLabel": ""
      },
      {
        "id": "RANiaspyuryuPrJADdtVf",
        "language": "nodejs",
        "code": "var request = require('request');\nvar options = {\n   'method': 'PUT',\n   'url': 'https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}',\n   'headers': {\n      'Authorization': 'string'\n   },\n   body: '{\"rules\":\"Array\"}'\n\n};\nrequest(options, function (error, response) {\n   if (error) throw new Error(error);\n   console.log(response.body);\n});\n",
        "customLabel": ""
      },
      {
        "id": "xP70f0iV11MzC9Ks9yKqF",
        "language": "javascript",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Authorization\", \"string\");\n\nvar raw = \"{\\\"rules\\\":\\\"Array\\\"}\";\n\nvar requestOptions = {\n   method: 'PUT',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));",
        "customLabel": ""
      },
      {
        "id": "kjskNYXziBqchsTdNG9RJ",
        "language": "python",
        "code": "import requests\n\nurl = \"https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}\"\n\npayload = \"{\\\"rules\\\":\\\"Array\\\"}\"\nheaders = {\n   'Authorization': 'string'\n}\n\nresponse = requests.request(\"PUT\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "customLabel": ""
      },
      {
        "id": "SW8NNjbsN-fN_nXi7E2Y3",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Put.new(url)\nrequest[\"Authorization\"] = \"string\"\nrequest.body = \"{\\\"rules\\\":\\\"Array\\\"}\"\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      },
      {
        "id": "f-__eLTkhaP_XtzNg5nfT",
        "language": "curl",
        "code": "curl --location --globoff --request PUT 'https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}' \\\n--header 'Authorization: string' \\\n--data '{\"rules\":{\"type\":\"String\",\"value\":\"Number\"}}'",
        "customLabel": ""
      },
      {
        "id": "gJuS9qtq0OiNJvFl0ClYd",
        "language": "nodejs",
        "code": "var request = require('request');\nvar options = {\n   'method': 'PUT',\n   'url': 'https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}',\n   'headers': {\n      'Authorization': 'string'\n   },\n   body: '{\"rules\":{\"type\":\"String\",\"value\":\"Number\"}}'\n\n};\nrequest(options, function (error, response) {\n   if (error) throw new Error(error);\n   console.log(response.body);\n});\n",
        "customLabel": ""
      },
      {
        "id": "jWryJd6yiClFBqiBqM4aR",
        "language": "javascript",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Authorization\", \"string\");\n\nvar raw = \"{\\\"rules\\\":{\\\"type\\\":\\\"String\\\",\\\"value\\\":\\\"Number\\\"}}\";\n\nvar requestOptions = {\n   method: 'PUT',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));",
        "customLabel": ""
      },
      {
        "id": "4SqYmJspqDVolFYmFCv6o",
        "language": "python",
        "code": "import requests\n\nurl = \"https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}\"\n\npayload = \"{\\\"rules\\\":{\\\"type\\\":\\\"String\\\",\\\"value\\\":\\\"Number\\\"}}\"\nheaders = {\n   'Authorization': 'string'\n}\n\nresponse = requests.request(\"PUT\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "customLabel": ""
      },
      {
        "id": "Bo-NFIpBqgV4YKozrA3bK",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api-sandbox.klavi.ai/monitor/v1/monitors/{id}/rules/{id}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Put.new(url)\nrequest[\"Authorization\"] = \"string\"\nrequest.body = \"{\\\"rules\\\":{\\\"type\\\":\\\"String\\\",\\\"value\\\":\\\"Number\\\"}}\"\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "HqgiwH9MEZFpD-2JOJlOe"
  },
  "results": {
    "languages": [
      {
        "id": "iiztZ4zh7mDqLHfGvCaUG",
        "language": "200",
        "customLabel": "",
        "code": "{\n\t\"message\": \"ok\"\n}"
      }
    ],
    "selectedLanguageId": "iiztZ4zh7mDqLHfGvCaUG"
  },
  "request": {
    "pathParameters": [
      {
        "name": "id",
        "kind": "required",
        "type": "string",
        "description": "ID of the monitor",
        "": "ID of the monitor"
      }
    ],
    "queryParameters": [],
    "headerParameters": [
      {
        "name": "Authorization",
        "kind": "required",
        "type": "string",
        "description": "Bearer access token, it returned by the /auth",
        "": "Bearer access token, it returned by the /auth"
      }
    ],
    "bodyDataParameters": [
      {
        "name": "rule",
        "kind": "required",
        "type": "object",
        "description": "Monitor rule",
        "": "Monitor rule",
        "children": [
          {
            "name": "relation",
            "kind": "required",
            "type": "string",
            "description": "The elements in the list currently only support and"
          },
          {
            "name": "children",
            "kind": "required",
            "type": "array",
            "description": "Field List",
            "children": [
              {
                "name": "Parameter name",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ]
          }
        ],
        "schema": [
          {
            "name": "relation",
            "kind": "required",
            "type": "string",
            "description": "The elements in the list currently only support and"
          },
          {
            "name": "children",
            "kind": "required",
            "type": "array",
            "description": "Field List",
            "children": [
              {
                "name": "Parameter name",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ]
          }
        ]
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false
}
```
:::

# Parameter

## children

### field

Currently only supports monitoring balance related indicators, including: BALANCE\_AMOUNT and BALANCE\_INCREASE.&#x20;

### operator

Comparison operator, currently only supports >=,  !=.

### value

Amount, numeric type.



## rule

| field             | operator | value                                                                                                                       |
| ----------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| BALANCE\_AMOUNT   | >=,  !=  | If operator is equal to >=, then value can only be a number. <br />If operator is equal to !=, then value can only be null. |
| BALANCE\_INCREASE | >=       | Only numbers.                                                                                                               |



::::ExpandableHeading{isOpen="true"}
# Body example

## Single Field

```json
{
    "rule":
    {
        "relation": "and",
        "children":
        [
            {
                "field": "BALANCE_INCREASE",
                "value": 12,
                "operator": ">="
            }
        ]
    }
}
```



## Multiple Fields

```json
{
    "rule":
    {
        "relation": "and",
        "children":
        [
            {
                "field": "BALANCE_INCREASE",
                "value": 12,
                "operator": ">="
            },
            {
                "field": "BALANCE_AMOUNT",
                "value": 12,
                "operator": ">="
            }
        ]
    }
}
```

:::hint{type="info"}
**Operators**

The application supports the relational operators:  !=, >=,.
:::


::::

