{
  "openapi": "3.1.0",
  "info": {
    "title": "Flashduty Open API",
    "description": "Public HTTP API for the Flashduty incident management platform — incidents, notification templates, channels, schedules, monitors, RUM, and platform administration. Every operation is authenticated with an `app_key` query parameter issued from the Flashduty console under Account → APP Keys. Responses follow a uniform envelope: `{ request_id, data }` on success, `{ request_id, error }` on failure.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.flashcat.cloud",
      "description": "Flashduty Open API"
    }
  ],
  "security": [
    {
      "AppKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Monitors/Alert rules",
      "description": "Create, manage, and export monitor alert rules. Query rule counters and audit history."
    },
    {
      "name": "Monitors/Data sources",
      "description": "Manage monitoring data sources used by alert rules to query metrics."
    },
    {
      "name": "Monitors/Rule sets",
      "description": "Manage shared rule sets (rulesets) in the Monitors rule repository. Rulesets can be shared publicly or within an account."
    },
    {
      "name": "Monitors/Diagnostics",
      "description": "Diagnostic and query endpoints used by Flashduty AI SRE — ad-hoc data source queries, log/metric diagnostics, and target-side tool invocation."
    },
    {
      "name": "Monitors/Monitor utilities",
      "description": "Monitors service activation and data preview utilities."
    }
  ],
  "paths": {
    "/monit/store/ruleset/update": {
      "post": {
        "operationId": "monit-store-ruleset-update",
        "summary": "Update ruleset",
        "description": "Update the note, sharing flag, and payload of an existing ruleset.",
        "tags": [
          "Monitors/Rule sets"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Rule Repository Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/rule-sets/monit-store-ruleset-update",
          "metadata": {
            "sidebarTitle": "Update ruleset"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/StoreRulesetItem"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 1,
                    "note": "Updated CPU alerts",
                    "open_flag": 2,
                    "updated_at": 1712100000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoreRulesetUpdateRequest"
              },
              "example": {
                "id": 1,
                "note": "Updated CPU alerts",
                "open_flag": 2,
                "payload": "[{\"prom_ql\":\"rate(cpu_usage[5m]) > 0.9\"}]"
              }
            }
          }
        }
      }
    },
    "/monit/rule/counter/total": {
      "post": {
        "operationId": "monit-rule-read-counter-total",
        "summary": "Get rule counter time series",
        "description": "Return the stored time series of the total rule count across the account — one sample per `clock` timestamp.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |\n\n## Usage\n\n- Each item is a historical snapshot: `num` is the total rule count at the given `clock` (Unix epoch seconds).",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-total",
          "metadata": {
            "sidebarTitle": "Get rule counter time series"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleCounterTotalResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "id": 1,
                      "account_id": 10023,
                      "num": 50,
                      "clock": 1712000000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleEmptyRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/monit/datasource/create": {
      "post": {
        "operationId": "monit-datasource-write-create",
        "summary": "Create datasource",
        "description": "Create a new monitoring data source. The `payload` must include the type-specific configuration block.",
        "tags": [
          "Monitors/Data sources"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Manage** (`monit`) |\n\n## Usage\n\n- `type_ident` must be one of: `prometheus`, `loki`, `mysql`, `oracle`, `postgres`, `clickhouse`, `elasticsearch`, `sls`, `victorialogs`.\n- `edge_cluster_name` specifies which Monitors edge cluster evaluates rules using this datasource.\n- For `elasticsearch`, set `payload.elasticsearch.deployment` to `cloud` or `self-managed`.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/data-sources/monit-datasource-write-create",
          "metadata": {
            "sidebarTitle": "Create datasource"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/DataSourceItem"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 10,
                    "type_ident": "prometheus",
                    "name": "Prometheus Prod",
                    "enabled": true,
                    "edge_cluster_name": "default",
                    "updated_at": 1712000000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataSourceUpsertRequest"
              },
              "example": {
                "type_ident": "prometheus",
                "name": "Prometheus Prod",
                "note": "Production Prometheus",
                "address": "http://prometheus.example.com:9090",
                "edge_cluster_name": "default",
                "payload": {
                  "prometheus": {
                    "basic_auth_enabled": false
                  }
                }
              }
            }
          }
        }
      }
    },
    "/monit/datasource/update": {
      "post": {
        "operationId": "monit-datasource-write-update",
        "summary": "Update datasource",
        "description": "Update an existing data source. Supply `id` plus the fields to change.",
        "tags": [
          "Monitors/Data sources"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/data-sources/monit-datasource-write-update",
          "metadata": {
            "sidebarTitle": "Update datasource"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/DataSourceItem"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 10,
                    "type_ident": "prometheus",
                    "name": "Prometheus Prod v2",
                    "enabled": true,
                    "edge_cluster_name": "default",
                    "updated_at": 1712100000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataSourceUpsertRequest"
              },
              "example": {
                "id": 10,
                "type_ident": "prometheus",
                "name": "Prometheus Prod v2",
                "note": "Updated",
                "address": "http://prometheus-v2.example.com:9090",
                "edge_cluster_name": "default",
                "payload": {
                  "prometheus": {
                    "basic_auth_enabled": false
                  }
                }
              }
            }
          }
        }
      }
    },
    "/monit/rule/move": {
      "post": {
        "operationId": "monit-rule-write-move",
        "summary": "Move alert rules to folder",
        "description": "Move one or more alert rules to a different folder.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Rules whose names already exist in the destination folder are skipped. Inspect each result's `message` to identify conflicts.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-move",
          "metadata": {
            "sidebarTitle": "Move alert rules to folder"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleNameMessageListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "name": "CPU High",
                      "message": ""
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleMoveRequest"
              },
              "example": {
                "ids": [
                  50001,
                  50002
                ],
                "dest_folder_id": 200
              }
            }
          }
        }
      }
    },
    "/monit/rule/counter/node": {
      "post": {
        "operationId": "monit-rule-read-counter-node",
        "summary": "Get rule counts by folder node",
        "description": "Return an object mapping top-level folder name to the total number of rules under that folder and all its descendants.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-node",
          "metadata": {
            "sidebarTitle": "Get rule counts by folder node"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleCounterNodeResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "Production": 10,
                    "Staging": 3
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleEmptyRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/monit/rule/audit/detail": {
      "post": {
        "operationId": "monit-rule-read-audit-detail",
        "summary": "Get rule audit snapshot",
        "description": "Return the audit record (including the `content` field, a JSON string of the rule snapshot at that point in time).",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |\n\n## Usage\n\n- Pass the audit record `id` (not the rule `id`) from `POST /monit/rule/audits`.\n- `content` is a JSON string — parse it to get the full rule snapshot.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-audit-detail",
          "metadata": {
            "sidebarTitle": "Get rule audit snapshot"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AlertRuleAudit"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 9001,
                    "account_id": 10023,
                    "alert_rule_id": 50001,
                    "action": "update",
                    "content": "{\"id\":50001,\"name\":\"CPU High\"}",
                    "creator_id": 80011,
                    "creator_name": "Alice",
                    "created_at": 1712000000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRecordIDRequest"
              },
              "example": {
                "id": 9001
              }
            }
          }
        }
      }
    },
    "/monit/datasource/delete": {
      "post": {
        "operationId": "monit-datasource-write-delete",
        "summary": "Delete datasource",
        "description": "Delete a data source by ID. Alert rules referencing this datasource must be updated or deleted first.",
        "tags": [
          "Monitors/Data sources"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/data-sources/monit-datasource-write-delete",
          "metadata": {
            "sidebarTitle": "Delete datasource"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/EmptyResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {}
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IDRequest"
              },
              "example": {
                "id": 10
              }
            }
          }
        }
      }
    },
    "/monit/rule/delete/batch": {
      "post": {
        "operationId": "monit-rule-write-delete-batch",
        "summary": "Batch delete alert rules",
        "description": "Delete multiple alert rules in a single request.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **30 requests/minute**; **5 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete-batch",
          "metadata": {
            "sidebarTitle": "Batch delete alert rules"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleEmptyResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {}
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleIDsRequest"
              },
              "example": {
                "ids": [
                  50001,
                  50002
                ]
              }
            }
          }
        }
      }
    },
    "/monit/datasource/sls/projects": {
      "post": {
        "operationId": "monit-datasource-read-sls-projects",
        "summary": "List SLS projects",
        "description": "List Alibaba Cloud SLS (Simple Log Service) projects available in the specified SLS datasource.",
        "tags": [
          "Monitors/Data sources"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Read** (`monit`) |\n\n## Usage\n\n- The datasource identified by `id` must be of type `sls`.\n- Use `query` to filter projects by name prefix. Use `offset` and `size` for pagination.",
          "href": "/en/api-reference/monitors/data-sources/monit-datasource-read-sls-projects",
          "metadata": {
            "sidebarTitle": "List SLS projects"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/SLSProjectsResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    "project-a",
                    "project-b"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SLSProjectsRequest"
              },
              "example": {
                "id": 10,
                "query": "",
                "offset": 0,
                "size": 50
              }
            }
          }
        }
      }
    },
    "/monit/rule/status": {
      "post": {
        "operationId": "monit-rule-write-status",
        "summary": "Get rule trigger status under folder",
        "description": "Return the rule trigger summary for all rules under a folder node and its descendants.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Set `folder_id` to `0` to get summary across all folders.\n- If the folder contains too many rules, computation is skipped for self-protection.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-status",
          "metadata": {
            "sidebarTitle": "Get rule trigger status under folder"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleStatusResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "folder_id": 100,
                      "folder_name": "Production",
                      "rule_total": 10,
                      "triggered_rule_count": 2
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleFolderIDRequest"
              },
              "example": {
                "folder_id": 100
              }
            }
          }
        }
      }
    },
    "/monit/rule/export": {
      "post": {
        "operationId": "monit-rule-read-export",
        "summary": "Export alert rules",
        "description": "Export the configuration of selected alert rules as a portable JSON array, compatible with `POST /monit/rule/import`.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **10 requests/minute**; **1 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-export",
          "metadata": {
            "sidebarTitle": "Export alert rules"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AlertRuleExportListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "name": "CPU High",
                      "ds_type": "prometheus",
                      "ds_list": [
                        "prometheus*"
                      ],
                      "enabled": true,
                      "cron_pattern": "* * * * *"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleIDsRequest"
              },
              "example": {
                "ids": [
                  50001
                ]
              }
            }
          }
        }
      }
    },
    "/monit/datasource/sls/logstores": {
      "post": {
        "operationId": "monit-datasource-read-sls-logstores",
        "summary": "List SLS logstores",
        "description": "List logstores within an SLS project for the specified SLS datasource.",
        "tags": [
          "Monitors/Data sources"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Read** (`monit`) |\n\n## Usage\n\n- The datasource identified by `id` must be of type `sls`.\n- Supply `project` to select the SLS project whose logstores to list.",
          "href": "/en/api-reference/monitors/data-sources/monit-datasource-read-sls-logstores",
          "metadata": {
            "sidebarTitle": "List SLS logstores"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/SLSLogstoresResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    "logstore-1",
                    "logstore-2"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SLSLogstoresRequest"
              },
              "example": {
                "id": 10,
                "project": "project-a",
                "offset": 0,
                "size": 50
              }
            }
          }
        }
      }
    },
    "/monit/datasource/info": {
      "post": {
        "operationId": "monit-datasource-read-info",
        "summary": "Get datasource detail",
        "description": "Retrieve full details of a single data source by its ID, including the `payload` configuration.",
        "tags": [
          "Monitors/Data sources"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Read** (`monit`) |",
          "href": "/en/api-reference/monitors/data-sources/monit-datasource-read-info",
          "metadata": {
            "sidebarTitle": "Get datasource detail"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/DataSourceItem"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 10,
                    "account_id": 10023,
                    "type_ident": "prometheus",
                    "name": "Prometheus Prod",
                    "enabled": true,
                    "note": "Production Prometheus",
                    "address": "http://prometheus.example.com:9090",
                    "payload": {
                      "prometheus": {
                        "basic_auth_enabled": false,
                        "basic_auth_username": "",
                        "basic_auth_password": "",
                        "tls_skip_verify": false
                      }
                    },
                    "edge_cluster_name": "default",
                    "updated_at": 1712000000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IDRequest"
              },
              "example": {
                "id": 10
              }
            }
          }
        }
      }
    },
    "/monit/rule/audits": {
      "post": {
        "operationId": "monit-rule-read-audits",
        "summary": "List rule change history",
        "description": "Return the change history (audit records) for an alert rule.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-audits",
          "metadata": {
            "sidebarTitle": "List rule change history"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleAuditListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "id": 9001,
                      "account_id": 10023,
                      "alert_rule_id": 50001,
                      "action": "update",
                      "creator_id": 80011,
                      "creator_name": "Alice",
                      "created_at": 1712000000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleIDRequest"
              },
              "example": {
                "id": 50001
              }
            }
          }
        }
      }
    },
    "/monit/rule/info": {
      "post": {
        "operationId": "monit-rule-read-info",
        "summary": "Get alert rule detail",
        "description": "Return the full configuration of an alert rule by its ID, including rule queries, thresholds, and notification settings.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-info",
          "metadata": {
            "sidebarTitle": "Get alert rule detail"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AlertRuleInfoResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 50001,
                    "folder_id": 100,
                    "name": "CPU High",
                    "ds_type": "prometheus",
                    "ds_list": [
                      "prometheus*"
                    ],
                    "enabled": true,
                    "cron_pattern": "* * * * *",
                    "channel_ids": [
                      20001
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleIDRequest"
              },
              "example": {
                "id": 50001
              }
            }
          }
        }
      }
    },
    "/monit/rule/delete": {
      "post": {
        "operationId": "monit-rule-write-delete",
        "summary": "Delete alert rule",
        "description": "Delete a single alert rule by its ID.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete",
          "metadata": {
            "sidebarTitle": "Delete alert rule"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleEmptyResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {}
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleIDRequest"
              },
              "example": {
                "id": 50001
              }
            }
          }
        }
      }
    },
    "/monit/rule/dstypes": {
      "post": {
        "operationId": "monit-rule-read-dstypes",
        "summary": "List available datasource types",
        "description": "Return the list of datasource types (`DSType` records) that the current account can use when authoring alert rules — combines global types and account-scoped types.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-dstypes",
          "metadata": {
            "sidebarTitle": "List available datasource types"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleDsTypesResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "id": 1,
                      "name": "Prometheus",
                      "ident": "prometheus",
                      "account_id": 0,
                      "weight": 100
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleEmptyRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/monit/rule/update": {
      "post": {
        "operationId": "monit-rule-write-update",
        "summary": "Update alert rule",
        "description": "Replace the full configuration of an existing alert rule. All fields are overwritten.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- `id` is required. All other fields follow the same rules as `POST /monit/rule/create`.\n- The name must remain unique within its folder; a duplicate returns `InvalidParameter`.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-update",
          "metadata": {
            "sidebarTitle": "Update alert rule"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AlertRule"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 50001,
                    "updated_at": 1712100000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AlertRule"
              },
              "example": {
                "id": 50001,
                "folder_id": 100,
                "name": "CPU High v2",
                "ds_type": "prometheus",
                "ds_list": [
                  "prometheus*"
                ],
                "enabled": true,
                "cron_pattern": "* * * * *",
                "rule_configs": {
                  "queries": [
                    {
                      "name": "A",
                      "expr": "avg(cpu_usage_idle) < 5"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/monit/rule/import": {
      "post": {
        "operationId": "monit-rule-write-import",
        "summary": "Import alert rules",
        "description": "Import one or more alert rules from a JSON array. Returns the result for each rule, indicating success or failure.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **20 requests/minute**; **2 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- The request body is a JSON array of rule export objects (compatible with the output of `POST /monit/rule/export`).\n- Each object must include `folder_id`, `ds_type`, and either `ds_list` or `ds_ids`.\n- Some rules may fail (e.g. duplicate name). Check each result for individual status.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-import",
          "metadata": {
            "sidebarTitle": "Import alert rules"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleImportResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "name": "CPU High",
                      "message": ""
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleImportRequest"
              },
              "example": [
                {
                  "folder_id": 100,
                  "name": "CPU High",
                  "ds_type": "prometheus",
                  "ds_list": [
                    "prometheus*"
                  ],
                  "enabled": true,
                  "cron_pattern": "* * * * *",
                  "rule_configs": {
                    "queries": [
                      {
                        "name": "A",
                        "expr": "avg(cpu_usage_idle) < 10"
                      }
                    ]
                  }
                }
              ]
            }
          }
        }
      }
    },
    "/monit/rule/create": {
      "post": {
        "operationId": "monit-rule-write-create",
        "summary": "Create alert rule",
        "description": "Create a new alert rule. Returns the created rule with its assigned ID.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- `name`, `ds_type`, `cron_pattern`, and `rule_configs.queries` are required.\n- Either `ds_list` (supports wildcards) or `ds_ids` must be non-empty.\n- `cron_pattern` uses standard 5-field cron syntax.\n- `channel_ids` can be empty; alerts will then route through the global integration.\n- `name` must be unique within `folder_id`; a duplicate returns `InvalidParameter`.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-create",
          "metadata": {
            "sidebarTitle": "Create alert rule"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/AlertRule"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 50001,
                    "folder_id": 100,
                    "name": "CPU High",
                    "ds_type": "prometheus",
                    "created_at": 1712000000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AlertRule"
              },
              "example": {
                "folder_id": 100,
                "name": "CPU High",
                "ds_type": "prometheus",
                "ds_list": [
                  "prometheus*"
                ],
                "enabled": true,
                "cron_pattern": "* * * * *",
                "channel_ids": [
                  20001
                ],
                "rule_configs": {
                  "queries": [
                    {
                      "name": "A",
                      "expr": "avg(cpu_usage_idle) < 10"
                    }
                  ],
                  "check_threshold": {
                    "enabled": true,
                    "critical": "A",
                    "alerting_check_times": 1,
                    "recovery_check_times": 1,
                    "push_recovery_event": true,
                    "recovery": {
                      "mode": "invert"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/monit/store/ruleset/list": {
      "post": {
        "operationId": "monit-store-ruleset-list",
        "summary": "List rulesets",
        "description": "Return all rulesets for a given datasource type that are accessible to the current user.",
        "tags": [
          "Monitors/Rule sets"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Rule Repository Read** (`monit`) |\n\n## Usage\n\n- A ruleset is visible if its `open_flag` is `2` (public), if the current user is the creator (`open_flag=0`), or if it belongs to the same account (`open_flag=1`).\n- The list does not include the `payload` field. Call `/monit/store/ruleset/info` to get the full ruleset content.",
          "href": "/en/api-reference/monitors/rule-sets/monit-store-ruleset-list",
          "metadata": {
            "sidebarTitle": "List rulesets"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/StoreRulesetListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "id": 1,
                      "type_ident": "prometheus",
                      "note": "CPU usage alerts",
                      "open_flag": 2,
                      "creator_account_id": 10023,
                      "creator_id": 80011,
                      "creator_name": "Alice",
                      "created_at": 1710000000,
                      "updated_at": 1712000000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoreRulesetListRequest"
              },
              "example": {
                "type_ident": "prometheus"
              }
            }
          }
        }
      }
    },
    "/monit/store/ruleset/delete": {
      "post": {
        "operationId": "monit-store-ruleset-delete",
        "summary": "Delete ruleset",
        "description": "Delete a ruleset from the rule repository by ID.",
        "tags": [
          "Monitors/Rule sets"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Rule Repository Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/rule-sets/monit-store-ruleset-delete",
          "metadata": {
            "sidebarTitle": "Delete ruleset"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/EmptyResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {}
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IDRequest"
              },
              "example": {
                "id": 1
              }
            }
          }
        }
      }
    },
    "/monit/rule/counter/status": {
      "post": {
        "operationId": "monit-rule-read-counter-status",
        "summary": "Get rule status counters for top-level folders",
        "description": "Return trigger status summary for all top-level folder nodes — used for the overview dashboard.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-status",
          "metadata": {
            "sidebarTitle": "Get rule status counters for top-level folders"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleStatusResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "folder_id": 100,
                      "folder_name": "Production",
                      "rule_total": 10,
                      "triggered_rule_count": 2
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleEmptyRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/monit/rule/list/basic": {
      "post": {
        "operationId": "monit-rule-read-list",
        "summary": "List alert rules",
        "description": "Return the basic information of all alert rules in a folder. For full rule details, call `POST /monit/rule/info`.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |\n\n## Usage\n\n- Set `folder_id` to `0` to list all rules across all folders visible to the current user.\n- The `triggered` field indicates whether the rule has any currently active alerts.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-list",
          "metadata": {
            "sidebarTitle": "List alert rules"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleBasicListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "id": 50001,
                      "folder_id": 100,
                      "name": "CPU High",
                      "ds_type": "prometheus",
                      "enabled": true,
                      "triggered": true,
                      "created_at": 1710000000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleListRequest"
              },
              "example": {
                "folder_id": 100
              }
            }
          }
        }
      }
    },
    "/monit/store/ruleset/info": {
      "post": {
        "operationId": "monit-store-ruleset-info",
        "summary": "Get ruleset detail",
        "description": "Retrieve the full details of a ruleset including its `payload` (the alert rule definitions as a JSON string).",
        "tags": [
          "Monitors/Rule sets"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Rule Repository Read** (`monit`) |",
          "href": "/en/api-reference/monitors/rule-sets/monit-store-ruleset-info",
          "metadata": {
            "sidebarTitle": "Get ruleset detail"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/StoreRulesetItem"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 1,
                    "type_ident": "prometheus",
                    "note": "CPU usage alerts",
                    "open_flag": 2,
                    "payload": "[{\"prom_ql\":\"...\"}]",
                    "creator_account_id": 10023,
                    "creator_id": 80011,
                    "creator_name": "Alice",
                    "created_at": 1710000000,
                    "updated_at": 1712000000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IDRequest"
              },
              "example": {
                "id": 1
              }
            }
          }
        }
      }
    },
    "/monit/store/ruleset/create": {
      "post": {
        "operationId": "monit-store-ruleset-create",
        "summary": "Create ruleset",
        "description": "Create a new ruleset in the rule repository.",
        "tags": [
          "Monitors/Rule sets"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Rule Repository Manage** (`monit`) |\n\n## Usage\n\n- `open_flag`: `0` = private (creator only), `1` = account-shared, `2` = public.\n- `payload` is a required JSON string containing the alert rule definitions.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/rule-sets/monit-store-ruleset-create",
          "metadata": {
            "sidebarTitle": "Create ruleset"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/StoreRulesetItem"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "id": 1,
                    "type_ident": "prometheus",
                    "note": "CPU usage alerts",
                    "open_flag": 1,
                    "created_at": 1712000000,
                    "updated_at": 1712000000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoreRulesetUpsertRequest"
              },
              "example": {
                "type_ident": "prometheus",
                "note": "CPU usage alerts",
                "open_flag": 1,
                "payload": "[{\"prom_ql\":\"rate(cpu_usage[5m]) > 0.8\"}]"
              }
            }
          }
        }
      }
    },
    "/monit/datasource/list": {
      "post": {
        "operationId": "monit-datasource-read-list",
        "summary": "List datasources",
        "description": "Return all data sources for the current account. Optionally filter by `type_ident`.",
        "tags": [
          "Monitors/Data sources"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Read** (`monit`) |\n\n## Usage\n\n- Omit `type_ident` to return all types.\n- Sensitive credential fields (passwords, keys) are not returned in the list response.",
          "href": "/en/api-reference/monitors/data-sources/monit-datasource-read-list",
          "metadata": {
            "sidebarTitle": "List datasources"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/DataSourceListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "id": 10,
                      "account_id": 10023,
                      "type_ident": "prometheus",
                      "name": "Prometheus Prod",
                      "enabled": true,
                      "note": "Production Prometheus",
                      "address": "http://prometheus.example.com:9090",
                      "edge_cluster_name": "default",
                      "updated_at": 1712000000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DataSourceListRequest"
              },
              "example": {
                "type": "prometheus"
              }
            }
          }
        }
      }
    },
    "/monit/rule/update/fields": {
      "post": {
        "operationId": "monit-rule-write-fields-update",
        "summary": "Batch update rule fields",
        "description": "Update specific fields across multiple alert rules at once. Only the fields listed in `fields` are applied.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Include the field names you want to update in the `fields` array, e.g. `[\"enabled\", \"channel_ids\"]`.\n- Only the specified fields are updated; others are left unchanged.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-fields-update",
          "metadata": {
            "sidebarTitle": "Batch update rule fields"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleNameMessageListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "name": "CPU High",
                      "message": ""
                    },
                    {
                      "name": "Disk High",
                      "message": ""
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleFieldsUpdateRequest"
              },
              "example": {
                "ids": [
                  50001,
                  50002
                ],
                "fields": [
                  "enabled"
                ],
                "enabled": false
              }
            }
          }
        }
      }
    },
    "/monit/rule/counter/channel": {
      "post": {
        "operationId": "monit-rule-read-counter-channel",
        "summary": "Get rule counts by channel",
        "description": "Return an object mapping channel name to the number of rules routing alerts to that channel. If a channel name cannot be resolved, the channel ID (as a string) is used as the key.",
        "tags": [
          "Monitors/Alert rules"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |",
          "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-channel",
          "metadata": {
            "sidebarTitle": "Get rule counts by channel"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/RuleCounterChannelResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "Production": 8
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleEmptyRequest"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/monit/query/rows": {
      "post": {
        "operationId": "monit-read-query-rows",
        "summary": "Query data source rows",
        "description": "Run a synchronous ad-hoc query against a configured data source and get back its raw rows. Used by Flashduty AI SRE and by UI preview. The request is forwarded over WebSocket to monit-edge, which executes the query against the underlying source (Prometheus / Loki / VictoriaLogs / SLS / MySQL / Postgres / Oracle / ClickHouse / Elasticsearch).",
        "tags": [
          "Monitors/Diagnostics"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **600 requests/minute**; **10 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- The request is forwarded to `monit-edge` over WebSocket; the data source named by `ds_type` + `ds_name` must already exist under the calling account.\n- `account_id` in the body is optional. When supplied it must equal the authenticated account; mismatched values are rejected.\n- Two error layers: webapi-level failures use the standard error envelope, but errors raised by `monit-edge` while executing the query are returned as HTTP 200 with an `error` object in the body. Always check the response body for `error` in addition to the HTTP status.\n- monit-edge enforces a row cap; large result sets come back as `error.message = \"too many rows\"`. Narrow the time range or aggregate at the source.\n- `args` is a polymorphic `string→string` map that is forwarded verbatim. Semantics depend on `ds_type` (SLS requires `sls.project` + `sls.logstore`; Loki / VictoriaLogs raw mode requires a time range via `*.start`/`*.end` or `*.timespan.value`/`*.timespan.unit`; Prometheus and SQL sources ignore it). See the monit-webapi query-api docs for the per-source key list.",
          "href": "/en/api-reference/monitors/diagnostics/monit-read-query-rows",
          "metadata": {
            "sidebarTitle": "Query data source rows"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryRowsRequest"
              },
              "example": {
                "account_id": 10001,
                "ds_type": "prometheus",
                "ds_name": "prod-prom",
                "expr": "up",
                "delay_seconds": 30
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/QueryRowsResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": [
                    {
                      "fields": {
                        "__name__": "up",
                        "instance": "10.0.0.1:9100",
                        "job": "node"
                      },
                      "values": {
                        "__value__": 1
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/monit/query/diagnose": {
      "post": {
        "operationId": "monit-read-query-diagnose",
        "summary": "Diagnose data source",
        "description": "Run a synchronous diagnostic query (`log_patterns` for Loki/VictoriaLogs, `metric_trends` for Prometheus). Used by Flashduty AI SRE for log-pattern clustering and time-series trend analysis. Long-running — up to 35 s.",
        "tags": [
          "Monitors/Diagnostics"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **600 requests/minute**; **10 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- This is a diagnostic / RCA endpoint, not a raw data query — pair it with `/monit/query/rows` when you need detailed rows.\n- `operation` defaults from `ds_type`: `loki` / `victorialogs` → `log_patterns`, `prometheus` → `metric_trends`. Other sources must pass `operation` explicitly.\n- `methods` selects the analyses to run; when omitted, `log_patterns` defaults to `pattern_snapshot + pattern_compare(previous_window)` and `metric_trends` defaults to `single_window_shape + window_compare(previous_window)`.\n- `time_range` is in Unix seconds; missing or invalid values default to the last 15 minutes; a window wider than 6 hours is rejected.\n- The request is forwarded over WebSocket to `monit-edge`. Long-running: the request may take up to ~30 s on the edge side plus webapi overhead. Set client timeouts to **at least 35 s**.\n- `options.*` are upper-bounded by edge (`max_logs_scanned` ≤ 50 000, `max_patterns` ≤ 50, `examples_per_pattern` ≤ 3, `step_seconds` ∈ [15, 300], `max_series` ≤ 200, `topk` ≤ 50, `timeout_seconds` ≤ 30).\n- Two error layers as with `/monit/query/rows`: edge-level execution errors come back as HTTP 200 with an `error` object in the body — check both layers.\n- Log examples are basic-redacted before being returned; expect `warnings: [\"examples redacted\"]`. Do not treat them as raw logs.",
          "href": "/en/api-reference/monitors/diagnostics/monit-read-query-diagnose",
          "metadata": {
            "sidebarTitle": "Diagnose data source"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiagnoseRequest"
              },
              "example": {
                "account_id": 10001,
                "ds_type": "victorialogs",
                "ds_name": "vmlogs-read",
                "operation": "log_patterns",
                "time_range": {
                  "start": 1776847544,
                  "end": 1776849344
                },
                "methods": [
                  {
                    "name": "pattern_snapshot"
                  },
                  {
                    "name": "pattern_compare",
                    "baseline": "same_window_yesterday"
                  }
                ],
                "input": {
                  "query": "_stream:{status='500'}"
                },
                "options": {
                  "max_logs_scanned": 10000,
                  "max_patterns": 20,
                  "examples_per_pattern": 2,
                  "timeout_seconds": 25
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/DiagnoseResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "operation": "log_patterns",
                    "ds_type": "victorialogs",
                    "ds_name": "vmlogs-read",
                    "query": "_stream:{status='500'}",
                    "window": {
                      "start": 1776847544,
                      "end": 1776849344
                    },
                    "results": [
                      {
                        "method": "pattern_snapshot",
                        "window": {
                          "start": 1776847544,
                          "end": 1776849344
                        },
                        "summary": {
                          "logs_scanned": 405,
                          "baseline_logs_scanned": 0,
                          "current_truncated": false,
                          "baseline_truncated": false,
                          "patterns_total": 2,
                          "returned_patterns": 2,
                          "new_patterns": 0,
                          "surging_patterns": 0,
                          "surging_threshold": {
                            "change_ratio_min": 3,
                            "count_min": 5
                          }
                        },
                        "patterns": [
                          {
                            "pattern_hash": "239fa5da",
                            "template": "POST /api/v<number>/orders/<number> HTTP/<number>",
                            "count": 213,
                            "first_seen": 1776847562,
                            "last_seen": 1776849336,
                            "severity": "unknown",
                            "approximate": false,
                            "sources": [
                              {
                                "field": "pod",
                                "value": "order-api-7f69d8d9b6-m4x9n",
                                "count": 130
                              }
                            ],
                            "examples": [
                              "POST /api/v<number>/orders/<number> HTTP/<number>"
                            ]
                          }
                        ],
                        "warnings": [
                          "examples redacted"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/monit/tools/catalog": {
      "post": {
        "operationId": "monit-read-tools-catalog",
        "summary": "List target tool catalog",
        "description": "Look up the tools that the per-target monit-agent currently exposes for a given `target_locator` (host, mysql, …). Returns each tool's name, description, and JSON-Schema `input_schema`. Pair with `/monit/tools/invoke` to drive AI-SRE tool calls.",
        "tags": [
          "Monitors/Diagnostics"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **600 requests/minute**; **10 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- Use `target_locator` to identify the target; `target_kind` is optional and is auto-inferred when omitted. Built-in target kinds are `host` and `mysql`.\n- If multiple kinds match the same locator, the response is HTTP 200 with `data.error.code = \"ambiguous_target_kind\"` and a `target_kinds` list — retry with an explicit `target_kind`.\n- The catalog is a *candidate capability* view, not an execution guarantee. The target Agent may go offline between catalog and invoke, or local Agent policy may block individual tools at invoke time.\n- Set `include_output_shape: true` to additionally receive each tool's `output_shape`. Default is `false` to keep the response small for LLM consumption.\n- Business errors (`target_unavailable`, `unknown_toolset_hash`, `ambiguous_target_kind`) come back as HTTP 200 with a non-null `data.error`. Only protocol / auth / internal errors use the standard error envelope.",
          "href": "/en/api-reference/monitors/diagnostics/monit-read-tools-catalog",
          "metadata": {
            "sidebarTitle": "List target tool catalog"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToolCatalogRequest"
              },
              "example": {
                "account_id": 10001,
                "target_locator": "web-01",
                "include_output_shape": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ToolCatalogResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "target": {
                      "kind": "host",
                      "locator": "web-01"
                    },
                    "tools": [
                      {
                        "name": "os.overview",
                        "target_kind": "host",
                        "description": "Returns a bounded overview of host health (CPU, memory, disk, network, top processes).",
                        "input_schema": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {}
                        },
                        "output_shape": {
                          "type": "object",
                          "required": [
                            "data",
                            "summary",
                            "truncated"
                          ],
                          "properties": {
                            "data": {
                              "type": "object"
                            },
                            "summary": {
                              "type": "string"
                            },
                            "truncated": {
                              "type": "object"
                            }
                          }
                        }
                      }
                    ],
                    "error": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/monit/tools/invoke": {
      "post": {
        "operationId": "monit-read-tools-invoke",
        "summary": "Invoke target tools",
        "description": "Invoke up to 8 monit-agent tools concurrently on a single target. Results come back in the order of the input `tools` array. Long-running — individual tools have per-tool timeouts on the agent and the whole request may take tens of seconds.",
        "tags": [
          "Monitors/Diagnostics"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **600 requests/minute**; **10 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- Up to **8** tools per call (`MaxToolsPerInvoke`); larger batches must be split client-side. The 8-tool cap aligns with the per-target agent concurrency.\n- Tools execute in parallel on the agent; webapi returns `results[]` aligned with the request `tools[]` order.\n- Long-running: set client timeouts to **at least 35 s**. The endpoint is intended for AI-SRE / human-RCA flows, not interactive UI.\n- Request-level errors (`target_unavailable`, `ambiguous_target_kind`, `unknown_toolset_hash`, `forward_failed`) appear as HTTP 200 with `data.error` set and `data.results = []`.\n- Per-tool failures appear as HTTP 200 with `data.error = null` and `results[i].error` populated — always check **all three** layers (outer envelope `error`, `data.error`, then each `results[i].error`).\n- Each result carries two latency fields: `agent_elapsed_ms` (agent-self-reported, excludes network) and `e2e_elapsed_ms` (webapi-observed end-to-end). A large gap between them indicates network / edge slowness rather than slow tool execution.\n- Construct `tools[].params` against the `input_schema` returned by `/monit/tools/catalog`. For no-arg tools always pass `params: {}` explicitly.",
          "href": "/en/api-reference/monitors/diagnostics/monit-read-tools-invoke",
          "metadata": {
            "sidebarTitle": "Invoke target tools"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToolInvokeRequest"
              },
              "example": {
                "account_id": 10001,
                "target_locator": "web-01",
                "tools": [
                  {
                    "tool": "os.overview",
                    "params": {}
                  },
                  {
                    "tool": "net.tcp_ping",
                    "params": {
                      "host": "10.0.0.10",
                      "port": 3306
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ToolInvokeResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "target": {
                      "kind": "host",
                      "locator": "web-01"
                    },
                    "results": [
                      {
                        "tool": "os.overview",
                        "tool_version": "0.5.0",
                        "data": {
                          "data": {
                            "sample_interval_sec": 3,
                            "degraded": false,
                            "degradation_reasons": []
                          },
                          "summary": "os.overview ...",
                          "truncated": {
                            "truncated": false
                          }
                        },
                        "error": null,
                        "agent_elapsed_ms": 3120,
                        "e2e_elapsed_ms": 3188
                      },
                      {
                        "tool": "net.tcp_ping",
                        "tool_version": "0.5.0",
                        "data": null,
                        "error": {
                          "code": "target_unreachable",
                          "message": "dial tcp 10.0.0.10:3306: i/o timeout"
                        },
                        "agent_elapsed_ms": 0,
                        "e2e_elapsed_ms": 2008
                      }
                    ],
                    "error": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/monit/targets": {
      "post": {
        "operationId": "monit-read-targets-list",
        "summary": "List monitored targets",
        "description": "List the targets observed under the current tenant by the monit-agent route projection. Supports `target_locator` prefix search and cursor pagination. Use this to drive `target_locator` selection for `/monit/tools/catalog` and `/monit/tools/invoke`.",
        "tags": [
          "Monitors/Diagnostics"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **600 requests/minute**; **10 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- This is a **UI projection view**, not the live source-of-truth used by `/monit/tools/invoke`. A row in the list is no guarantee the target is currently invokable.\n- `keyword` is a **prefix** match against `target_locator` (ASCII-only, no whitespace, no `|`, max 256 bytes). Substring search is not supported in v1.\n- `limit` defaults to 50, max 200. Pagination is cursor-based: pass the previous response's `next_cursor` to fetch the next page; an empty / missing `next_cursor` means the last page.\n- Resetting `keyword`, `limit`, or the tenant context requires resetting `cursor`; never mix a cursor across different filter sets.\n- `total` is the unfiltered-by-cursor match count for the current `(account_id, keyword)` pair and stays stable across pages.\n- Fields surface `cluster_name` / `edge_ipport` for diagnostics; treat `updated_at` as \"most recently observed\" rather than a live online indicator.",
          "href": "/en/api-reference/monitors/diagnostics/monit-read-targets-list",
          "metadata": {
            "sidebarTitle": "List monitored targets"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TargetsListRequest"
              },
              "example": {
                "keyword": "db-prod",
                "limit": 50
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/TargetsListResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "items": [
                      {
                        "target_kind": "host",
                        "target_locator": "db-prod-01",
                        "agent_version": "2.0.0",
                        "cluster_name": "edge-a",
                        "edge_ipport": "10.0.0.1:19090",
                        "updated_at": 1710000000
                      }
                    ],
                    "total": 120,
                    "next_cursor": "eyJ0YXJnZXRfbG9jYXRvciI6ImRiLXByb2QtMDEiLCJpZCI6MTIzNDV9"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/monit/preview/sync": {
      "post": {
        "operationId": "monit-preview-sync",
        "summary": "Preview datasource query",
        "description": "Execute a synchronous datasource query and return the raw result. Used to preview alert rule expressions before saving.",
        "tags": [
          "Monitors/Monitor utilities"
        ],
        "x-mint": {
          "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **60 requests/minute**; **10 requests/second** per account |\n| Permissions | None — any valid `app_key` can call this operation |\n\n## Usage\n\n- `ds_type` must match the datasource type (e.g. `prometheus`, `loki`).\n- `ds_name` is the display name of the datasource as configured in the account.\n- `delay_seconds` shifts the query window backward by the specified number of seconds, useful for accommodating data ingestion latency.\n- The response body is the raw JSON returned by the datasource — its schema varies by datasource type.",
          "href": "/en/api-reference/monitors/monitor-utilities/monit-preview-sync",
          "metadata": {
            "sidebarTitle": "Preview datasource query"
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessEnvelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/PreviewSyncResponse"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "data": {
                    "status": "success",
                    "data": {
                      "resultType": "vector",
                      "result": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewSyncRequest"
              },
              "example": {
                "ds_type": "prometheus",
                "ds_name": "Prometheus Prod",
                "expr": "rate(http_requests_total[5m])",
                "delay_seconds": 0
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "AppKeyAuth": {
        "type": "apiKey",
        "in": "query",
        "name": "app_key",
        "description": "App key issued from the Flashduty console under Account → APP Keys. Required on every public API call. Keep it secret — it grants the same access as the owning account."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request — usually a missing or malformed parameter.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "missingParameter": {
                "value": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "error": {
                    "code": "InvalidParameter",
                    "message": "The specified parameter is not valid."
                  }
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid app_key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "missingAppKey": {
                "value": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "error": {
                    "code": "Unauthorized",
                    "message": "You are unauthorized."
                  }
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The app_key is valid but lacks permission for this operation.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "noEditPermission": {
                "value": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "error": {
                    "code": "AccessDenied",
                    "message": "Access Denied."
                  }
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "The referenced resource does not exist or has been deleted. Note: Flashduty historically returns HTTP 400 with code `ResourceNotFound` for missing domain entities; a true 404 is reserved for unknown routes.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "resourceMissing": {
                "value": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "error": {
                    "code": "ResourceNotFound",
                    "message": "The resource you request is not found"
                  }
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limit hit. Either the global API limit, a per-account limit, or a per-integration limit.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "rateLimited": {
                "value": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "error": {
                    "code": "RequestTooFrequently",
                    "message": "Request too frequently."
                  }
                }
              }
            }
          }
        }
      },
      "ServerError": {
        "description": "Unexpected server-side error. Include the request_id when reporting.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "internal": {
                "value": {
                  "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
                  "error": {
                    "code": "InternalError",
                    "message": "We encountered an internal error, and it has been reported. Please try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "AlertRule": {
        "type": "object",
        "description": "Full alert rule configuration.",
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64"
          },
          "account_id": {
            "type": "integer",
            "format": "uint64"
          },
          "folder_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Folder the rule belongs to."
          },
          "name": {
            "type": "string",
            "description": "Rule name."
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Custom labels."
          },
          "ds_type": {
            "type": "string",
            "description": "Data source type."
          },
          "ds_list": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Data source name patterns (supports wildcards)."
          },
          "ds_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            },
            "description": "Specific data source IDs."
          },
          "enabled": {
            "type": "boolean"
          },
          "debug_log_enabled": {
            "type": "boolean"
          },
          "rule_configs": {
            "$ref": "#/components/schemas/RuleConfigs"
          },
          "cron_pattern": {
            "type": "string",
            "description": "5-field cron schedule. Must not start with `CRON_TZ=` or `TZ=`; use the `timezone` field instead."
          },
          "timezone": {
            "type": "string",
            "description": "Timezone in which the rule executes. Determines how the cron schedule and effective time windows are interpreted. Only IANA timezone names are accepted (e.g. `Asia/Shanghai`, `UTC`, `Europe/London`); shortcuts and offsets such as `Local`, `UTC+8`, or `CST` are rejected. Treated as `Asia/Shanghai` if empty.",
            "default": "Asia/Shanghai"
          },
          "delay_seconds": {
            "type": "integer"
          },
          "enabled_times": {
            "type": "array",
            "description": "Time windows when the rule is active.",
            "items": {
              "type": "object",
              "properties": {
                "days": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  },
                  "description": "Days of week (0=Sunday)."
                },
                "stime": {
                  "type": "string",
                  "description": "Start time, e.g. `09:00`."
                },
                "etime": {
                  "type": "string",
                  "description": "End time, e.g. `18:00`."
                }
              }
            }
          },
          "annotations": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "description_type": {
            "type": "string",
            "enum": [
              "text",
              "markdown"
            ]
          },
          "description": {
            "type": "string"
          },
          "channel_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            },
            "description": "Channel IDs to send alerts to."
          },
          "repeat_interval": {
            "type": "integer",
            "format": "int64",
            "description": "Notification repeat interval in seconds."
          },
          "repeat_total": {
            "type": "integer",
            "format": "int64",
            "description": "Max number of repeat notifications."
          },
          "creator_id": {
            "type": "integer",
            "format": "uint64"
          },
          "creator_name": {
            "type": "string"
          },
          "updater_id": {
            "type": "integer",
            "format": "uint64"
          },
          "updater_name": {
            "type": "string"
          },
          "created_at": {
            "type": "integer",
            "format": "int64"
          },
          "updated_at": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "AlertRuleAudit": {
        "type": "object",
        "description": "An audit record capturing a rule snapshot at a point in time.",
        "required": [
          "id",
          "account_id",
          "alert_rule_id",
          "action",
          "creator_id",
          "creator_name",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Audit record ID."
          },
          "account_id": {
            "type": "integer",
            "format": "uint64"
          },
          "alert_rule_id": {
            "type": "integer",
            "format": "uint64",
            "description": "ID of the alert rule this record belongs to."
          },
          "action": {
            "type": "string",
            "description": "Action performed, e.g. `create`, `update`."
          },
          "content": {
            "type": "string",
            "description": "JSON string of the full rule snapshot at audit time. Populated on `/monit/rule/audit/detail`, omitted on list responses."
          },
          "creator_id": {
            "type": "integer",
            "format": "uint64"
          },
          "creator_name": {
            "type": "string"
          },
          "created_at": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "AlertRuleBasic": {
        "type": "object",
        "description": "Basic alert rule information for list views.",
        "required": [
          "id",
          "account_id",
          "folder_id",
          "name",
          "ds_type",
          "enabled",
          "debug_log_enabled",
          "cron_pattern",
          "delay_seconds",
          "creator_id",
          "creator_name",
          "updater_id",
          "updater_name",
          "created_at",
          "updated_at",
          "triggered"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Unique rule ID."
          },
          "account_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Account ID."
          },
          "folder_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Folder ID."
          },
          "name": {
            "type": "string",
            "description": "Rule name."
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Custom labels."
          },
          "ds_type": {
            "type": "string",
            "description": "Data source type, e.g. `prometheus`."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the rule is enabled."
          },
          "debug_log_enabled": {
            "type": "boolean",
            "description": "Whether debug logging is enabled."
          },
          "cron_pattern": {
            "type": "string",
            "description": "5-field cron schedule, e.g. `* * * * *`. Must not start with `CRON_TZ=` or `TZ=`; use the `timezone` field instead."
          },
          "timezone": {
            "type": "string",
            "description": "Timezone in which the rule executes. Determines how the cron schedule and effective time windows are interpreted. Only IANA timezone names are accepted (e.g. `Asia/Shanghai`, `UTC`, `Europe/London`); shortcuts and offsets such as `Local`, `UTC+8`, or `CST` are rejected. Treated as `Asia/Shanghai` if empty.",
            "default": "Asia/Shanghai"
          },
          "delay_seconds": {
            "type": "integer",
            "description": "Evaluation delay in seconds."
          },
          "creator_id": {
            "type": "integer",
            "format": "uint64"
          },
          "creator_name": {
            "type": "string"
          },
          "updater_id": {
            "type": "integer",
            "format": "uint64"
          },
          "updater_name": {
            "type": "string"
          },
          "created_at": {
            "type": "integer",
            "format": "int64"
          },
          "updated_at": {
            "type": "integer",
            "format": "int64"
          },
          "triggered": {
            "type": "boolean",
            "description": "True if the rule currently has active alerts."
          }
        }
      },
      "AlertRuleCounter": {
        "type": "object",
        "description": "One historical snapshot of the account's alert rule total.",
        "required": [
          "id",
          "account_id",
          "num",
          "clock"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64"
          },
          "account_id": {
            "type": "integer",
            "format": "uint64"
          },
          "num": {
            "type": "integer",
            "format": "int64",
            "description": "Rule count at the sample time."
          },
          "clock": {
            "type": "integer",
            "format": "int64",
            "description": "Sample timestamp, Unix epoch seconds."
          }
        }
      },
      "AlertRuleExport": {
        "type": "object",
        "description": "Portable alert rule representation for import/export. Omits identifying fields like `id`, `account_id`, and audit metadata.",
        "required": [
          "name",
          "ds_type",
          "enabled",
          "debug_log_enabled",
          "cron_pattern"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "ds_type": {
            "type": "string"
          },
          "ds_list": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ds_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "debug_log_enabled": {
            "type": "boolean"
          },
          "rule_configs": {
            "$ref": "#/components/schemas/RuleConfigs"
          },
          "cron_pattern": {
            "type": "string"
          },
          "timezone": {
            "type": "string",
            "description": "Timezone in which the rule executes. IANA timezone name; defaults to `Asia/Shanghai`.",
            "default": "Asia/Shanghai"
          },
          "delay_seconds": {
            "type": "integer"
          },
          "enabled_times": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EnabledTime"
            }
          },
          "annotations": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "description_type": {
            "type": "string",
            "enum": [
              "text",
              "markdown"
            ]
          },
          "description": {
            "type": "string"
          },
          "repeat_interval": {
            "type": "integer",
            "format": "int64"
          },
          "repeat_total": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "AlertRuleExportListResponse": {
        "type": "array",
        "description": "List of exported rule configurations, compatible with `POST /monit/rule/import`.",
        "items": {
          "$ref": "#/components/schemas/AlertRuleExport"
        }
      },
      "AlertRuleInfoResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AlertRule"
          }
        ],
        "description": "Full alert rule returned by the info endpoint. All server-assigned fields are guaranteed present.",
        "required": [
          "id",
          "account_id",
          "folder_id",
          "name",
          "ds_type",
          "enabled",
          "debug_log_enabled",
          "cron_pattern",
          "delay_seconds",
          "creator_id",
          "creator_name",
          "updater_id",
          "updater_name",
          "created_at",
          "updated_at"
        ]
      },
      "AlertRuleStatus": {
        "type": "object",
        "description": "Rule trigger status for a folder node.",
        "required": [
          "folder_id",
          "rule_total",
          "triggered_rule_count"
        ],
        "properties": {
          "folder_id": {
            "type": "integer",
            "format": "uint64"
          },
          "folder_name": {
            "type": "string"
          },
          "rule_total": {
            "type": "integer",
            "format": "int64",
            "description": "Total rules in the folder family."
          },
          "triggered_rule_count": {
            "type": "integer",
            "format": "int64",
            "description": "Rules with active alerts."
          }
        }
      },
      "DSClickHouseConfig": {
        "type": "object",
        "description": "ClickHouse datasource configuration. TLS fields are inherited from TLSClientConfig.",
        "properties": {
          "database": {
            "type": "string",
            "description": "Default database for authentication."
          },
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string"
          },
          "open_conns": {
            "type": "integer"
          },
          "idle_conns": {
            "type": "integer"
          },
          "lifetime_seconds": {
            "type": "integer",
            "format": "int64"
          },
          "timeout_mills": {
            "type": "integer",
            "format": "int64"
          },
          "max_execution_seconds": {
            "type": "integer",
            "format": "int64",
            "description": "Max query execution time in seconds."
          },
          "dial_timeout_mills": {
            "type": "integer",
            "format": "int64",
            "description": "Dial timeout in milliseconds."
          },
          "tls_enabled": {
            "type": "boolean"
          },
          "tls_ca": {
            "type": "string"
          },
          "tls_cert": {
            "type": "string"
          },
          "tls_key": {
            "type": "string"
          },
          "tls_key_pwd": {
            "type": "string"
          },
          "tls_skip_verify": {
            "type": "boolean"
          },
          "tls_server_name": {
            "type": "string"
          },
          "tls_min_version": {
            "type": "string"
          },
          "tls_max_version": {
            "type": "string"
          }
        }
      },
      "DSElasticSearchConfig": {
        "type": "object",
        "description": "Elasticsearch datasource configuration.",
        "properties": {
          "deployment": {
            "type": "string",
            "enum": [
              "cloud",
              "self-managed"
            ],
            "description": "Deployment type. `cloud` uses Elastic Cloud; `self-managed` uses a self-hosted cluster."
          },
          "timeout_mills": {
            "type": "integer",
            "format": "int64"
          },
          "cloud_id": {
            "type": "string",
            "description": "Elastic Cloud deployment ID. Only for `cloud` deployment."
          },
          "api_key": {
            "type": "string",
            "description": "Elastic Cloud API key. Only for `cloud` deployment."
          },
          "username": {
            "type": "string",
            "description": "Username for `self-managed` deployment."
          },
          "password": {
            "type": "string"
          },
          "service_token": {
            "type": "string",
            "description": "Service token; overrides username/password if set."
          },
          "tls_ca": {
            "type": "string"
          },
          "certificate_fingerprint": {
            "type": "string"
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "DSLokiConfig": {
        "type": "object",
        "description": "Loki datasource configuration. TLS fields are inherited from TLSClientConfig.",
        "properties": {
          "basic_auth_enabled": {
            "type": "boolean"
          },
          "basic_auth_username": {
            "type": "string"
          },
          "basic_auth_password": {
            "type": "string"
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "params": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tls_ca": {
            "type": "string"
          },
          "tls_cert": {
            "type": "string"
          },
          "tls_key": {
            "type": "string"
          },
          "tls_key_pwd": {
            "type": "string"
          },
          "tls_skip_verify": {
            "type": "boolean"
          },
          "tls_server_name": {
            "type": "string"
          },
          "tls_min_version": {
            "type": "string"
          },
          "tls_max_version": {
            "type": "string"
          }
        }
      },
      "DSMySQLConfig": {
        "type": "object",
        "description": "MySQL datasource configuration. TLS fields are inherited from TLSClientConfig.",
        "properties": {
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string"
          },
          "open_conns": {
            "type": "integer",
            "description": "Maximum open connections."
          },
          "idle_conns": {
            "type": "integer",
            "description": "Maximum idle connections."
          },
          "lifetime_seconds": {
            "type": "integer",
            "format": "int64",
            "description": "Connection maximum lifetime in seconds."
          },
          "timeout_mills": {
            "type": "integer",
            "format": "int64",
            "description": "Query timeout in milliseconds."
          },
          "tls_ca": {
            "type": "string"
          },
          "tls_cert": {
            "type": "string"
          },
          "tls_key": {
            "type": "string"
          },
          "tls_key_pwd": {
            "type": "string"
          },
          "tls_skip_verify": {
            "type": "boolean"
          },
          "tls_server_name": {
            "type": "string"
          },
          "tls_min_version": {
            "type": "string"
          },
          "tls_max_version": {
            "type": "string"
          }
        }
      },
      "DSOracleConfig": {
        "type": "object",
        "description": "Oracle datasource configuration.",
        "properties": {
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string"
          },
          "options": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Extra connection options as key-value pairs."
          },
          "open_conns": {
            "type": "integer"
          },
          "idle_conns": {
            "type": "integer"
          },
          "lifetime_seconds": {
            "type": "integer",
            "format": "int64"
          },
          "timeout_mills": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "DSPayload": {
        "type": "object",
        "description": "Type-specific datasource configuration. Include only the block matching `type_ident`.",
        "properties": {
          "prometheus": {
            "$ref": "#/components/schemas/DSPrometheusConfig"
          },
          "loki": {
            "$ref": "#/components/schemas/DSLokiConfig"
          },
          "mysql": {
            "$ref": "#/components/schemas/DSMySQLConfig"
          },
          "oracle": {
            "$ref": "#/components/schemas/DSOracleConfig"
          },
          "postgres": {
            "$ref": "#/components/schemas/DSPostgresConfig"
          },
          "clickhouse": {
            "$ref": "#/components/schemas/DSClickHouseConfig"
          },
          "elasticsearch": {
            "$ref": "#/components/schemas/DSElasticSearchConfig"
          },
          "sls": {
            "$ref": "#/components/schemas/DSSLSConfig"
          },
          "victorialogs": {
            "$ref": "#/components/schemas/DSVictoriaLogsConfig"
          }
        }
      },
      "DSPostgresConfig": {
        "type": "object",
        "description": "PostgreSQL datasource configuration.",
        "properties": {
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string"
          },
          "open_conns": {
            "type": "integer"
          },
          "idle_conns": {
            "type": "integer"
          },
          "lifetime_seconds": {
            "type": "integer",
            "format": "int64"
          },
          "timeout_mills": {
            "type": "integer",
            "format": "int64"
          },
          "tls_ca": {
            "type": "string"
          },
          "tls_cert": {
            "type": "string"
          },
          "tls_key": {
            "type": "string"
          }
        }
      },
      "DSPrometheusConfig": {
        "type": "object",
        "description": "Prometheus datasource configuration. TLS fields are inherited from TLSClientConfig.",
        "properties": {
          "basic_auth_enabled": {
            "type": "boolean",
            "description": "Enable HTTP Basic Auth."
          },
          "basic_auth_username": {
            "type": "string",
            "description": "Basic auth username."
          },
          "basic_auth_password": {
            "type": "string",
            "description": "Basic auth password."
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Custom HTTP headers in `Key: Value` format."
          },
          "params": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Custom query parameters in `key=value` format."
          },
          "tls_ca": {
            "type": "string"
          },
          "tls_cert": {
            "type": "string"
          },
          "tls_key": {
            "type": "string"
          },
          "tls_key_pwd": {
            "type": "string"
          },
          "tls_skip_verify": {
            "type": "boolean"
          },
          "tls_server_name": {
            "type": "string"
          },
          "tls_min_version": {
            "type": "string"
          },
          "tls_max_version": {
            "type": "string"
          }
        }
      },
      "DSSLSConfig": {
        "type": "object",
        "description": "Alibaba Cloud SLS datasource configuration.",
        "properties": {
          "access_key_id": {
            "type": "string",
            "description": "Alibaba Cloud Access Key ID."
          },
          "access_key_secret": {
            "type": "string",
            "description": "Alibaba Cloud Access Key Secret."
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Custom HTTP headers."
          }
        }
      },
      "DSType": {
        "type": "object",
        "description": "A datasource type definition usable by alert rules.",
        "required": [
          "id",
          "name",
          "ident",
          "account_id",
          "weight"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64"
          },
          "name": {
            "type": "string",
            "description": "Display name, e.g. `Prometheus`."
          },
          "ident": {
            "type": "string",
            "description": "Identifier used as the `ds_type` of rules, e.g. `prometheus`."
          },
          "account_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Owning account ID. `0` for global types."
          },
          "weight": {
            "type": "integer",
            "description": "Display order weight; higher appears first."
          }
        }
      },
      "DSVictoriaLogsConfig": {
        "type": "object",
        "description": "VictoriaLogs datasource configuration. TLS fields are inherited from TLSClientConfig.",
        "properties": {
          "basic_auth_enabled": {
            "type": "boolean"
          },
          "basic_auth_username": {
            "type": "string"
          },
          "basic_auth_password": {
            "type": "string"
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "params": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tls_ca": {
            "type": "string"
          },
          "tls_cert": {
            "type": "string"
          },
          "tls_key": {
            "type": "string"
          },
          "tls_key_pwd": {
            "type": "string"
          },
          "tls_skip_verify": {
            "type": "boolean"
          },
          "tls_server_name": {
            "type": "string"
          },
          "tls_min_version": {
            "type": "string"
          },
          "tls_max_version": {
            "type": "string"
          }
        }
      },
      "DataSourceItem": {
        "type": "object",
        "description": "A monitoring datasource.",
        "required": [
          "id",
          "account_id",
          "type_ident",
          "name",
          "enabled",
          "note",
          "address",
          "edge_cluster_name",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Unique datasource ID."
          },
          "account_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Account ID."
          },
          "type_ident": {
            "type": "string",
            "description": "Datasource type identifier. Allowed: `prometheus`, `loki`, `mysql`, `oracle`, `postgres`, `clickhouse`, `elasticsearch`, `sls`, `victorialogs`."
          },
          "name": {
            "type": "string",
            "description": "Datasource display name."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the datasource is active."
          },
          "note": {
            "type": "string",
            "description": "Optional description."
          },
          "address": {
            "type": "string",
            "description": "Connection address. For Prometheus/Loki/VictoriaLogs: HTTP URL. For MySQL/Oracle/Postgres/ClickHouse: `host:port`. For SLS: endpoint without http/https prefix."
          },
          "payload": {
            "$ref": "#/components/schemas/DSPayload"
          },
          "edge_cluster_name": {
            "type": "string",
            "description": "Monitors edge cluster name responsible for evaluating rules using this datasource."
          },
          "updated_at": {
            "type": "integer",
            "format": "int64",
            "description": "Last update timestamp, Unix epoch seconds."
          }
        }
      },
      "DataSourceListRequest": {
        "type": "object",
        "description": "Filter parameters for listing datasources.",
        "properties": {
          "type": {
            "type": "string",
            "description": "Filter by datasource type identifier. Omit to return all types. Allowed values: `prometheus`, `loki`, `mysql`, `oracle`, `postgres`, `clickhouse`, `elasticsearch`, `sls`, `victorialogs`."
          }
        }
      },
      "DataSourceListResponse": {
        "type": "array",
        "description": "List of datasources. Sensitive credential fields are omitted.",
        "items": {
          "$ref": "#/components/schemas/DataSourceItem"
        }
      },
      "DataSourceUpsertRequest": {
        "type": "object",
        "description": "Request body for creating or updating a datasource. `id` is required only for update. `address` is required for all types except Elasticsearch with `deployment=cloud`.",
        "required": [
          "type_ident",
          "name",
          "edge_cluster_name",
          "payload"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Datasource ID. Required for update; omit for create."
          },
          "type_ident": {
            "type": "string",
            "description": "Datasource type identifier. Allowed: `prometheus`, `loki`, `mysql`, `oracle`, `postgres`, `clickhouse`, `elasticsearch`, `sls`, `victorialogs`."
          },
          "name": {
            "type": "string",
            "description": "Datasource display name."
          },
          "note": {
            "type": "string",
            "description": "Optional description."
          },
          "address": {
            "type": "string",
            "description": "Connection address. For Prometheus/Loki/VictoriaLogs: HTTP URL. For MySQL/Oracle/Postgres/ClickHouse: `host:port`. For SLS: endpoint without http/https prefix. Not required for Elasticsearch cloud deployment."
          },
          "payload": {
            "$ref": "#/components/schemas/DSPayload",
            "description": "Type-specific configuration block. Must include the key matching `type_ident`."
          },
          "edge_cluster_name": {
            "type": "string",
            "description": "Monitors edge cluster name responsible for evaluating rules using this datasource."
          }
        }
      },
      "DutyError": {
        "type": "object",
        "description": "Error payload inside the response envelope. Present only on non-2xx responses.",
        "properties": {
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message, localized by the caller's Accept-Language. May contain field names, IDs, or other context from the failing request.",
            "example": "The specified parameter template_id is not valid."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "EmptyObject": {
        "type": "object",
        "description": "An empty object. Returned as the `data` payload by operations whose success signal is simply the absence of an error.",
        "additionalProperties": false
      },
      "EmptyRequest": {
        "type": "object",
        "description": "No parameters required.",
        "additionalProperties": false
      },
      "EmptyResponse": {
        "type": "object",
        "description": "Empty response body. The server returns `data: null` on success.",
        "properties": {}
      },
      "EnabledTime": {
        "type": "object",
        "description": "Time window in which the rule is active.",
        "properties": {
          "days": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Days of week, 0 = Sunday."
          },
          "stime": {
            "type": "string",
            "description": "Start time, e.g. `09:00`."
          },
          "etime": {
            "type": "string",
            "description": "End time, e.g. `18:00`."
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "description": "Flashduty error code enum. Every failed API response sets `error.code` to one of these stable wire strings. HTTP status is informational — the authoritative signal is the enum value.\n\n| Code | HTTP | Meaning |\n|---|---|---|\n| `OK` | 200 | Reserved — not returned on real errors. |\n| `InvalidParameter` | 400 | A required parameter is missing or failed validation. |\n| `BadRequest` | 400 | Generic 400 used when no more specific code fits. |\n| `InvalidContentType` | 400 | The `Content-Type` header is not `application/json`. |\n| `ResourceNotFound` | 400 | The referenced resource does not exist. Note: returned as HTTP 400, not 404 (historical choice). |\n| `NoLicense` | 400 | The feature is license-gated and no active license was found. |\n| `ReferenceExist` | 400 | Deletion blocked — other entities still reference this resource. |\n| `Unauthorized` | 401 | `app_key` is missing, invalid, or expired. |\n| `BalanceNotEnough` | 402 | Billing-gated operation with insufficient account balance. |\n| `AccessDenied` | 403 | Authenticated but lacking the permission required for this operation. |\n| `RouteNotFound` | 404 | The request URL path is not a known route. |\n| `MethodNotAllowed` | 405 | The HTTP method is not allowed on this otherwise-known path. |\n| `UndonedOrderExist` | 409 | An outstanding billing order blocks this new one. Wait and retry. |\n| `RequestLocked` | 423 | Operation temporarily locked due to repeated failures. |\n| `EntityTooLarge` | 413 | Request body exceeds the configured max size. |\n| `RequestTooFrequently` | 429 | Rate limit hit — API-global, per-account, or per-integration. |\n| `RequestVerifyRequired` | 428 | Second-factor verification required but not supplied. |\n| `DangerousOperation` | 428 | High-risk operation requires MFA verification. |\n| `InternalError` | 500 | Unhandled server-side error. Include `request_id` in the bug report. |\n| `ServiceUnavailable` | 503 | A backend dependency is unavailable. Try again later. |",
        "enum": [
          "OK",
          "InvalidParameter",
          "BadRequest",
          "InvalidContentType",
          "ResourceNotFound",
          "NoLicense",
          "ReferenceExist",
          "Unauthorized",
          "BalanceNotEnough",
          "AccessDenied",
          "RouteNotFound",
          "MethodNotAllowed",
          "UndonedOrderExist",
          "RequestLocked",
          "EntityTooLarge",
          "RequestTooFrequently",
          "RequestVerifyRequired",
          "DangerousOperation",
          "InternalError",
          "ServiceUnavailable"
        ],
        "x-enumDescriptions": {
          "OK": "Reserved — not returned on real errors.",
          "InvalidParameter": "A required parameter is missing or failed validation.",
          "BadRequest": "Generic 400 used when no more specific code fits.",
          "InvalidContentType": "The `Content-Type` header is not `application/json`.",
          "ResourceNotFound": "The referenced resource does not exist. Note: returned as HTTP 400, not 404 (historical choice).",
          "NoLicense": "The feature is license-gated and no active license was found.",
          "ReferenceExist": "Deletion blocked — other entities still reference this resource.",
          "Unauthorized": "`app_key` is missing, invalid, or expired.",
          "BalanceNotEnough": "Billing-gated operation with insufficient account balance.",
          "AccessDenied": "Authenticated but lacking the permission required for this operation.",
          "RouteNotFound": "The request URL path is not a known route.",
          "MethodNotAllowed": "The HTTP method is not allowed on this otherwise-known path.",
          "UndonedOrderExist": "An outstanding billing order blocks this new one. Wait and retry.",
          "RequestLocked": "Operation temporarily locked due to repeated failures.",
          "EntityTooLarge": "Request body exceeds the configured max size.",
          "RequestTooFrequently": "Rate limit hit — API-global, per-account, or per-integration.",
          "RequestVerifyRequired": "Second-factor verification required but not supplied.",
          "DangerousOperation": "High-risk operation requires MFA verification.",
          "InternalError": "Unhandled server-side error. Include `request_id` in the bug report.",
          "ServiceUnavailable": "A backend dependency is unavailable. Try again later."
        },
        "example": "InvalidParameter"
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Response envelope for errors. `error` is required; `data` is absent.",
        "properties": {
          "request_id": {
            "type": "string",
            "example": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
          },
          "error": {
            "$ref": "#/components/schemas/DutyError"
          }
        },
        "required": [
          "request_id",
          "error"
        ]
      },
      "IDRequest": {
        "type": "object",
        "required": [
          "id"
        ],
        "description": "Request with a single numeric ID.",
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Resource ID."
          }
        }
      },
      "NameMessage": {
        "type": "object",
        "description": "Per-item result for batch rule operations.",
        "required": [
          "name",
          "message"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Rule name."
          },
          "message": {
            "type": "string",
            "description": "Empty on success, error message on failure."
          }
        }
      },
      "RuleAuditListResponse": {
        "type": "array",
        "description": "Audit records for a rule, ordered by creation time descending. The `content` field is omitted.",
        "items": {
          "$ref": "#/components/schemas/AlertRuleAudit"
        }
      },
      "RuleBasicListResponse": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/AlertRuleBasic"
        },
        "description": "List of alert rules (basic info)."
      },
      "RuleConfigs": {
        "type": "object",
        "description": "Rule evaluation configuration.",
        "properties": {
          "queries": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Query identifier (letter, e.g. `A`). The name `R` is reserved and must not be used."
                },
                "expr": {
                  "type": "string",
                  "description": "Query expression."
                },
                "label_fields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "value_fields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "args": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "relate_queries": {
            "type": "array",
            "description": "Optional auxiliary queries whose results are attached to alert events as context. Each entry must have a unique `name` (not duplicating any query name) and a non-empty `expr`.",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Relate-query identifier."
                },
                "expr": {
                  "type": "string",
                  "description": "Query expression."
                },
                "args": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "check_threshold": {
            "type": "object",
            "description": "Threshold check configuration.",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "alerting_check_times": {
                "type": "integer"
              },
              "recovery_check_times": {
                "type": "integer"
              },
              "push_recovery_event": {
                "type": "boolean"
              },
              "critical": {
                "type": "string"
              },
              "warning": {
                "type": "string"
              },
              "info": {
                "type": "string"
              },
              "recovery": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "invert",
                      "threshold",
                      "ql"
                    ]
                  },
                  "condition": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "check_anydata": {
            "type": "object",
            "description": "Any-data check configuration. Fires when the query returns any data rows.",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "alerting_check_times": {
                "type": "integer"
              },
              "recovery_check_times": {
                "type": "integer"
              },
              "push_recovery_event": {
                "type": "boolean"
              },
              "severity": {
                "type": "string",
                "enum": [
                  "Critical",
                  "Warning",
                  "Info"
                ]
              },
              "recovery": {
                "type": "object",
                "description": "Recovery condition for any-data check. If omitted or `mode` is empty, treated as `nodata`.",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "nodata",
                      "ql"
                    ],
                    "description": "`nodata` = recover when the query returns no data; `ql` = recover when the `condition` expression evaluates to true. When `mode` is `ql`, only a single query (`name=A`) is permitted."
                  },
                  "condition": {
                    "type": "string",
                    "description": "Recovery expression. Required when `mode` is `ql`."
                  },
                  "args": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "check_nodata": {
            "type": "object",
            "description": "No-data check configuration.",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "alerting_check_times": {
                "type": "integer"
              },
              "recovery_check_times": {
                "type": "integer"
              },
              "push_recovery_event": {
                "type": "boolean"
              },
              "severity": {
                "type": "string",
                "enum": [
                  "Critical",
                  "Warning",
                  "Info"
                ]
              },
              "resolve_timeout": {
                "type": "integer",
                "description": "Auto-resolve after N seconds."
              }
            }
          }
        }
      },
      "RuleCounterChannelResponse": {
        "type": "object",
        "description": "Map of channel name to rule count. Unresolved channel IDs appear as stringified IDs.",
        "additionalProperties": {
          "type": "integer",
          "format": "int64"
        }
      },
      "RuleCounterNodeResponse": {
        "type": "object",
        "description": "Map of top-level folder name to rule count.",
        "additionalProperties": {
          "type": "integer",
          "format": "int64"
        }
      },
      "RuleCounterTotalResponse": {
        "type": "array",
        "description": "Historical rule-count samples ordered by `clock` ascending.",
        "items": {
          "$ref": "#/components/schemas/AlertRuleCounter"
        }
      },
      "RuleDsTypesResponse": {
        "type": "array",
        "description": "Datasource types available to the account — global types plus account-scoped types.",
        "items": {
          "$ref": "#/components/schemas/DSType"
        }
      },
      "RuleEmptyRequest": {
        "type": "object",
        "description": "No parameters required.",
        "additionalProperties": false
      },
      "RuleEmptyResponse": {
        "type": "object",
        "description": "Empty response on success.",
        "additionalProperties": false
      },
      "RuleFieldsUpdateRequest": {
        "type": "object",
        "required": [
          "ids",
          "fields"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            },
            "description": "Rule IDs to update."
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Field names to update."
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "ds_type": {
            "type": "string"
          },
          "ds_list": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ds_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "debug_log_enabled": {
            "type": "boolean"
          },
          "cron_pattern": {
            "type": "string"
          },
          "timezone": {
            "type": "string",
            "description": "Timezone in which the rule executes. IANA timezone name; defaults to `Asia/Shanghai`.",
            "default": "Asia/Shanghai"
          },
          "delay_seconds": {
            "type": "integer"
          },
          "enabled_times": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EnabledTime"
            }
          },
          "annotations": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          },
          "channel_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            }
          },
          "repeat_interval": {
            "type": "integer",
            "format": "int64"
          },
          "repeat_total": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "RuleFolderIDRequest": {
        "type": "object",
        "properties": {
          "folder_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Folder ID. 0 for all."
          }
        }
      },
      "RuleIDRequest": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Rule ID."
          }
        }
      },
      "AuditRecordIDRequest": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Audit record ID — the `id` of an audit row returned by `POST /monit/rule/audits`, NOT the rule ID. Passing a rule ID returns HTTP 400."
          }
        }
      },
      "RuleIDsRequest": {
        "type": "object",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            },
            "description": "Rule IDs."
          }
        }
      },
      "RuleImportRequest": {
        "type": "array",
        "description": "Array of alert rule export objects to import.",
        "items": {
          "$ref": "#/components/schemas/AlertRule"
        }
      },
      "RuleImportResponse": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/NameMessage"
        },
        "description": "Import result for each rule."
      },
      "RuleListRequest": {
        "type": "object",
        "description": "Filter parameter for listing rules in a folder.",
        "properties": {
          "folder_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Folder ID. 0 to list all accessible rules."
          }
        }
      },
      "RuleMoveRequest": {
        "type": "object",
        "required": [
          "ids",
          "dest_folder_id"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "uint64"
            },
            "description": "Rule IDs to move."
          },
          "dest_folder_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Destination folder ID."
          }
        }
      },
      "RuleNameMessageListResponse": {
        "type": "array",
        "description": "Per-rule batch-operation results.",
        "items": {
          "$ref": "#/components/schemas/NameMessage"
        }
      },
      "RuleStatusResponse": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/AlertRuleStatus"
        }
      },
      "SLSLogstoresRequest": {
        "type": "object",
        "description": "Parameters for listing SLS logstores.",
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "SLS datasource ID."
          },
          "project": {
            "type": "string",
            "description": "SLS project name."
          },
          "offset": {
            "type": "integer",
            "description": "Pagination offset."
          },
          "size": {
            "type": "integer",
            "description": "Page size."
          }
        }
      },
      "SLSLogstoresResponse": {
        "type": "array",
        "description": "List of SLS logstore names.",
        "items": {
          "type": "string"
        }
      },
      "SLSProjectsRequest": {
        "type": "object",
        "description": "Parameters for listing SLS projects.",
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "SLS datasource ID."
          },
          "query": {
            "type": "string",
            "description": "Name prefix filter."
          },
          "offset": {
            "type": "integer",
            "description": "Pagination offset."
          },
          "size": {
            "type": "integer",
            "description": "Page size."
          }
        }
      },
      "SLSProjectsResponse": {
        "type": "array",
        "description": "List of SLS project names.",
        "items": {
          "type": "string"
        }
      },
      "StoreRulesetItem": {
        "type": "object",
        "description": "A rule repository ruleset.",
        "required": [
          "id",
          "type_ident",
          "note",
          "open_flag",
          "creator_account_id",
          "creator_id",
          "creator_name",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Ruleset ID."
          },
          "type_ident": {
            "type": "string",
            "description": "Datasource type identifier this ruleset applies to."
          },
          "note": {
            "type": "string",
            "description": "Description or title of the ruleset."
          },
          "open_flag": {
            "type": "integer",
            "enum": [
              0,
              1,
              2
            ],
            "description": "Sharing scope. `0` = private (creator only), `1` = account-shared, `2` = public."
          },
          "payload": {
            "type": "string",
            "description": "JSON string containing the alert rule definitions. Omitted in list responses."
          },
          "creator_account_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Account ID of the creator."
          },
          "creator_id": {
            "type": "integer",
            "format": "uint64",
            "description": "Member ID of the creator."
          },
          "creator_name": {
            "type": "string",
            "description": "Display name of the creator."
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "description": "Creation timestamp, Unix epoch seconds."
          },
          "updated_at": {
            "type": "integer",
            "format": "int64",
            "description": "Last update timestamp, Unix epoch seconds."
          }
        }
      },
      "StoreRulesetListRequest": {
        "type": "object",
        "required": [
          "type_ident"
        ],
        "description": "Filter rulesets by datasource type.",
        "properties": {
          "type_ident": {
            "type": "string",
            "description": "Datasource type identifier to filter by, e.g. `prometheus`."
          }
        }
      },
      "StoreRulesetListResponse": {
        "type": "array",
        "description": "Rulesets accessible to the current user. The `payload` field is omitted.",
        "items": {
          "$ref": "#/components/schemas/StoreRulesetItem"
        }
      },
      "StoreRulesetUpdateRequest": {
        "type": "object",
        "required": [
          "id",
          "note",
          "payload"
        ],
        "description": "Parameters for updating a ruleset.",
        "properties": {
          "id": {
            "type": "integer",
            "format": "uint64",
            "description": "Ruleset ID to update."
          },
          "note": {
            "type": "string",
            "description": "New description."
          },
          "open_flag": {
            "type": "integer",
            "enum": [
              0,
              1,
              2
            ],
            "description": "New sharing scope. `0` = private, `1` = account-shared, `2` = public."
          },
          "payload": {
            "type": "string",
            "description": "New JSON string of alert rule definitions."
          }
        }
      },
      "StoreRulesetUpsertRequest": {
        "type": "object",
        "description": "Request body for creating a ruleset. All fields are validated by `Validate()` on the server.",
        "required": [
          "type_ident",
          "note",
          "payload"
        ],
        "properties": {
          "type_ident": {
            "type": "string",
            "description": "Datasource type identifier this ruleset applies to, e.g. `prometheus`."
          },
          "note": {
            "type": "string",
            "description": "Description or title of the ruleset."
          },
          "open_flag": {
            "type": "integer",
            "enum": [
              0,
              1,
              2
            ],
            "description": "Sharing scope. `0` = private (creator only), `1` = account-shared, `2` = public. Defaults to `0` if omitted."
          },
          "payload": {
            "type": "string",
            "description": "JSON string containing the alert rule definitions."
          }
        }
      },
      "SuccessEnvelope": {
        "type": "object",
        "description": "Success response envelope. On every 2xx response, `request_id` identifies the call (also mirrored in the `Flashcat-Request-Id` header) and `data` holds the endpoint-specific payload. Failure responses use a different shape — see `ErrorResponse`.",
        "properties": {
          "request_id": {
            "type": "string",
            "description": "Unique ID for this request. Mirrored in the Flashcat-Request-Id response header. Include it when reporting issues.",
            "example": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
          },
          "data": {
            "description": "Endpoint-specific payload. See each operation's 200 response schema."
          }
        },
        "required": [
          "request_id",
          "data"
        ]
      },
      "QueryRowsRequest": {
        "type": "object",
        "required": [
          "ds_type",
          "ds_name",
          "expr"
        ],
        "properties": {
          "account_id": {
            "type": "integer",
            "format": "int64",
            "description": "Optional consistency check. Must equal the authenticated account when supplied; mismatched values are rejected. Business execution always uses the authenticated account."
          },
          "ds_type": {
            "type": "string",
            "description": "Data source type; must match a configured data source under the tenant. Examples: `prometheus`, `loki`, `victorialogs`, `sls`, `elasticsearch`, `mysql`, `postgres`, `oracle`, `clickhouse`."
          },
          "ds_name": {
            "type": "string",
            "description": "Data source name; must match a configured data source under the tenant."
          },
          "expr": {
            "type": "string",
            "description": "Query expression. Syntax depends on `ds_type` and is interpreted by the corresponding monit-edge client (PromQL for Prometheus, LogQL for Loki, SQL for SQL sources, etc.)."
          },
          "delay_seconds": {
            "type": "integer",
            "description": "Look-back offset in seconds applied to point-in-time queries (Prometheus, Loki stats, VictoriaLogs stats). Ignored for raw / detail queries.",
            "default": 0
          },
          "args": {
            "type": "object",
            "description": "Polymorphic key/value extension parameters forwarded verbatim to monit-edge. All values must be strings. Semantics depend on `ds_type`: SLS requires `sls.project` + `sls.logstore`; Loki / VictoriaLogs raw mode requires a time range via `<source>.start`/`<source>.end` or `<source>.timespan.value` + `<source>.timespan.unit`; Prometheus and SQL sources ignore it. Always namespace keys by source (e.g. `sls.project`, `loki.type`).",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "QueryRowsResponse": {
        "type": "array",
        "description": "Result rows. Different data sources populate `fields` vs `values` differently — metric sources (Prometheus, *-stats) put numbers into `values`; detail sources (SQL, SLS, raw logs) put data into `fields` and may return `values: null`.",
        "items": {
          "$ref": "#/components/schemas/QueryRow"
        }
      },
      "QueryRow": {
        "type": "object",
        "properties": {
          "fields": {
            "type": "object",
            "description": "String-valued fields (labels, log fields, SQL columns).",
            "additionalProperties": {
              "type": "string"
            }
          },
          "values": {
            "type": "object",
            "nullable": true,
            "description": "Numeric fields. For metric queries the canonical key is `__value__`. May be `null` for detail-oriented sources.",
            "additionalProperties": {
              "type": "number"
            }
          }
        }
      },
      "DiagnoseRequest": {
        "type": "object",
        "required": [
          "ds_type",
          "ds_name",
          "input"
        ],
        "properties": {
          "account_id": {
            "type": "integer",
            "format": "int64",
            "description": "Optional consistency check. Must equal the authenticated account when supplied."
          },
          "ds_type": {
            "type": "string",
            "description": "Data source type. `log_patterns` supports `loki` and `victorialogs`; `metric_trends` supports `prometheus`."
          },
          "ds_name": {
            "type": "string",
            "description": "Data source name configured under the tenant."
          },
          "operation": {
            "type": "string",
            "enum": [
              "log_patterns",
              "metric_trends"
            ],
            "description": "Diagnostic operation. When omitted, inferred from `ds_type` (loki / victorialogs → `log_patterns`, prometheus → `metric_trends`). Other sources must specify explicitly."
          },
          "time_range": {
            "type": "object",
            "description": "Diagnostic window in Unix seconds. Defaults to the last 15 minutes when missing or invalid; windows wider than 6 hours are rejected.",
            "properties": {
              "start": {
                "type": "integer",
                "format": "int64",
                "description": "Window start, Unix seconds."
              },
              "end": {
                "type": "integer",
                "format": "int64",
                "description": "Window end, Unix seconds."
              }
            }
          },
          "methods": {
            "type": "array",
            "description": "Diagnostic methods to run. When omitted, `log_patterns` defaults to `pattern_snapshot + pattern_compare(previous_window)` and `metric_trends` defaults to `single_window_shape + window_compare(previous_window)`.",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "`log_patterns` supports `pattern_snapshot`, `pattern_compare`. `metric_trends` supports `single_window_shape`, `window_compare`."
                },
                "baseline": {
                  "type": "string",
                  "enum": [
                    "previous_window",
                    "same_window_yesterday",
                    "same_window_last_week"
                  ],
                  "description": "Only meaningful for compare-style methods. Defaults to `previous_window`."
                }
              }
            }
          },
          "input": {
            "type": "object",
            "required": [
              "query"
            ],
            "properties": {
              "query": {
                "type": "string",
                "description": "Query expression. LogQL / VictoriaLogs query syntax for `log_patterns`; PromQL for `metric_trends`."
              }
            }
          },
          "options": {
            "type": "object",
            "description": "Execution options, all upper-bounded by monit-edge.",
            "properties": {
              "max_logs_scanned": {
                "type": "integer",
                "description": "Per-window log scan cap. Default 10 000, hard max 50 000."
              },
              "max_patterns": {
                "type": "integer",
                "description": "Max patterns returned. Default 20, hard max 50."
              },
              "examples_per_pattern": {
                "type": "integer",
                "description": "Max redacted examples per pattern. Default 2, hard max 3."
              },
              "step_seconds": {
                "type": "integer",
                "description": "`metric_trends` query_range step. Default 60, range [15, 300]."
              },
              "max_series": {
                "type": "integer",
                "description": "`metric_trends` max series considered. Default 50, hard max 200."
              },
              "topk": {
                "type": "integer",
                "description": "`metric_trends` max notable series returned. Default 10, hard max 50."
              },
              "timeout_seconds": {
                "type": "integer",
                "description": "Edge-side diagnostic timeout in seconds. Default 25, hard max 30."
              }
            }
          }
        }
      },
      "DiagnoseResponse": {
        "type": "object",
        "description": "Operation-specific diagnostic result. Inspect `operation` first, then `results[]`. The shape of `results[].patterns` (for `log_patterns`) vs `results[].series` (for `metric_trends`) differs by operation; the full schema is documented in the monit-webapi diagnose-api guide.",
        "properties": {
          "operation": {
            "type": "string",
            "enum": [
              "log_patterns",
              "metric_trends"
            ]
          },
          "ds_type": {
            "type": "string"
          },
          "ds_name": {
            "type": "string"
          },
          "query": {
            "type": "string",
            "description": "Query string echoed back from the request."
          },
          "window": {
            "type": "object",
            "properties": {
              "start": {
                "type": "integer",
                "format": "int64"
              },
              "end": {
                "type": "integer",
                "format": "int64"
              }
            }
          },
          "results": {
            "type": "array",
            "description": "One entry per `methods[]` in the request, in the same order.",
            "items": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string",
                  "description": "`pattern_snapshot` / `pattern_compare` for `log_patterns`; `single_window_shape` / `window_compare` for `metric_trends`."
                },
                "baseline": {
                  "type": "string",
                  "description": "Only present for compare-style methods."
                },
                "window": {
                  "type": "object",
                  "properties": {
                    "start": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "end": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "baseline_window": {
                  "type": "object",
                  "description": "Only present for compare-style methods.",
                  "properties": {
                    "start": {
                      "type": "integer",
                      "format": "int64"
                    },
                    "end": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "summary": {
                  "type": "object",
                  "description": "Aggregate summary for this method. Shape differs between `log_patterns` (logs_scanned, patterns_total, surging_threshold, …) and `metric_trends` (series_total, data_quality, observations, …)."
                },
                "patterns": {
                  "type": "array",
                  "description": "`log_patterns` only. Sorted RCA-first; each item carries pattern_hash, template, count, severity, sources, examples, and (for compare) baseline_count / change_ratio / is_new / is_gone.",
                  "items": {
                    "type": "object"
                  }
                },
                "series": {
                  "type": "array",
                  "description": "`metric_trends` only. Notable series with current / baseline / change / notable_period.",
                  "items": {
                    "type": "object"
                  }
                },
                "warnings": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Per-method advisory messages (e.g. `examples redacted`, sampling notices)."
                }
              }
            }
          }
        }
      },
      "ToolCatalogRequest": {
        "type": "object",
        "required": [
          "target_locator"
        ],
        "properties": {
          "account_id": {
            "type": "integer",
            "format": "int64",
            "description": "Optional consistency check. Must equal the authenticated account when supplied."
          },
          "target_locator": {
            "type": "string",
            "description": "Target identifier (host name, MySQL address, …). Max 256 bytes; no whitespace, control characters, or `|`."
          },
          "target_kind": {
            "type": "string",
            "description": "Optional target kind. When omitted webapi auto-infers across currently known kinds. Built-in kinds: `host`, `mysql`. Required on retry when the previous call returned `ambiguous_target_kind`."
          },
          "include_output_shape": {
            "type": "boolean",
            "description": "When true, each tool entry includes its `output_shape` JSON Schema. Defaults to false to keep responses small for LLM consumption.",
            "default": false
          }
        }
      },
      "ToolCatalogResponse": {
        "type": "object",
        "properties": {
          "target": {
            "type": "object",
            "nullable": true,
            "description": "Resolved target. `null` when locator could not be uniquely resolved.",
            "properties": {
              "kind": {
                "type": "string"
              },
              "locator": {
                "type": "string"
              }
            }
          },
          "tools": {
            "type": "array",
            "description": "Tool catalog entries. Empty when `error` is non-null.",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Tool name; pass into `/monit/tools/invoke` as `tools[].tool`."
                },
                "target_kind": {
                  "type": "string",
                  "description": "Target kind this tool applies to."
                },
                "description": {
                  "type": "string",
                  "description": "Tool capability description for UI / AI-SRE consumption."
                },
                "input_schema": {
                  "type": "object",
                  "description": "JSON Schema for `tools[].params`."
                },
                "output_shape": {
                  "type": "object",
                  "description": "Optional output JSON Schema; only returned when `include_output_shape=true`."
                }
              }
            }
          },
          "error": {
            "type": "object",
            "nullable": true,
            "description": "Business error. `null` on success.",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "target_unavailable",
                  "unknown_toolset_hash",
                  "ambiguous_target_kind"
                ]
              },
              "message": {
                "type": "string"
              },
              "target_kinds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Returned for `ambiguous_target_kind`; lists the candidate kinds."
              }
            }
          }
        }
      },
      "ToolInvokeRequest": {
        "type": "object",
        "required": [
          "target_locator",
          "tools"
        ],
        "properties": {
          "account_id": {
            "type": "integer",
            "format": "int64",
            "description": "Optional consistency check. Must equal the authenticated account when supplied."
          },
          "target_locator": {
            "type": "string",
            "description": "Target identifier. Same validation rules as `/monit/tools/catalog`."
          },
          "target_kind": {
            "type": "string",
            "description": "Optional target kind; auto-inferred when omitted."
          },
          "tools": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "description": "Up to 8 tool calls; webapi executes them concurrently and returns results in input order.",
            "items": {
              "type": "object",
              "required": [
                "tool"
              ],
              "properties": {
                "tool": {
                  "type": "string",
                  "description": "Tool name, typically from `/monit/tools/catalog`."
                },
                "params": {
                  "type": "object",
                  "description": "Tool parameters matching the catalog `input_schema`. For no-arg tools pass `{}` explicitly.",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "ToolInvokeResponse": {
        "type": "object",
        "properties": {
          "target": {
            "type": "object",
            "nullable": true,
            "description": "Resolved target.",
            "properties": {
              "kind": {
                "type": "string"
              },
              "locator": {
                "type": "string"
              }
            }
          },
          "results": {
            "type": "array",
            "description": "Per-tool results aligned with the request `tools[]` order. Empty when `error` is non-null.",
            "items": {
              "type": "object",
              "properties": {
                "tool": {
                  "type": "string"
                },
                "tool_version": {
                  "type": "string",
                  "description": "Agent-executed tool version. Empty when execution failed before the agent picked a version."
                },
                "data": {
                  "type": "object",
                  "nullable": true,
                  "description": "Successful tool payload — passthrough of monit-agent `ToolResultPayload.data` (typically `data` / `summary` / `truncated`). `null` when the per-tool `error` is set."
                },
                "error": {
                  "type": "object",
                  "nullable": true,
                  "description": "Per-tool error. Mutually exclusive with `data`.",
                  "properties": {
                    "code": {
                      "type": "string",
                      "description": "Common values: `timeout`, `target_unavailable`, `edge_unsupported`, `invalid_tool_result`, `internal`, `invalid_args`, `unknown_tool`, `unknown_tool_version`, `unknown_toolset_hash`, `target_not_owned`, `wrong_agent`, `overloaded`, `denied`, `permission_denied`, `credential_unavailable`, `target_unreachable`."
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "agent_elapsed_ms": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Agent-self-reported tool execution time in milliseconds, excludes network. May be 0 when the failure occurred before the agent started executing."
                },
                "e2e_elapsed_ms": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Webapi-observed end-to-end time in milliseconds (webapi → ws → edge → agent → ws → webapi). A large gap vs `agent_elapsed_ms` indicates network / edge slowness."
                }
              }
            }
          },
          "error": {
            "type": "object",
            "nullable": true,
            "description": "Request-level business error. `null` on success.",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "target_unavailable",
                  "unknown_toolset_hash",
                  "forward_failed",
                  "invalid_tool_result",
                  "ambiguous_target_kind"
                ]
              },
              "message": {
                "type": "string"
              },
              "target_kinds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "TargetsListRequest": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "integer",
            "format": "int64",
            "description": "Optional consistency check. Must equal the authenticated account when supplied."
          },
          "keyword": {
            "type": "string",
            "description": "Prefix match against `target_locator`. ASCII only, no whitespace, no `|`, max 256 bytes. Substring search is not supported."
          },
          "limit": {
            "type": "integer",
            "description": "Page size. Default 50, max 200.",
            "default": 50,
            "maximum": 200
          },
          "cursor": {
            "type": "string",
            "description": "Opaque pagination cursor from the previous response's `next_cursor`. Omit / pass empty string for the first page. Reset whenever `keyword`, `limit`, or tenant changes."
          }
        }
      },
      "TargetsListResponse": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "target_kind": {
                  "type": "string",
                  "description": "Target kind, e.g. `host`, `mysql`. Filtering by kind is not supported in v1."
                },
                "target_locator": {
                  "type": "string",
                  "description": "Target identifier; the list is sorted by this field ascending."
                },
                "agent_version": {
                  "type": "string",
                  "description": "Most recently observed Agent version."
                },
                "cluster_name": {
                  "type": "string",
                  "description": "Edge cluster name."
                },
                "edge_ipport": {
                  "type": "string",
                  "description": "Edge instance address (`ip:port`), surfaced for diagnostics."
                },
                "updated_at": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Last route-projection upsert time, Unix seconds. Treat as 'most recently observed', not a live-online indicator."
                }
              }
            }
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Total matches for the current `(account_id, keyword)` pair, independent of `cursor`."
          },
          "next_cursor": {
            "type": "string",
            "description": "Opaque cursor for the next page. Absent / empty means this is the last page."
          }
        }
      },
      "PreviewSyncRequest": {
        "type": "object",
        "required": [
          "ds_type",
          "ds_name",
          "expr"
        ],
        "description": "Parameters for a synchronous datasource query preview.",
        "properties": {
          "ds_type": {
            "type": "string",
            "description": "Datasource type, e.g. `prometheus`, `loki`, `elasticsearch`."
          },
          "ds_name": {
            "type": "string",
            "description": "Datasource display name as configured in the account."
          },
          "expr": {
            "type": "string",
            "description": "Query expression. Format depends on `ds_type` (PromQL for Prometheus, LogQL for Loki, etc.)."
          },
          "delay_seconds": {
            "type": "integer",
            "description": "Shift the query window backward by this many seconds to compensate for data ingestion latency."
          },
          "args": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Additional type-specific query arguments."
          }
        }
      },
      "PreviewSyncResponse": {
        "type": "object",
        "description": "Raw JSON response from the datasource. Schema varies by datasource type."
      }
    }
  }
}