# Job monitors

## Overview of all job monitors

<mark style="color:blue;">`GET`</mark> `https://cronly.app/api/monitors`

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

{% tabs %}
{% tab title="200 All of your registered monitors" %}

```json
[
    {
        "id": 1,
        "name": "Test monitor",
        "company_id": 1,
        "project_id": null,
        "token": "91d13ccf-f015-4e61-aae9-355627815800",
        "timezone": "UTC",
        "schedule": "* * * * *",
        "last_run_at": "2022-05-30T13:39:55.000000Z",
        "duration": 1,
        "is_alerted": 1,
        "alert_reason": "Monitor failed",
        "deleted_at": null,
        "created_at": "2022-05-30T13:15:07.000000Z",
        "updated_at": "2022-05-30T13:41:01.000000Z"
    }
]
```

{% endtab %}
{% endtabs %}

## Details of job monitor

<mark style="color:blue;">`GET`</mark> `https://cronly.app/api/monitors/{id}`

#### Query Parameters

| Name                                 | Type    | Description                                |
| ------------------------------------ | ------- | ------------------------------------------ |
| id<mark style="color:red;">\*</mark> | Integer | The ID of the job monitor you want to view |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

{% tabs %}
{% tab title="200 The job monitor" %}

```json
{
    "id": 1,
    "name": "Test monitor",
    "company_id": 1,
    "project_id": null,
    "token": "91d13ccf-f015-4e61-aae9-355627815800",
    "timezone": "UTC",
    "schedule": "* * * * *",
    "last_run_at": "2022-05-30T13:39:55.000000Z",
    "duration": 1,
    "is_alerted": 1,
    "alert_reason": "Monitor failed",
    "deleted_at": null,
    "created_at": "2022-05-30T13:15:07.000000Z",
    "updated_at": "2022-05-30T13:41:01.000000Z"
}
```

{% endtab %}

{% tab title="404: Not Found The job monitor was not found" %}

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

{% endtab %}
{% endtabs %}

## Create a new job monitor

<mark style="color:green;">`POST`</mark> `https://cronly.app/api/monitors`

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

#### Request Body

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| name<mark style="color:red;">\*</mark>     | String  |             |
| timezone<mark style="color:red;">\*</mark> | String  |             |
| project\_id                                | Integer |             |
| schedule<mark style="color:red;">\*</mark> | String  |             |
| duration<mark style="color:red;">\*</mark> | Integer |             |

{% tabs %}
{% tab title="200 The newly created job monitor" %}

```json
{
    "name": "test",
    "project_id": "1",
    "timezone": "UTC",
    "schedule": "* * * * *",
    "duration": "1",
    "company_id": 1,
    "token": "6e9c5250-a609-4fcc-aec8-710104fd744e",
    "updated_at": "2022-05-31T19:47:36.000000Z",
    "created_at": "2022-05-31T19:47:36.000000Z",
    "id": 5
}
```

{% endtab %}
{% endtabs %}

## Delete a job monitor

<mark style="color:red;">`DELETE`</mark> `https://cronly.app/api/monitors/{id}`

#### Query Parameters

| Name                                 | Type    | Description                                |
| ------------------------------------ | ------- | ------------------------------------------ |
| id<mark style="color:red;">\*</mark> | Integer | The ID of the job monitor you want to view |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

{% tabs %}
{% tab title="204: No Content The job monitor has been deleted successfully" %}

```json
{
    "success": "Monitor deleted"
}
```

{% endtab %}

{% tab title="404: Not Found The job monitor was not found" %}

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

{% endtab %}
{% endtabs %}
