# Cron Jobs

<a id="get-api-v1-accounts-username-cron"></a>
#### `GET /api/v1/accounts/{username}/cron`

*List cron jobs*

Returns every cron job defined for the account.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_CronResponse__` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": [
    {
      "command": "...",
      "day": "...",
      "enabled": "...",
      "hour": "...",
      "id": "...",
      "last_run": "...",
      "minute": "...",
      "month": "...",
      "schedule": "...",
      "weekday": "..."
    }
  ],
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/cron
```

---

<a id="post-api-v1-accounts-username-cron"></a>
#### `POST /api/v1/accounts/{username}/cron`

*Create cron job*

Define a new cron entry under the account's crontab.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `command` | string | yes | maxLength=1024 |
| `day` | string | no | default `*`; maxLength=120 |
| `enabled` | boolean | no | default `True` |
| `hour` | string | no | default `*`; maxLength=120 |
| `minute` | string | no | default `*`; maxLength=120 |
| `month` | string | no | default `*`; maxLength=120 |
| `weekday` | string | no | default `*`; maxLength=120 |

**Request body example:**

```json
{
  "command": "string",
  "day": "*",
  "enabled": true,
  "hour": "*",
  "minute": "*",
  "month": "*",
  "weekday": "*"
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_CronResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "command": "string",
    "day": "string",
    "enabled": false,
    "hour": "string",
    "id": "string",
    "last_run": "...",
    "minute": "string",
    "month": "string",
    "schedule": "string",
    "weekday": "string"
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/cron
```

---

<a id="delete-api-v1-accounts-username-cron-cron-id"></a>
#### `DELETE /api/v1/accounts/{username}/cron/{cron_id}`

*Delete cron job*

Remove a cron entry by id.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `cron_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `MessageResponse` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "message": "string",
  "status": "success"
}
```

**cURL example:**

```bash
curl -X DELETE \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/cron/{cron_id}
```

---

<a id="put-api-v1-accounts-username-cron-cron-id"></a>
#### `PUT /api/v1/accounts/{username}/cron/{cron_id}`

*Update cron job*

Patch the schedule / command / enabled flag of an existing cron entry.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `cron_id` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `command` | string | no | — |
| `day` | string | no | — |
| `enabled` | boolean | no | — |
| `hour` | string | no | — |
| `minute` | string | no | — |
| `month` | string | no | — |
| `weekday` | string | no | — |

**Request body example:**

```json
{
  "command": "string",
  "day": "string",
  "enabled": false,
  "hour": "string",
  "minute": "string",
  "month": "string",
  "weekday": "string"
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_CronResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "command": "string",
    "day": "string",
    "enabled": false,
    "hour": "string",
    "id": "string",
    "last_run": "...",
    "minute": "string",
    "month": "string",
    "schedule": "string",
    "weekday": "string"
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X PUT \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/cron/{cron_id}
```

---

<a id="post-api-v1-accounts-username-cron-cron-id-run"></a>
#### `POST /api/v1/accounts/{username}/cron/{cron_id}/run`

*Run cron job manually*

Execute the cron command immediately. Response data is the exec result (exit_code, success, stdout/stderr).

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `cron_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_dict_str__Any__` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {},
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/cron/{cron_id}/run
```

---
