# Reference API pro monitory

Source: https://instatus.com/help/cs/api/monitors

- [Monitors](https://instatus.com/help/cs/api/monitors#get-monitors): Check the uptime of your websites, APIs, and services
- [Cron Monitors](https://instatus.com/help/cs/api/monitors#cron-monitors): Monitor your scheduled jobs via HTTP pings

## Možné hodnoty polí

**Lokalita monitoru**

| Hodnota          | Popis             |
| ---------------- | ----------------- |
| `US_EAST_1`      | Severní Virginie  |
| `CA_CENTRAL_1`   | Kanada (Montreal) |
| `EU_CENTRAL_1`   | Frankfurt         |
| `AP_NORTHEAST_1` | Tokio             |

**Typy upozornění monitoru**

| Hodnota           | Popis                 |
| ----------------- | --------------------- |
| `INCIDENT`        | Upozornění incidentem |
| `EMAIL`           | Upozornění e-mailem   |
| `SMS`             | Upozornění SMS        |
| `SLACK`           | Upozornění do Slacku  |
| `DISCORD`         | Upozornění do Discordu |
| `MICROSOFT_TEAMS` | Upozornění do Microsoft Teams |
| `PHONE_CALL`      | Upozornění telefonátem |
| `WEBHOOK`         | Upozornění webhookem  |
| `GOOGLE_CHAT`     | Upozornění do Google Chatu |
| `WHATSAPP`        | Upozornění na WhatsApp |

**Stav monitoru**

| Hodnota    | Popis                             |
| ---------- | --------------------------------- |
| `UP`       | Monitor běží normálně             |
| `DOWN`     | Monitor selhal                    |
| `DEGRADED` | Monitor má potíže                 |
| `UNKNOWN`  | Stav monitoru nelze určit         |

## Získání monitorů

Tímto endpointem najdete a projdete seznam všech existujících monitorů.

**Endpoint:**

```bash
GET /:page_id/monitors
```

**Parametry dotazu**

| Parametr  | Typ      | Výchozí hodnota | Popis                                        |
| --------- | -------- | ------------- | ------------------------------------------------------ |
| `page`    | `number` | `1`           | Číslo stránky, kterou načíst.                          |
| `limit`   | `number` | `100`         | Počet monitorů na stránku.                             |
| `search`  | `string` | `null`        | Hledaný výraz pro filtrování výsledků.                 |
| `status`  | `enum`   | `null`        | Filtr stavu _('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')_.   |

**Ukázkový požadavek**

```bash
GET /1/monitors?limit=3&page=2&status=DOWN
```

**Ukázková odpověď**

```json
{
  "monitors": [{ "...": "monitor objects" }],
  "total": 10,
  "page": 3,
  "totalPages": 5,
  "limit": 2
}
```

## Vytvoření monitoru

**Endpoint:**

```bash
POST /monitors
```

**Ukázkový požadavek**

```json
{
  "pageId": "page123",
  "url": "https://example.com",
  "httpMethod": "GET",
  "body": null,
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer token"
  },
  "queryParams": {
    "search": "test",
    "limit": "10"
  },
  "basicAuth": {
    "username": "user",
    "password": "password"
  },
  "type": "HTTP",
  "assertions": [
    {
      "type": "STATUSCODE",
      "comparison": "EQUALS",
      "selector": null,
      "target": "200"
    }
  ],
  "alerts": ["alert-id-1", "alert-id-2"],
  "name": "Example Monitor",
  "locations": "US_EAST_1",
  "checksInterval": 300,
  "createComponent": true,
  "createMetric": true,
  "onFail": {
    "createIncident": true,
    "createOutageDuration": true,
    "publishIncident": true,
    "notifySubscribers": true
  },
  "onRecover": {
    "resolveIncident": true,
    "resolveOutageDuration": true,
    "publishIncident": true,
    "notifySubscribers": true
  }
}
```

**Ukázková odpověď**

```json
{
  "monitor": {
    "pageId": "page123",
    "url": "https://example.com",
    "httpMethod": "GET",
    "body": null,
    "headers": {
      "Content-Type": "application/json",
      "Authorization": "Bearer token"
    },
    "queryParams": {
      "search": "test",
      "limit": "10"
    },
    "basicAuth": {
      "username": "user",
      "password": "password"
    },
    "type": "HTTP",
    "assertions": [
      {
        "id": "assertion1",
        "type": "STATUSCODE",
        "comparison": "EQUALS",
        "selector": null,
        "target": "200"
      }
    ],
    "alerts": ["alert1", "alert2"],
    "name": "Example Monitor",
    "locations": "US_EAST_1",
    "checksInterval": 300,
    "createComponent": true,
    "createMetric": true,
    "onFail": {
      "createIncident": true,
      "createOutageDuration": true,
      "publishIncident": true,
      "notifySubscribers": true
    },
    "onRecover": {
      "resolveIncident": true,
      "resolveOutageDuration": true,
      "publishIncident": true,
      "notifySubscribers": true
    },
    "createdAt": "2023-08-08T12:00:00Z",
    "updatedAt": "2023-08-08T12:00:00Z"
  },
  "message": "Monitor created successfully"
}
```

## Aktualizace monitoru

**Endpoint:**

```bash
PUT /monitors/:id
```

**Ukázkový požadavek**

```json
{
  "url": "https://updated.com",
  "name": "Updated Monitor Name"
}
```

**Ukázková odpověď**

```json
{
  "monitor": {
    "pageId": "page123",
    "url": "https://updated.com",
    "httpMethod": "GET",
    "body": null,
    "headers": {
      "Content-Type": "application/json",
      "Authorization": "Bearer token"
    },
    "queryParams": {
      "search": "test",
      "limit": "10"
    },
    "basicAuth": {
      "username": "user",
      "password": "password"
    },
    "type": "HTTP",
    "assertions": [
      {
        "id": "assertion1",
        "type": "STATUSCODE",
        "comparison": "EQUALS",
        "selector": null,
        "value": "200"
      }
    ],
    "alerts": ["alert1", "alert2"],
    "name": "Updated Monitor Name",
    "locations": "US_EAST_1",
    "checksInterval": 300,
    "createComponent": true,
    "createMetric": true,
    "onFail": {
      "createIncident": true,
      "createOutageDuration": true,
      "publishIncident": true,
      "notifySubscribers": true
    },
    "onRecover": {
      "resolveIncident": true,
      "resolveOutageDuration": true,
      "publishIncident": true,
      "notifySubscribers": true
    },
    "createdAt": "2023-08-08T12:00:00Z",
    "updatedAt": "2023-08-08T12:00:00Z"
  },
  "message": "Monitor updated successfully"
}
```

## Smazání monitoru

**Endpoint:**

```bash
DELETE /monitors/:id
```

**Ukázkový požadavek**

```bash
DELETE /monitors/monitor-id-1
```

**Ukázková odpověď**

```json
{
  "message": "Monitor deleted successfully."
}
```

## Získání logů monitoru

**Endpoint:**

```bash
GET /monitors/:id/logs
```

# Parametry dotazu

| Parametr               | Typ                                     | Výchozí hodnota | Popis                                                                                   |
| ---------------------- | --------------------------------------- | --------------- | --------------------------------------------------------------------------------------- |
| `limit`                | `number`                                | 100             | Počet položek na stránku. Nesmí přesáhnout 1000.                                        |
| `page`                 | `number`                                | 1               | Číslo stránky, kterou načíst.                                                           |
| `monitorId`            | `string`                                | -               | ID monitoru.                                                                            |
| `location`             | `string`                                | `null`          | Lokalita monitoru.                                                                      |
| `createdAt`            | `string` \| `object` \| `number`        | `null`          | Datum vytvoření. Může to být řetězec, číslo nebo objekt s poli `gte` a `lte`.           |
| `isSuccessful`         | `boolean`                               | `null`          | Jestli byla kontrola úspěšná.                                                           |
| `isSSLCheck`           | `boolean`                               | `null`          | Jestli jde o SSL kontrolu.                                                              |
| `httpStatusCode`       | `string`                                | `null`          | HTTP stavový kód odpovědi.                                                              |
| `status`               | `('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')` | `null`          | Stav monitoru.                                                                          |
| `dnsTime`              | `string` \| `number` \| `object`        | `null`          | Doba překladu DNS.                                                                      |
| `tcpTime`              | `string` \| `number` \| `object`        | `null`          | Doba navázání TCP spojení.                                                              |
| `tlsTime`              | `string` \| `number` \| `object`        | `null`          | Doba TLS handshaku.                                                                     |
| `firstByteTime`        | `string` \| `number` \| `object`        | `null`          | Doba do přijetí prvního bajtu.                                                          |
| `downloadTime`         | `string` \| `number` \| `object`        | `null`          | Doba stahování.                                                                         |
| `responseTime`         | `string` \| `number` \| `object`        | `null`          | Celková doba odezvy.                                                                    |
| `performanceTime`      | `string` \| `number` \| `object`        | `null`          | Doba výkonu.                                                                            |
| `accessabilityScore`   | `string` \| `number` \| `object`        | `null`          | Skóre přístupnosti.                                                                     |
| `seoScore`             | `string` \| `number` \| `object`        | `null`          | Skóre SEO.                                                                              |
| `bestPracticesScore`   | `string` \| `number` \| `object`        | `null`          | Skóre best practices.                                                                   |
| `successfulAssertions` | `string` \| `number` \| `object`        | `null`          | Počet úspěšných podmínek.                                                               |
| `sort`                 | `string`                                | chronologicky   | Pole, podle kterého řadit.                                                              |

**Ukázkový požadavek**

```bash
GET /monitors/monitor-id-1/logs?limit=100&page=1
```

**Ukázková odpověď**

```json
{
  "monitorLogs": [
    // {monitor log object},
    // {monitor log object 2}
  ],
  "total": 478,
  "page": 1,
  "totalPages": 5,
  "limit": 100
}
```

## Spuštění kontroly monitoru podle ID

**Endpoint:**

```bash
GET /monitors/:id/run
```

**Parametry dotazu**

| Parametr       | Typ                                                                               | Výchozí hodnota | Popis                                                           |
| -------------- | --------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------- |
| `location`     | `'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'` | -             | Lokalita monitoru. Musí být jedna z uvedených hodnot.             |
| `retry`        | `boolean`                                                                         | `false`       | Určuje, jestli se má operace zopakovat. Nepovinné.                |
| `monitorLogId` | `string`                                                                          | `null`        | Jedinečný identifikátor logu monitoru. Nepovinné.                 |

**Ukázkový požadavek**

```bash
GET /monitors/monitor-id-1/run?monitorId=abc123&location=US_EAST_1&retry=true&monitorLogId=log456
```

**Ukázková odpověď**

```json
{
  "status": "success",
  "message": "Monitor check run successfully."
}
```

## Vytvoření upozornění monitoru

**Endpoint:**

```bash
POST /monitor-alerts
```

**Ukázkový požadavek**

```json
{
  "type": "EMAIL",
  "pageId": "page123",
  "recipient": "user@example.com",
  "recipientWorkspace": "workspace123",
  "whenFails": true,
  "whenRecovers": true,
  "whenDegrades": false,
  "whenSslExpires": true,
  "sslExpiresInDays": 30,
  "monitors": ["monitor1", "monitor2"],
  "metadata": "Additional information about the alert"
}
```

**Ukázková odpověď**

```json
{
  "monitor": {
    "id": "alert123",
    "siteId": "site123",
    "type": "EMAIL",
    "recipient": "user@example.com",
    "whenFails": true,
    "whenRecovers": true,
    "whenDegrades": false,
    "whenSslExpires": true,
    "sslExpiresInDays": 30,
    "monitors": [{ "id": "monitor1" }, { "id": "monitor2" }],
    "createdAt": "2023-08-08T12:00:00Z",
    "updatedAt": "2023-08-08T12:00:00Z",
    "metadata": "Additional information about the alert"
  },
  "message": "Monitor Alert created successfully"
}
```

## Aktualizace upozornění monitoru

**Endpoint:**

```bash
PUT /monitor-alerts/:id
```

**Ukázkový požadavek**

```json
{
  "type": "EMAIL",
  "monitors": ["monitor-1-id", "monitor-2-id", "monitor-3-id"]
}
```

**Ukázková odpověď**

```json
{
  "monitor": {
    "type": "EMAIL",
    "pageId": "page123",
    "recipient": "user@example.com",
    "recipientWorkspace": "workspace123",
    "whenFails": true,
    "whenRecovers": true,
    "whenDegrades": false,
    "whenSslExpires": true,
    "sslExpiresInDays": 30,
    "monitors": ["monitor-1-id", "monitor-2-id"],
    "metadata": "Additional information about the alert"
  },
  "message": "Monitor alert updated successfully."
}
```

## Získání upozornění monitoru

**Endpoint:**

```bash
GET /:page_id/monitor-alerts
```

**Parametry dotazu**

| Parametr  | Typ      | Výchozí hodnota | Popis                       |
| --------- | -------- | ------------- | ----------------------------- |
| `limit`   | `number` | 100           | Počet položek na stránku.     |
| `page`    | `number` | 1             | Číslo stránky, kterou načíst. |

**Ukázkový požadavek**

```bash
GET /1/monitor-alerts?limit=2&page=3
```

**Ukázková odpověď**

```json
{
  "monitorAlerts": [
    {...monitor alert objects}
  ],
  "total": 27,
  "page": 3,
  "totalPages": 14,
  "limit": 2
}
```

## Smazání upozornění monitoru

**Endpoint:**

```bash
DELETE /monitor-alerts/:id
```

**Ukázkový požadavek**

```bash
DELETE /monitor-alerts/alert-id-1
```

**Ukázková odpověď**

```json
{
  "message": "Monitor alert deleted successfully."
}
```

## Vytvoření skupiny monitorů

**Endpoint:**

```bash
POST /monitors-groups
```

**Ukázkový požadavek**

```json
{
  "pageId": "page123",
  "name": "Example Name",
  "childId": "child456"
}
```

**Ukázková odpověď**

```json
{
  "monitor": {
    "id": "group123",
    "name": "Example Name",
    "siteId": "site123",
    "collapsed": false,
    "monitors": [{ "id": "monitor1" }, { "id": "monitor2" }],
    "groupId": "parentGroup123",
    "children": [
      { "id": "childGroup1", "name": "Child Group 1" },
      { "id": "childGroup2", "name": "Child Group 2" }
    ],
    "order": 1,
    "createdAt": "2023-08-08T12:00:00Z",
    "updatedAt": "2023-08-08T12:00:00Z",
    "parents": ["parent1", "parent2"],
    "componentId": "component123"
  },
  "message": "Monitor group created successfully."
}
```

## Aktualizace skupiny monitorů

**Endpoint:**

```bash
PUT /monitors-groups/:id
```

**Ukázkový požadavek**

```json
{
  "name": "Updated Monitor Group Name"
}
```

**Ukázková odpověď**

```json
{
  "monitor": {
    "id": "group123",
    "name": "Updated Monitor Group Name",
    "siteId": "site123",
    "collapsed": true,
    "monitors": [{ "id": "monitor1" }, { "id": "monitor2" }],
    "groupId": "parentGroup123",
    "children": [
      { "id": "childGroup1", "name": "Child Group 1" },
      { "id": "childGroup2", "name": "Child Group 2" }
    ],
    "order": 1,
    "createdAt": "2023-08-08T12:00:00Z",
    "updatedAt": "2023-08-08T12:00:00Z",
    "parents": ["parent1", "parent2"],
    "componentId": "component123"
  },
  "message": "Monitor group updated successfully."
}
```

## Smazání skupiny monitorů

**Endpoint:**

```bash
DELETE /monitors-groups/:id
```

**Ukázkový požadavek**

```bash
DELETE /monitors-groups/group-id-1
```

**Ukázková odpověď**

```json
{
  "message": "Monitor group deleted successfully."
}
```

## Přidání monitorů do skupiny

**Endpoint:**

```bash
POST /monitors-groups/:id/monitors
```

**Ukázkový požadavek**

```json
{
  "monitors": ["monitor1", "monitor2", "monitor3"]
}
```

**Ukázková odpověď**

```json
{
  "message": "Monitors added to the group successfully."
}
```

## Spuštění kontroly skupiny monitorů

**Endpoint:**

```bash
GET /monitors-groups/:id/run
```

**Parametry dotazu**

| Parametr       | Typ                                                                               | Výchozí hodnota | Popis                                                           |
| -------------- | --------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------- |
| `location`     | `'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'` | -             | Lokalita monitoru. Musí být jedna z uvedených hodnot.             |
| `retry`        | `boolean`                                                                         | `false`       | Určuje, jestli se má operace zopakovat. Nepovinné.                |
| `monitorLogId` | `string`                                                                          | `null`        | Jedinečný identifikátor logu monitoru. Nepovinné.                 |

**Ukázkový požadavek**

```bash
GET /monitors-groups/group-id-1/run
```

**Ukázková odpověď**

```json
{
  "result": "OK",
  "monitorLogId": "monitor-log-id-1"
}
```

## Cron monitory

Cron monitory sledují naplánované úlohy pomocí HTTP pingů. Nastavení v produktu a práci v dashboardu popisuje článek [Cron monitoring](https://instatus.com/help/cs/monitoring/cron).

### Možné hodnoty polí

**Stav cron monitoru**

| Hodnota    | Popis                             |
| ---------- | --------------------------------- |
| `UP`       | Monitor běží normálně             |
| `DOWN`     | Monitor selhal                    |
| `DEGRADED` | Monitor má potíže                 |
| `UNKNOWN`  | Stav monitoru nelze určit         |

**Režim cron monitoru**

| Hodnota  | Popis                                |
| -------- | ------------------------------------ |
| `ACTIVE` | Monitor se aktivně kontroluje        |
| `PAUSED` | Kontroly monitoru jsou pozastavené   |
| `MUTED`  | Monitor je ztlumený (bez oznámení)   |

**Stav logu cron monitoru**

| Hodnota   | Popis                                            |
| --------- | ------------------------------------------------ |
| `SUCCESS` | Úloha úspěšně doběhla                            |
| `FAILURE` | Úloha výslovně nahlásila selhání               |
| `MISSED`  | Úloha nepingla v očekávaném okně                 |
| `LATE`    | Úloha pingla po periodě, ale v rámci tolerance   |
| `STARTED` | Úloha nahlásila, že začala (měření doby běhu)    |

**Perioda a tolerance**

`period` i `grace` se zadávají v **sekundách**. `period` je, jak často má úloha běžet; `grace` je čas navíc, než se monitor označí za nedostupný.

### Získání cron monitorů

**Endpoint:**

```bash
GET /:page_id/monitors/cron
```

**Parametry dotazu**

| Parametr  | Typ      | Výchozí hodnota | Popis                                        |
| --------- | -------- | ------------- | ------------------------------------------------------ |
| `limit`   | `number` | `100`         | Počet cron monitorů na stránku. Maximum je 100.        |
| `page`    | `number` | `1`           | Číslo stránky.                                         |
| `search`  | `string` | `null`        | Hledaný výraz pro filtrování výsledků podle názvu.     |
| `status`  | `enum`   | `null`        | Filtr stavu _('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')_.   |

**Ukázkový požadavek**

```bash
GET /page123/monitors/cron?limit=10&page=1&status=DOWN
```

**Ukázková odpověď**

```json
{
  "cronMonitors": [
    {
      "id": "cron-abc123",
      "name": "Daily backup",
      "slug": "my-page-x7k2m9n4p1q8w3e5",
      "period": 86400,
      "grace": 3600,
      "status": "UP",
      "state": "ACTIVE",
      "siteId": "page123",
      "order": 1,
      "groupId": null,
      "componentId": "component-id-1",
      "onFailCreateIncident": true,
      "onFailCreateOutageDuration": false,
      "onFailPublishIncident": true,
      "onFailNotifySubscribers": true,
      "onRecoverResolveIncident": true,
      "onRecoverResolveOutageDuration": false,
      "onRecoverPublishIncident": true,
      "onRecoverNotifySubscribers": true,
      "createTemplateId": null,
      "resolveTemplateId": null,
      "createdAt": "2024-01-15T08:00:00.000Z",
      "updatedAt": "2024-01-15T08:00:00.000Z"
    }
  ],
  "total": 1,
  "page": 1,
  "totalPages": 1,
  "limit": 10
}
```

### Vytvoření cron monitoru

**Endpoint:**

```bash
POST /monitors/cron
```

**Ukázkový požadavek**

```json
{
  "pageId": "page123",
  "name": "Daily backup",
  "period": 86400,
  "grace": 3600,
  "alerts": ["alert-id-1", "alert-id-2"],
  "createComponent": true,
  "onFail": {
    "createIncident": true,
    "createOutageDuration": false,
    "publishIncident": true,
    "notifySubscribers": true
  },
  "onRecover": {
    "resolveIncident": true,
    "resolveOutageDuration": false,
    "publishIncident": true,
    "notifySubscribers": true
  }
}
```

**Ukázková odpověď**

```json
{
  "cronMonitor": {
    "id": "cron-abc123",
    "name": "Daily backup",
    "slug": "my-page-x7k2m9n4p1q8w3e5",
    "period": 86400,
    "grace": 3600,
    "status": "UP",
    "state": "ACTIVE",
    "siteId": "page123",
    "order": 1,
    "groupId": null,
    "componentId": "component-id-1",
    "onFailCreateIncident": true,
    "onFailCreateOutageDuration": false,
    "onFailPublishIncident": true,
    "onFailNotifySubscribers": true,
    "onRecoverResolveIncident": true,
    "onRecoverResolveOutageDuration": false,
    "onRecoverPublishIncident": true,
    "onRecoverNotifySubscribers": true,
    "createTemplateId": null,
    "resolveTemplateId": null,
    "createdAt": "2024-01-15T08:00:00.000Z",
    "updatedAt": "2024-01-15T08:00:00.000Z"
  },
  "message": "Cron monitor created successfully."
}
```

Odpověď obsahuje `slug`. Použijte ho k sestavení ping URL pro svou úlohu. První úspěšný ping naplánuje kontrolní úlohu na pozadí.

### Aktualizace cron monitoru

**Endpoint:**

```bash
PUT /monitors/cron/:id
```

**Ukázkový požadavek**

```json
{
  "name": "Daily backup (updated)",
  "period": 43200,
  "grace": 1800,
  "state": "PAUSED",
  "alerts": ["alert-id-1"],
  "onFail": {
    "notifySubscribers": false
  }
}
```

**Ukázková odpověď**

```json
{
  "cronMonitor": {
    "id": "cron-abc123",
    "name": "Daily backup (updated)",
    "slug": "my-page-x7k2m9n4p1q8w3e5",
    "period": 43200,
    "grace": 1800,
    "status": "UP",
    "state": "PAUSED",
    "siteId": "page123",
    "order": 1,
    "groupId": null,
    "componentId": "component-id-1",
    "onFailCreateIncident": true,
    "onFailCreateOutageDuration": false,
    "onFailPublishIncident": true,
    "onFailNotifySubscribers": false,
    "onRecoverResolveIncident": true,
    "onRecoverResolveOutageDuration": false,
    "onRecoverPublishIncident": true,
    "onRecoverNotifySubscribers": true,
    "createTemplateId": null,
    "resolveTemplateId": null,
    "alerts": [
      {
        "id": "alert-id-1",
        "type": "EMAIL",
        "recipient": "ops@example.com"
      }
    ],
    "createdAt": "2024-01-15T08:00:00.000Z",
    "updatedAt": "2024-01-16T10:30:00.000Z"
  },
  "message": "Cron monitor updated successfully."
}
```

### Smazání cron monitoru

**Endpoint:**

```bash
DELETE /monitors/cron/:id
```

**Ukázkový požadavek**

```bash
DELETE /monitors/cron/cron-abc123
```

**Ukázková odpověď**

```json
{
  "cronMonitor": {
    "id": "cron-abc123",
    "name": "Daily backup",
    "slug": "my-page-x7k2m9n4p1q8w3e5",
    "period": 86400,
    "grace": 3600,
    "status": "UP",
    "state": "ACTIVE",
    "siteId": "page123",
    "order": 1,
    "groupId": null,
    "componentId": "component-id-1",
    "onFailCreateIncident": true,
    "onFailCreateOutageDuration": false,
    "onFailPublishIncident": true,
    "onFailNotifySubscribers": true,
    "onRecoverResolveIncident": true,
    "onRecoverResolveOutageDuration": false,
    "onRecoverPublishIncident": true,
    "onRecoverNotifySubscribers": true,
    "createTemplateId": null,
    "resolveTemplateId": null,
    "createdAt": "2024-01-15T08:00:00.000Z",
    "updatedAt": "2024-01-15T08:00:00.000Z"
  },
  "message": "Cron monitor deleted successfully."
}
```

### Získání logů cron monitoru

**Endpoint:**

```bash
GET /monitors/cron/:id/logs
```

**Parametry dotazu**

| Parametr     | Typ      | Výchozí hodnota | Popis                                          |
| ------------ | -------- | ------------- | -------------------------------------------------------- |
| `limit`      | `number` | `100`         | Počet logů na stránku. Maximum je 127.                   |
| `page`       | `number` | `1`           | Číslo stránky. Maximum je 1000.                          |
| `startDate`  | `string` | před rokem    | Počáteční datum rozsahu logů podle ISO 8601.             |
| `endDate`    | `string` | teď           | Koncové datum rozsahu logů podle ISO 8601.               |
| `importance` | `enum`   | `null`        | Filtrovat logy podle důležitosti _('all', 'important')_. |

**Ukázkový požadavek**

```bash
GET /monitors/cron/cron-abc123/logs?limit=50&page=1&importance=important
```

**Ukázková odpověď**

```json
{
  "logs": [
    {
      "id": "log-xyz789",
      "monitorId": "cron-abc123",
      "status": "SUCCESS",
      "requestType": "GET",
      "agent": "curl/8.4.0",
      "ipAddress": "203.0.113.10",
      "createdAt": "2024-01-16T06:00:00.000Z",
      "startedAt": "2024-01-16T05:59:58.000Z"
    }
  ],
  "page": 1
}
```

### Získání souhrnu cron monitoru

**Endpoint:**

```bash
GET /monitors/cron/:id/summary
```

**Ukázkový požadavek**

```bash
GET /monitors/cron/cron-abc123/summary
```

**Ukázková odpověď**

```json
{
  "summary": {
    "totalLogs": 120,
    "totalFailedLogs": 3,
    "availability": 97.5,
    "oneDayAvailability": 100,
    "previousDayAvailability": 100,
    "sevenDayAvailability": 98.2,
    "previousSevenDayAvailability": 96.1,
    "thirtyDayAvailability": 97.5,
    "previousThirtyDayAvailability": 95.8,
    "lastSuccess": "2024-01-16T06:00:00.000Z",
    "lastFailure": "2024-01-10T06:00:00.000Z",
    "lastStarted": null,
    "upSince": "2024-01-10T07:00:00.000Z",
    "downSince": null
  }
}
```

### Ping endpointy

Tyto endpointy **nevyžadují** ověření. Jako tajný klíč slouží `slug` monitoru.

Pingnout můžete přes základní URL API nebo přes vyhrazený cron host:

- **Úspěch:** `https://cron.instatus.com/{slug}` nebo `GET` / `POST` / `HEAD` `/monitors/cron/{slug}`
- **Selhání:** `https://cron.instatus.com/{slug}/fail` nebo `GET` / `POST` / `HEAD` `/monitors/cron/{slug}/fail`
- **Start:** `https://cron.instatus.com/{slug}/start` nebo `GET` / `POST` / `HEAD` `/monitors/cron/{slug}/start`

Ping úspěchu posílejte pokaždé, když úloha doběhne podle rozvrhu. Pro záznam doby běhu pošlete ping startu před spuštěním úlohy a ping úspěchu nebo selhání, až skončí.

**Ukázkový ping úspěchu**

```bash
curl https://cron.instatus.com/my-page-x7k2m9n4p1q8w3e5
```

**Ukázková odpověď**

```json
{
  "id": "log-xyz789",
  "monitorId": "cron-abc123",
  "status": "SUCCESS",
  "requestType": "GET",
  "agent": "curl/8.4.0",
  "ipAddress": "203.0.113.10",
  "createdAt": "2024-01-16T06:00:00.000Z"
}
```

Pokud je slug neplatný, odpověď je:

```json
{
  "message": "Monitor not found"
}
```
