# Riferimento API dei monitor

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

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

## Valori possibili per i campi

**Località del monitor**

| Valore           | Descrizione       |
| ---------------- | ----------------- |
| `US_EAST_1`      | Virginia del Nord |
| `CA_CENTRAL_1`   | Canada (Montreal) |
| `EU_CENTRAL_1`   | Francoforte       |
| `AP_NORTHEAST_1` | Tokyo             |

**Tipi di avviso del monitor**

| Valore            | Descrizione           |
| ----------------- | --------------------- |
| `INCIDENT`        | Avviso di incidente   |
| `EMAIL`           | Avviso via email      |
| `SMS`             | Avviso via SMS        |
| `SLACK`           | Avviso su Slack       |
| `DISCORD`         | Avviso su Discord     |
| `MICROSOFT_TEAMS` | Avviso su Microsoft Teams |
| `PHONE_CALL`      | Avviso via chiamata   |
| `WEBHOOK`         | Avviso via webhook    |
| `GOOGLE_CHAT`     | Avviso su Google Chat |
| `WHATSAPP`        | Avviso su WhatsApp    |

**Stato del monitor**

| Valore     | Descrizione                       |
| ---------- | --------------------------------- |
| `UP`       | Il monitor funziona normalmente   |
| `DOWN`     | Il monitor ha fallito             |
| `DEGRADED` | Il monitor ha dei problemi        |
| `UNKNOWN`  | Impossibile determinare lo stato del monitor |

## Ottenere i monitor

Puoi usare questo endpoint per consultare e sfogliare l'elenco di tutti i monitor esistenti.

**Endpoint:**

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

**Parametri query**

| Parametro | Tipo     | Valore predefinito | Descrizione                                       |
| --------- | -------- | ------------- | ------------------------------------------------------ |
| `page`    | `number` | `1`           | Il numero della pagina da recuperare.                  |
| `limit`   | `number` | `100`         | Il numero di monitor per pagina.                       |
| `search`  | `string` | `null`        | Termine di ricerca per filtrare i risultati.           |
| `status`  | `enum`   | `null`        | Filtro sullo stato _('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')_. |

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Creare un monitor

**Endpoint:**

```bash
POST /monitors
```

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Aggiornare un monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Eliminare un monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Ottenere i log di un monitor

**Endpoint:**

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

# Parametri query

| Parametro              | Tipo                                    | Valore predefinito | Descrizione                                                                          |
| ---------------------- | --------------------------------------- | --------------- | --------------------------------------------------------------------------------------- |
| `limit`                | `number`                                | 100             | Il numero di elementi per pagina. Non può superare 1000.                                |
| `page`                 | `number`                                | 1               | Il numero della pagina da recuperare.                                                   |
| `monitorId`            | `string`                                | -               | L'ID del monitor.                                                                       |
| `location`             | `string`                                | `null`          | La località del monitor.                                                                |
| `createdAt`            | `string` \| `object` \| `number`        | `null`          | La data di creazione. Può essere una stringa, un numero o un oggetto con i campi `gte` e `lte`. |
| `isSuccessful`         | `boolean`                               | `null`          | Se il controllo è riuscito.                                                             |
| `isSSLCheck`           | `boolean`                               | `null`          | Se il controllo è un controllo SSL.                                                     |
| `httpStatusCode`       | `string`                                | `null`          | Il codice di stato HTTP della risposta.                                                 |
| `status`               | `('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')` | `null`          | Lo stato del monitor.                                                                   |
| `dnsTime`              | `string` \| `number` \| `object`        | `null`          | Tempo impiegato per la risoluzione DNS.                                                 |
| `tcpTime`              | `string` \| `number` \| `object`        | `null`          | Tempo impiegato per la connessione TCP.                                                 |
| `tlsTime`              | `string` \| `number` \| `object`        | `null`          | Tempo impiegato per l'handshake TLS.                                                    |
| `firstByteTime`        | `string` \| `number` \| `object`        | `null`          | Tempo impiegato per ricevere il primo byte.                                             |
| `downloadTime`         | `string` \| `number` \| `object`        | `null`          | Tempo impiegato per il download.                                                        |
| `responseTime`         | `string` \| `number` \| `object`        | `null`          | Tempo di risposta totale.                                                               |
| `performanceTime`      | `string` \| `number` \| `object`        | `null`          | Tempo di prestazione.                                                                   |
| `accessabilityScore`   | `string` \| `number` \| `object`        | `null`          | Punteggio di accessibilità.                                                             |
| `seoScore`             | `string` \| `number` \| `object`        | `null`          | Punteggio SEO.                                                                          |
| `bestPracticesScore`   | `string` \| `number` \| `object`        | `null`          | Punteggio sulle best practice.                                                          |
| `successfulAssertions` | `string` \| `number` \| `object`        | `null`          | Numero di asserzioni soddisfatte.                                                       |
| `sort`                 | `string`                                | cronologico     | Campo in base a cui ordinare.                                                           |

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Eseguire il controllo di un monitor per ID

