# Dokumentacja API monitorów

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

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

## Możliwe wartości pól

**Lokalizacja monitora**

| Wartość | Opis |
| ---------------- | ----------------- |
| `US_EAST_1`      | Wirginia Północna |
| `CA_CENTRAL_1`   | Kanada (Montreal) |
| `EU_CENTRAL_1`   | Frankfurt |
| `AP_NORTHEAST_1` | Tokio |

**Typy alertów monitora**

| Wartość | Opis |
| ----------------- | --------------------- |
| `INCIDENT`        | Alert incydentu |
| `EMAIL`           | Alert e-mail |
| `SMS`             | Alert SMS |
| `SLACK`           | Alert Slack |
| `DISCORD`         | Alert Discord |
| `MICROSOFT_TEAMS` | Alert Microsoft Teams |
| `PHONE_CALL`      | Alert przez połączenie telefoniczne |
| `WEBHOOK`         | Alert webhook |
| `GOOGLE_CHAT`     | Alert Google Chat |
| `WHATSAPP`        | Alert WhatsApp |

**Status monitora**

| Wartość | Opis |
| ---------- | --------------------------------- |
| `UP`       | Monitor działa normalnie |
| `DOWN`     | Monitor zgłosił awarię |
| `DEGRADED` | Monitor ma problemy |
| `UNKNOWN`  | Nie da się ustalić stanu monitora |

## Pobierz monitory

Ten endpoint pozwala przeglądać listę wszystkich istniejących monitorów i wyszukiwać w niej.

**Endpoint:**

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

**Parametry zapytania**

| Parametr | Typ | Wartość domyślna | Opis |
| --------- | -------- | ------------- | ------------------------------------------------------ |
| `page`    | `number` | `1`           | Numer strony do pobrania. |
| `limit`   | `number` | `100`         | Liczba monitorów na stronę. |
| `search`  | `string` | `null`        | Fraza do filtrowania wyników. |
| `status`  | `enum`   | `null`        | Filtr statusu _('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')_. |

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Utwórz monitor

**Endpoint:**

```bash
POST /monitors
```

**Przykładowe żądanie**

```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
  }
}
```

**Przykładowa odpowiedź**

```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"
}
```

## Zaktualizuj monitor

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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"
}
```

## Usuń monitor

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Pobierz logi monitora

**Endpoint:**

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

# Parametry zapytania

| Parametr | Typ | Wartość domyślna | Opis |
| ---------------------- | --------------------------------------- | --------------- | --------------------------------------------------------------------------------------- |
| `limit`                | `number`                                | 100             | Liczba elementów na stronę. Nie może przekraczać 1000. |
| `page`                 | `number`                                | 1               | Numer strony do pobrania. |
| `monitorId`            | `string`                                | -               | ID monitora. |
| `location`             | `string`                                | `null`          | Lokalizacja monitora. |
| `createdAt`            | `string` \| `object` \| `number`        | `null`          | Data utworzenia. Może być tekstem, liczbą lub obiektem z polami `gte` i `lte`. |
| `isSuccessful`         | `boolean`                               | `null`          | Czy sprawdzenie zakończyło się powodzeniem. |
| `isSSLCheck`           | `boolean`                               | `null`          | Czy sprawdzenie jest sprawdzeniem SSL. |
| `httpStatusCode`       | `string`                                | `null`          | Kod statusu HTTP odpowiedzi. |
| `status`               | `('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')` | `null`          | Status monitora. |
| `dnsTime`              | `string` \| `number` \| `object`        | `null`          | Czas rozwiązywania DNS. |
| `tcpTime`              | `string` \| `number` \| `object`        | `null`          | Czas nawiązania połączenia TCP. |
| `tlsTime`              | `string` \| `number` \| `object`        | `null`          | Czas uzgadniania TLS. |
| `firstByteTime`        | `string` \| `number` \| `object`        | `null`          | Czas do otrzymania pierwszego bajtu. |
| `downloadTime`         | `string` \| `number` \| `object`        | `null`          | Czas pobierania. |
| `responseTime`         | `string` \| `number` \| `object`        | `null`          | Łączny czas odpowiedzi. |
| `performanceTime`      | `string` \| `number` \| `object`        | `null`          | Czas wydajności. |
| `accessabilityScore`   | `string` \| `number` \| `object`        | `null`          | Wynik dostępności (accessibility). |
| `seoScore`             | `string` \| `number` \| `object`        | `null`          | Wynik SEO. |
| `bestPracticesScore`   | `string` \| `number` \| `object`        | `null`          | Wynik dobrych praktyk. |
| `successfulAssertions` | `string` \| `number` \| `object`        | `null`          | Liczba udanych asercji. |
| `sort`                 | `string`                                | chronologicznie | Pole, według którego sortować. |

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Uruchom sprawdzenie monitora po ID

**Endpoint:**

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

**Parametry zapytania**

| Parametr | Typ | Wartość domyślna | Opis |
| -------------- | --------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------- |
| `location`     | `'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'` | -             | Lokalizacja monitora. Musi być jedną ze wskazanych wartości. |
| `retry`        | `boolean`                                                                         | `false`       | Określa, czy operacja ma zostać ponowiona. Opcjonalne. |
| `monitorLogId` | `string`                                                                          | `null`        | Unikalny identyfikator logu monitora. Opcjonalne. |

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Utwórz alert monitora

**Endpoint:**

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

**Przykładowe żądanie**

```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"
}
```

**Przykładowa odpowiedź**

```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"
}
```

## Zaktualizuj alert monitora

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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."
}
```

## Pobierz alerty monitorów

**Endpoint:**

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

**Parametry zapytania**

