---
title: Create Server Cron Job
description: "Creates a server-level cron job and installs it on the server synchronously. The user is validated against the server's actual Linux users via SSH. Requires the write:servers scope and the…"
url: "https://betterdocs.shahrear.msf.bd/index.php/docs/hell0-boys-docs/hell0-boys/servers/create-server-cron-job/"
updated: "2026-08-20"
category: hell0 boys / Servers
---

# Create Server Cron Job

POST`/servers/{uuid}/cron-jobs`

## Code Samples

```curl

                curl --request POST \
  --url 'https://app.xcloud.host/api/v1/servers/{uuid}/cron-jobs' \
  --header 'Authorization: Bearer YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "user": "root",
    "frequency": "every_minute",
    "pattern": "*/5 * * * *",
    "command": "echo hello"
}'

                const response = await fetch('https://app.xcloud.host/api/v1/servers/{uuid}/cron-jobs', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "user": "root",
    "frequency": "every_minute",
    "pattern": "*/5 * * * *",
    "command": "echo hello"
})
});

const data = await response.json();
console.log(data);

                import requests

headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
}

payload = {
    "user": "root",
    "frequency": "every_minute",
    "pattern": "*/5 * * * *",
    "command": "echo hello"
}

response = requests.post("https://app.xcloud.host/api/v1/servers/{uuid}/cron-jobs", headers=headers, json=payload)

print(response.json())

                <?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://app.xcloud.host/api/v1/servers/{uuid}/cron-jobs',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
  'Authorization: Bearer YOUR_TOKEN',
  'Content-Type: application/json'
  ],
  CURLOPT_POSTFIELDS => '{
    "user": "root",
    "frequency": "every_minute",
    "pattern": "*/5 * * * *",
    "command": "echo hello"
}',
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;

                using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://app.xcloud.host/api/v1/servers/{uuid}/cron-jobs");
request.Headers.Add("Authorization", "Bearer YOUR_TOKEN");
request.Content = new StringContent(@"{
    ""user"": ""root"",
    ""frequency"": ""every_minute"",
    ""pattern"": ""*/5 * * * *"",
    ""command"": ""echo hello""
}", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

                import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://app.xcloud.host/api/v1/servers/{uuid}/cron-jobs"))
    .header("Authorization", "Bearer YOUR_TOKEN")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
{
    "user": "root",
    "frequency": "every_minute",
    "pattern": "*/5 * * * *",
    "command": "echo hello"
}
"""))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

## Response

```json

                {
    "success": true,
    "message": "Operation completed successfully.",
    "data": {
        "uuid": "123e4567-e89b-12d3-a456-426614174000",
        "command": "php artisan schedule:run",
        "user": "xcloud_example",
        "frequency": "every_minute",
        "frequency_label": "Every Minute",
        "pattern": "* * * * *",
        "status": "processing",
        "site_uuid": "123e4567-e89b-12d3-a456-426614174000",
        "created_at": "2024-01-15T09:30:00Z",
        "updated_at": "2024-01-15T09:30:00Z"
    }
}

                {
    "success": false,
    "message": "Unauthenticated.",
    "data": null
}

                {
    "success": false,
    "message": "This action is unauthorized. Your token is missing the required scope.",
    "data": null
}

                {
    "success": false,
    "message": "Not found.",
    "data": null
}

                {
    "success": false,
    "message": "The given data was invalid.",
    "data": null,
    "errors": {
        "domain": [
            "The domain field is required when mode is live."
        ]
    }
}
```

Creates a [Server](https://betterdocs.shahrear.msf.bd/encyclopedia/server/)-[Level](https://betterdocs.shahrear.msf.bd/encyclopedia/level/) cron job and installs it on the [Server](https://betterdocs.shahrear.msf.bd/encyclopedia/server/) synchronously. The user is validated against the [Server](https://betterdocs.shahrear.msf.bd/encyclopedia/server/)'s actual Linux users via SSH. Requires the `write:servers` scope and the `Server:manage-cron-jobs` permission.

## Path Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `uuid` | string (uuid) | **Required** | UUID of the [Server](https://betterdocs.shahrear.msf.bd/encyclopedia/server/) |

## Request Body

Content type: `application/json` — **required**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `user` | string | **Required** | Linux user that owns the cron entry. Validated against the [Server](https://betterdocs.shahrear.msf.bd/encyclopedia/server/)'s actual users via SSH. |
| `frequency` | string | **Required** | Allowed: every_minute, every_five_minutes, every_ten_minutes, every_fifteen_minutes, every_thirty_minutes, hourly, weekly, monthly, on_reboot, custom |
| `pattern` | string | Optional | Required when frequency=custom. 5-field cron expression. |
| `command` | string | **Required** |  |

```json

                {
    "user": "root",
    "frequency": "every_minute",
    "pattern": "*/5 * * * *",
    "command": "echo hello"
}
```

## Responses

### 201 — Cron job created and installed

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |
| `data` | object | Optional |  |
| `data.uuid` | string (uuid) | Optional |  |
| `data.command` | string | Optional |  |
| `data.user` | string | Optional |  |
| `data.frequency` | string | Optional | Allowed: every_minute, every_five_minutes, every_ten_minutes, every_fifteen_minutes, every_thirty_minutes, hourly, weekly, monthly, on_reboot, custom |
| `data.frequency_label` | string | Optional |  |
| `data.pattern` | string | Optional |  |
| `data.status` | string | Optional | Allowed: processing, active, inactive |
| `data.site_uuid` | string (uuid) | Optional |  |
| `data.created_at` | string (date-time) | Optional |  |
| `data.updated_at` | string (date-time) | Optional |  |

```json

                {
    "success": true,
    "message": "Operation completed successfully.",
    "data": {
        "uuid": "123e4567-e89b-12d3-a456-426614174000",
        "command": "php artisan schedule:run",
        "user": "xcloud_example",
        "frequency": "every_minute",
        "frequency_label": "Every Minute",
        "pattern": "* * * * *",
        "status": "processing",
        "site_uuid": "123e4567-e89b-12d3-a456-426614174000",
        "created_at": "2024-01-15T09:30:00Z",
        "updated_at": "2024-01-15T09:30:00Z"
    }
}
```

### 401 — Missing or invalid authentication token

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |

```json

                {
    "success": false,
    "message": "Unauthenticated.",
    "data": null
}
```

### 403 — Token lacks the required scope

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |

```json

                {
    "success": false,
    "message": "This action is unauthorized. Your token is missing the required scope.",
    "data": null
}
```

### 404 — Resource not found or not accessible to your [Team](https://betterdocs.shahrear.msf.bd/encyclopedia/team/)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |

```json

                {
    "success": false,
    "message": "Not found.",
    "data": null
}
```

### 422 — Request validation failed

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | boolean | Optional |  |
| `message` | string | Optional |  |
| `data` | object | Optional |  |
| `errors` | object | Optional |  |

```json

                {
    "success": false,
    "message": "The given data was invalid.",
    "data": null,
    "errors": {
        "domain": [
            "The domain field is required when mode is live."
        ]
    }
}
```
