{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usewrit-app/json-schema/usewrit-app-automation-schema.json",
  "title": "Automation",
  "description": "One automation. On output the JSON-TEXT columns are PARSED: `conditions` is an object, `actions` an array, `blocks` an array or null.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/usewrit-app-automations-api-openapi.yml#/components/schemas/Automation",
  "type": "object",
  "required": [
    "id",
    "event_type",
    "name",
    "enabled",
    "conditions",
    "actions",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "target_id": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "event_type": {
      "type": "string",
      "description": "`change_detected` | `webhook_received` | `workflow_started` | `workflow_completed`."
    },
    "target_selector_id": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "workflow_id": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "webhook_trigger_id": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "enabled": {
      "type": "integer",
      "description": "0/1 integer flag."
    },
    "priority": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "conditions": {
      "type": "object",
      "description": "Parsed conditions object (parse failures degrade to `{}`).",
      "additionalProperties": true
    },
    "actions": {
      "type": "array",
      "description": "Parsed actions array (parse failures degrade to `[]`)."
    },
    "blocks": {
      "type": [
        "array",
        "null"
      ],
      "description": "Parsed block tree, or null."
    },
    "last_triggered_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "trigger_count": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64"
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": [
        "string",
        "null"
      ]
    }
  }
}