| Parametr | Typ | Wartość domyślna | Opis |
| --------- | -------- | ------------- | ----------------------------- |
| `limit`   | `number` | 100           | Liczba elementów na stronę. |
| `page`    | `number` | 1             | Numer strony do pobrania. |

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Usuń alert monitora

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Utwórz grupę monitorów

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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."
}
```

## Zaktualizuj grupę monitorów

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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."
}
```

## Usuń grupę monitorów

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Dodaj monitory do grupy

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Uruchom sprawdzenie grupy monitorów

**Endpoint:**

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

**Parametry zapytania**

| Parametr | Typ | Wartość domyślna | Opis |
| -------------- | --------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------- |
| `location`     | `'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'` | -             | Lokalizacja monitora. Musi być jedną ze wskazanych wartości. |
| `retry`        | `boolean`                                                                         | `false`       | Określa, czy operacja ma zostać ponowiona. Opcjonalne. |
| `monitorLogId` | `string`                                                                          | `null`        | Unikalny identyfikator logu monitora. Opcjonalne. |

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

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

## Monitory cron

Monitory cron śledzą zaplanowane zadania za pomocą pingów HTTP. Konfigurację w produkcie i obsługę w panelu opisujemy w artykule [Monitoring cron](https://instatus.com/help/pl/monitoring/cron).

### Możliwe wartości pól

**Status monitora cron**

| Wartość | Opis |
| ---------- | --------------------------------- |
| `UP`       | Monitor działa normalnie |
| `DOWN`     | Monitor zgłosił awarię |
| `DEGRADED` | Monitor ma problemy |
| `UNKNOWN`  | Nie da się ustalić stanu monitora |

**Stan monitora cron**

| Wartość | Opis |
| -------- | ------------------------------------ |
| `ACTIVE` | Monitor jest aktywnie sprawdzany |
| `PAUSED` | Sprawdzenia monitora są wstrzymane |
| `MUTED`  | Monitor jest wyciszony (bez powiadomień) |

**Status logu monitora cron**

| Wartość | Opis |
| --------- | ------------------------------------------------ |
| `SUCCESS` | Zadanie zakończyło się powodzeniem |
| `FAILURE` | Zadanie jawnie zgłosiło awarię |
| `MISSED`  | Zadanie nie wysłało pinga w oczekiwanym oknie |
| `LATE`    | Zadanie wysłało ping po okresie, ale w czasie karencji |
| `STARTED` | Zadanie zgłosiło start (pomiar czasu wykonania) |

**Okres i karencja**

Zarówno `period`, jak i `grace` podaje się w **sekundach**. `period` określa, jak często zadanie ma się wykonywać, a `grace` to dodatkowy czas, zanim monitor zostanie oznaczony jako niedziałający.

### Pobierz monitory cron

**Endpoint:**

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

**Parametry zapytania**

| Parametr | Typ | Wartość domyślna | Opis |
| --------- | -------- | ------------- | ------------------------------------------------------ |
| `limit`   | `number` | `100`         | Liczba monitorów cron na stronę. Maksymalnie 100. |
| `page`    | `number` | `1`           | Numer strony. |
| `search`  | `string` | `null`        | Fraza do filtrowania wyników po nazwie. |
| `status`  | `enum`   | `null`        | Filtr statusu _('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')_. |

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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
}
```

### Utwórz monitor cron

**Endpoint:**

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

**Przykładowe żądanie**

```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
  }
}
```

**Przykładowa odpowiedź**

```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."
}
```

Odpowiedź zawiera pole `slug`. Użyj go, aby zbudować adresy URL pingów dla swojego zadania. Pierwszy udany ping planuje zadanie sprawdzające w tle.

### Zaktualizuj monitor cron

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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."
}
```

### Usuń monitor cron

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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."
}
```

### Pobierz logi monitora cron

**Endpoint:**

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

**Parametry zapytania**

| Parametr | Typ | Wartość domyślna | Opis |
| ------------ | -------- | ------------- | -------------------------------------------------------- |
| `limit`      | `number` | `100`         | Liczba logów na stronę. Maksymalnie 127. |
| `page`       | `number` | `1`           | Numer strony. Maksymalnie 1000. |
| `startDate`  | `string` | rok temu | Data początkowa zakresu logów w formacie ISO 8601. |
| `endDate`    | `string` | teraz | Data końcowa zakresu logów w formacie ISO 8601. |
| `importance` | `enum`   | `null`        | Filtruj logi według ważności _('all', 'important')_. |

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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
}
```

### Pobierz podsumowanie monitora cron

**Endpoint:**

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

**Przykładowe żądanie**

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

**Przykładowa odpowiedź**

```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
  }
}
```

### Endpointy pingów

Te endpointy **nie** wymagają uwierzytelniania. Rolę sekretu pełni `slug` monitora.

Ping możesz wysłać na bazowy adres URL API albo na dedykowany host cron:

- **Powodzenie:** `https://cron.instatus.com/{slug}` lub `GET` / `POST` / `HEAD` `/monitors/cron/{slug}`
- **Awaria:** `https://cron.instatus.com/{slug}/fail` lub `GET` / `POST` / `HEAD` `/monitors/cron/{slug}/fail`
- **Start:** `https://cron.instatus.com/{slug}/start` lub `GET` / `POST` / `HEAD` `/monitors/cron/{slug}/start`

Wysyłaj ping powodzenia za każdym razem, gdy zadanie zakończy się zgodnie z harmonogramem. Aby zapisać czas wykonania, wyślij ping startu przed uruchomieniem zadania oraz ping powodzenia lub awarii po jego zakończeniu.

**Przykładowy ping powodzenia**

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

**Przykładowa odpowiedź**

```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"
}
```

Jeśli slug jest nieprawidłowy, odpowiedź wygląda tak:

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