{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codai-ro/json-schema/codai-ro-schedule-schema.json",
  "title": "Schedule",
  "description": "A scheduled task.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codai-ro-schedules-api-openapi.yml#/components/schemas/Schedule",
  "type": "object",
  "required": [
    "id",
    "name",
    "kind",
    "enabled",
    "trigger",
    "target",
    "upcoming"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "name": {
      "type": "string",
      "maxLength": 120
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "enabled": {
      "type": "boolean"
    },
    "kind": {
      "type": "string",
      "enum": [
        "agent",
        "shell",
        "http",
        "chain",
        "phone_action"
      ]
    },
    "spec": {
      "type": "object",
      "additionalProperties": true
    },
    "trigger": {
      "type": "object",
      "description": "cron `{type, expr, tz}`, at `{type, at}`, interval `{type, every_s}`, event `{type, trigger_id}` or after `{type, schedule_id, on}`.",
      "additionalProperties": true
    },
    "target": {
      "type": "object",
      "description": "host `{type, device_id}`, tags `{type, tags}`, any, cloud or cloud_vm `{type, project_id}`.",
      "additionalProperties": true
    },
    "failover": {
      "type": "array",
      "items": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "native": {
      "type": "boolean"
    },
    "policy": {
      "type": "object",
      "description": "Approval (never, always, outside quiet hours), quiet hours, budgets per run and per day (micro-USD) and the hourly run limit.",
      "additionalProperties": true
    },
    "misfire": {
      "type": "string",
      "enum": [
        "skip",
        "once",
        "all_within"
      ]
    },
    "misfire_window_min": {
      "type": "integer"
    },
    "overlap": {
      "type": "string",
      "enum": [
        "skip",
        "queue",
        "kill"
      ]
    },
    "timeout_s": {
      "type": "integer"
    },
    "retries": {
      "type": "integer"
    },
    "retry_backoff_s": {
      "type": "integer"
    },
    "late_after_s": {
      "type": [
        "integer",
        "null"
      ]
    },
    "alert_on_fail": {
      "type": "boolean"
    },
    "template": {
      "type": [
        "string",
        "null"
      ]
    },
    "command_hash": {
      "type": [
        "string",
        "null"
      ]
    },
    "next_run_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_run_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "upcoming": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "date-time"
      }
    },
    "approvals": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "device_id": {
            "type": "string",
            "format": "uuid"
          },
          "command_hash": {
            "type": "string"
          },
          "approved_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  }
}