**Endpoint:**

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

**Parametri query**

| Parametro      | Tipo                                                                              | Valore predefinito | Descrizione                                                  |
| -------------- | --------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------- |
| `location`     | `'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'` | -             | La località del monitor. Deve essere uno dei valori indicati. |
| `retry`        | `boolean`                                                                         | `false`       | Indica se l'operazione deve essere ritentata. Facoltativo.   |
| `monitorLogId` | `string`                                                                          | `null`        | L'identificatore univoco del log del monitor. Facoltativo.   |

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Creare un avviso per un monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Aggiornare un avviso di un monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Ottenere gli avvisi dei monitor

**Endpoint:**

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

**Parametri query**

| Parametro | Tipo     | Valore predefinito | Descrizione              |
| --------- | -------- | ------------- | ----------------------------- |
| `limit`   | `number` | 100           | Il numero di elementi per pagina. |
| `page`    | `number` | 1             | Il numero della pagina da recuperare. |

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Eliminare un avviso di un monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Creare un gruppo di monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Aggiornare un gruppo di monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Eliminare un gruppo di monitor

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Aggiungere monitor a un gruppo

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Eseguire il controllo di un gruppo di monitor

**Endpoint:**

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

**Parametri query**

| Parametro      | Tipo                                                                              | Valore predefinito | Descrizione                                                  |
| -------------- | --------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------- |
| `location`     | `'US_EAST_1', 'EU_CENTRAL_1', 'AP_NORTHEAST_1', 'AP_SOUTHEAST_2', 'CA_CENTRAL_1'` | -             | La località del monitor. Deve essere uno dei valori indicati. |
| `retry`        | `boolean`                                                                         | `false`       | Indica se l'operazione deve essere ritentata. Facoltativo.   |
| `monitorLogId` | `string`                                                                          | `null`        | L'identificatore univoco del log del monitor. Facoltativo.   |

**Esempio di richiesta**

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

**Esempio di risposta**

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

## Monitor cron

I monitor cron tengono traccia dei job pianificati tramite ping HTTP. Per la configurazione nel prodotto e l'uso dalla dashboard, vedi [Monitoraggio cron](https://instatus.com/help/it/monitoring/cron).

### Valori possibili per i campi

**Stato del monitor cron**

| Valore     | Descrizione                       |
| ---------- | --------------------------------- |
| `UP`       | Il monitor funziona normalmente   |
| `DOWN`     | Il monitor ha fallito             |
| `DEGRADED` | Il monitor ha dei problemi        |
| `UNKNOWN`  | Impossibile determinare lo stato del monitor |

**Stato di attività del monitor cron**

