POST /api/v1/monitors/apply
Authenticate with Authorization: Bearer YOUR_API_KEY and X-Project-Id: YOUR_PROJECT_ID. Replace path placeholders and example values with your project's values.
Parameters
| Name | Location | Type | Presence | Description |
|---|---|---|---|---|
X-Project-Id | header | string (uuid) | Required | Project UUID. Use the project associated with your API key. |
Request Body
Create request.json with the fields this operation requires. The examples read that file.
JSON schema
{
"oneOf": [
{
"properties": {
"active": {
"type": "boolean"
},
"alert_recovery_threshold": {
"format": "double",
"type": "number"
},
"alert_threshold": {
"format": "double",
"type": "number"
},
"check_interval_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"email_all": {
"type": "boolean"
},
"emails": {
"items": {
"type": "string"
},
"type": "array"
},
"environment": {
"type": "string"
},
"message": {
"type": "string"
},
"notify_after_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"query": {
"type": "string"
},
"service": {
"type": "string"
},
"severity": {
"type": "string"
},
"slack_channels": {
"items": {
"type": "string"
},
"type": "array"
},
"stop_after_count": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"subject": {
"type": "string"
},
"teams": {
"items": {
"$ref": "#/components/schemas/UUID"
},
"type": "array"
},
"threshold_sustained_for_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"time_window_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"title": {
"type": "string"
},
"trigger_less_than": {
"type": "boolean"
},
"unit": {
"type": "string"
},
"visualization_type": {
"type": "string"
},
"warning_recovery_threshold": {
"format": "double",
"type": "number"
},
"warning_threshold": {
"format": "double",
"type": "number"
}
},
"required": [
"title",
"query",
"alert_threshold",
"trigger_less_than",
"check_interval_mins",
"time_window_mins",
"emails",
"slack_channels",
"teams"
],
"type": "object"
},
{
"$ref": "#/components/schemas/MonitorConfig"
}
]
}Examples
curl --request POST 'https://api.monoscope.tech/api/v1/monitors/apply' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'X-Project-Id: YOUR_PROJECT_ID' \
--header 'Content-Type: application/json' \
--data-binary @request.jsonimport requests
import json
with open("request.json") as body_file:
payload = json.load(body_file)
response = requests.post(
"https://api.monoscope.tech/api/v1/monitors/apply",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"X-Project-Id": "YOUR_PROJECT_ID",
"Content-Type": "application/json"
},
json=payload,
timeout=30,
)
response.raise_for_status()
print(response.text)import { readFile } from "node:fs/promises";
const payload = await readFile("request.json", "utf8");
const response = await fetch("https://api.monoscope.tech/api/v1/monitors/apply", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"X-Project-Id": "YOUR_PROJECT_ID",
"Content-Type": "application/json"
},
body: payload,
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
console.log(await response.text());Responses
HTTP 200
Response defined by the API schema.
| Field | Type | Presence | Description |
|---|---|---|---|
alert_config | object | Required | |
alert_last_triggered | string (yyyy-mm-ddThh:MM:ssZ) | Optional | |
alert_recovery_threshold | number (double) | Optional | |
alert_threshold | number (double) | Required | |
check_interval_mins | integer | Required | |
created_at | string (yyyy-mm-ddThh:MM:ssZ) | Required | |
current_status | normal | warning | alerting | Required | |
current_value | number (double) | Required | |
dashboard_id | string (uuid) | Optional | |
deactivated_at | string (yyyy-mm-ddThh:MM:ssZ) | Optional | |
deleted_at | string (yyyy-mm-ddThh:MM:ssZ) | Optional | |
environment | string | Optional | |
id | string (uuid) | Required | |
last_evaluated | string (yyyy-mm-ddThh:MM:ssZ) | Optional | |
log_query | string | Required | |
log_query_as_sql | string | Required | |
muted_until | string (yyyy-mm-ddThh:MM:ssZ) | Optional | |
notification_count | integer | Required | |
project_id | string (uuid) | Required | |
renotify_interval_mins | integer | Optional | |
service | string | Optional | |
stop_after_count | integer | Optional | |
teams | string (uuid)[] | Required | |
threshold_sustained_for_mins | integer | Required | |
time_window_mins | integer | Required | |
trigger_less_than | boolean | Required | |
updated_at | string (yyyy-mm-ddThh:MM:ssZ) | Required | |
visualization_type | string | Required | |
warning_last_triggered | string (yyyy-mm-ddThh:MM:ssZ) | Optional | |
warning_recovery_threshold | number (double) | Optional | |
warning_threshold | number (double) | Optional | |
widget_id | string | Optional |
JSON schema
{
"properties": {
"alert_config": {
"$ref": "#/components/schemas/MonitorAlertConfig"
},
"alert_last_triggered": {
"$ref": "#/components/schemas/UTCTime"
},
"alert_recovery_threshold": {
"format": "double",
"type": "number"
},
"alert_threshold": {
"format": "double",
"type": "number"
},
"check_interval_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"created_at": {
"$ref": "#/components/schemas/UTCTime"
},
"current_status": {
"enum": [
"normal",
"warning",
"alerting"
],
"type": "string"
},
"current_value": {
"format": "double",
"type": "number"
},
"dashboard_id": {
"$ref": "#/components/schemas/UUID"
},
"deactivated_at": {
"$ref": "#/components/schemas/UTCTime"
},
"deleted_at": {
"$ref": "#/components/schemas/UTCTime"
},
"environment": {
"type": "string"
},
"id": {
"$ref": "#/components/schemas/UUID"
},
"last_evaluated": {
"$ref": "#/components/schemas/UTCTime"
},
"log_query": {
"type": "string"
},
"log_query_as_sql": {
"type": "string"
},
"muted_until": {
"$ref": "#/components/schemas/UTCTime"
},
"notification_count": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"project_id": {
"$ref": "#/components/schemas/UUID"
},
"renotify_interval_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"service": {
"type": "string"
},
"stop_after_count": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"teams": {
"items": {
"$ref": "#/components/schemas/UUID"
},
"type": "array"
},
"threshold_sustained_for_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"time_window_mins": {
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"type": "integer"
},
"trigger_less_than": {
"type": "boolean"
},
"updated_at": {
"$ref": "#/components/schemas/UTCTime"
},
"visualization_type": {
"type": "string"
},
"warning_last_triggered": {
"$ref": "#/components/schemas/UTCTime"
},
"warning_recovery_threshold": {
"format": "double",
"type": "number"
},
"warning_threshold": {
"format": "double",
"type": "number"
},
"widget_id": {
"type": "string"
}
},
"required": [
"id",
"project_id",
"created_at",
"updated_at",
"check_interval_mins",
"alert_threshold",
"log_query",
"log_query_as_sql",
"trigger_less_than",
"threshold_sustained_for_mins",
"alert_config",
"visualization_type",
"teams",
"current_status",
"current_value",
"notification_count",
"time_window_mins"
],
"type": "object"
}HTTP 400
Refused; error.code says why
| Field | Type | Presence | Description |
|---|---|---|---|
error | object | Required |
JSON schema
{
"properties": {
"error": {
"$ref": "#/components/schemas/ApiProblem"
}
},
"required": [
"error"
],
"type": "object"
}HTTP 401
Refused; error.code says why
| Field | Type | Presence | Description |
|---|---|---|---|
error | object | Required |
JSON schema
{
"properties": {
"error": {
"$ref": "#/components/schemas/ApiProblem"
}
},
"required": [
"error"
],
"type": "object"
}HTTP 404
Refused; error.code says why
| Field | Type | Presence | Description |
|---|---|---|---|
error | object | Required |
JSON schema
{
"properties": {
"error": {
"$ref": "#/components/schemas/ApiProblem"
}
},
"required": [
"error"
],
"type": "object"
}