# Servers

## Overview of all servers

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

#### Headers

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

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

```json
[
    {
        "id": 1,
        "company_id": 1,
        "name": "Test Server",
        "identifier": "server_identifier",
        "ip_address": "143.110.208.131",
        "deleted_at": null,
        "created_at": "2024-03-04T16:19:06.000000Z",
        "updated_at": "2024-03-04T16:19:06.000000Z"
    }
]
```

{% endtab %}
{% endtabs %}

## Details of server

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

#### Query Parameters

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

#### Headers

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

{% tabs %}
{% tab title="200 The server" %}

```json
{
        "id": 1,
        "company_id": 1,
        "name": "Test Server",
        "ip_address": "143.110.208.131",
        "identifier": "server_identifier",
        "deleted_at": null,
        "created_at": "2024-03-04T16:19:06.000000Z",
        "updated_at": "2024-03-04T16:19:06.000000Z"
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

## Create a new server

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

#### 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 | The name of the server       |
| ip\_address<mark style="color:red;">\*</mark> | String | The IP Address of the server |
| identifier<mark style="color:red;">\*</mark>  | String |                              |

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

```json
{
    "name": "Test Server",
    "ip_address": "143.110.208.131",
    "identifier": "server_identifier",
    "company_id": 1,
    "updated_at": "2024-03-04T20:41:32.000000Z",
    "created_at": "2024-03-04T20:41:32.000000Z",
    "id": 4
}
```

{% endtab %}
{% endtabs %}

## Delete a server

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

#### Query Parameters

| Name                                         | Type    | Description                                     |
| -------------------------------------------- | ------- | ----------------------------------------------- |
| server\_id<mark style="color:red;">\*</mark> | Integer | The identifier of the server you want to delete |

#### Headers

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

{% tabs %}
{% tab title="200: No Content The server has been deleted successfully" %}

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

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

## Alert

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

#### Headers

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

#### Request Body

<table><thead><tr><th>Name</th><th width="235">Type</th><th>Description</th></tr></thead><tbody><tr><td>username<mark style="color:red;">*</mark></td><td>String</td><td>The username on the server whose back-up you want to alert</td></tr><tr><td>server_id<mark style="color:red;">*</mark></td><td>String</td><td>The identifier of the server you want to alert</td></tr><tr><td>command<mark style="color:red;">*</mark></td><td>String</td><td>The command that was altered</td></tr></tbody></table>

{% tabs %}
{% tab title="200 Success" %}

```json
{
    "success": "Alert sent"
}
```

{% endtab %}
{% endtabs %}