| Valore   | Descrizione                          |
| -------- | ------------------------------------ |
| `ACTIVE` | Il monitor viene controllato attivamente |
| `PAUSED` | I controlli del monitor sono in pausa |
| `MUTED`  | Il monitor è silenziato (nessuna notifica) |

**Stato dei log del monitor cron**

| Valore    | Descrizione                                      |
| --------- | ------------------------------------------------ |
| `SUCCESS` | Il job è stato completato correttamente          |
| `FAILURE` | Il job ha segnalato esplicitamente un errore     |
| `MISSED`  | Il job non ha inviato il ping nella finestra prevista |
| `LATE`    | Il job ha inviato il ping dopo il periodo ma entro la tolleranza |
| `STARTED` | Il job ha segnalato di essere partito (misura del tempo di esecuzione) |

**Periodo e tolleranza**

Sia `period` sia `grace` si esprimono in **secondi**. `period` indica ogni quanto il job deve essere eseguito; `grace` è il tempo aggiuntivo concesso prima che il monitor venga contrassegnato come giù.

### Ottenere i monitor cron

**Endpoint:**

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

**Parametri query**

| Parametro | Tipo     | Valore predefinito | Descrizione                                       |
| --------- | -------- | ------------- | ------------------------------------------------------ |
| `limit`   | `number` | `100`         | Il numero di monitor cron per pagina. Il massimo è 100. |
| `page`    | `number` | `1`           | Il numero della pagina.                                |
| `search`  | `string` | `null`        | Termine di ricerca per filtrare i risultati per nome.  |
| `status`  | `enum`   | `null`        | Filtro sullo stato _('UP', 'DOWN', 'UNKNOWN', 'DEGRADED')_. |

**Esempio di richiesta**

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

**Esempio di risposta**

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

### Creare un monitor cron

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

La risposta include uno `slug`. Usalo per costruire gli URL di ping del tuo job. Il primo ping riuscito pianifica il job di controllo in background.

### Aggiornare un monitor cron

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

### Eliminare un monitor cron

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

### Ottenere i log di un monitor cron

**Endpoint:**

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

**Parametri query**

| Parametro    | Tipo     | Valore predefinito | Descrizione                                         |
| ------------ | -------- | ------------- | -------------------------------------------------------- |
| `limit`      | `number` | `100`         | Il numero di log per pagina. Il massimo è 127.           |
| `page`       | `number` | `1`           | Il numero della pagina. Il massimo è 1000.               |
| `startDate`  | `string` | 1 anno fa     | Data di inizio ISO 8601 dell'intervallo dei log.         |
| `endDate`    | `string` | adesso        | Data di fine ISO 8601 dell'intervallo dei log.           |
| `importance` | `enum`   | `null`        | Filtra i log per importanza _('all', 'important')_.      |

**Esempio di richiesta**

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

**Esempio di risposta**

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

### Ottenere il riepilogo di un monitor cron

**Endpoint:**

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

**Esempio di richiesta**

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

**Esempio di risposta**

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

### Endpoint di ping

Questi endpoint **non** richiedono autenticazione. Lo `slug` del monitor funge da secret.

Puoi inviare il ping tramite l'URL base dell'API oppure tramite l'host cron dedicato:

- **Successo:** `https://cron.instatus.com/{slug}` oppure `GET` / `POST` / `HEAD` `/monitors/cron/{slug}`
- **Errore:** `https://cron.instatus.com/{slug}/fail` oppure `GET` / `POST` / `HEAD` `/monitors/cron/{slug}/fail`
- **Avvio:** `https://cron.instatus.com/{slug}/start` oppure `GET` / `POST` / `HEAD` `/monitors/cron/{slug}/start`

Invia un ping di successo ogni volta che il job si conclude nei tempi previsti. Invia un ping di avvio prima dell'esecuzione e un ping di successo o di errore alla fine per registrare il tempo di esecuzione.

**Esempio di ping di successo**

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

**Esempio di risposta**

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

Se lo slug non è valido, la risposta è:

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