{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/foxnfe-com-br/json-schema/foxnfe-com-br-post-api-v1-automations-request-schema.json",
  "title": "post_api_v1_automationsRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": [
    "app/app/Modules/Automation/Http/Controllers/AutomationRuleController.php:128"
  ],
  "type": "object",
  "properties": {
    "name": {
      "x-laravel-rules": [
        "required",
        "string",
        "max:80",
        "regex:/^[\\pL\\pN\\p{Pd} _.]+$/u"
      ],
      "type": "string",
      "maxLength": 80
    },
    "trigger_event": {
      "x-laravel-rules": [
        "required",
        "string",
        "in:"
      ],
      "type": "string",
      "enum": [
        ""
      ]
    },
    "conditions": {
      "x-laravel-rules": [
        "sometimes",
        "array",
        "max:10"
      ],
      "type": "array",
      "maxItems": 10,
      "items": {
        "type": "object",
        "properties": {
          "field": {
            "x-laravel-rules": [
              "required",
              "string",
              "max:120",
              "regex:/^[A-Za-z0-9_.]+$/"
            ],
            "type": "string",
            "maxLength": 120,
            "pattern": "^[A-Za-z0-9_.]+$"
          },
          "op": {
            "x-laravel-rules": [
              "required",
              "in:eq,ne,gt,gte,lt,lte,contains,in,exists,not_exists"
            ],
            "enum": [
              "eq",
              "ne",
              "gt",
              "gte",
              "lt",
              "lte",
              "contains",
              "in",
              "exists",
              "not_exists"
            ]
          },
          "value": {
            "x-laravel-rules": [
              "nullable"
            ]
          }
        },
        "required": [
          "field",
          "op"
        ]
      }
    },
    "actions": {
      "x-laravel-rules": [
        "required",
        "array",
        "min:1",
        "max:3"
      ],
      "type": "array",
      "minItems": 1,
      "maxItems": 3,
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "x-laravel-rules": [
              "required",
              "in:webhook,email"
            ],
            "enum": [
              "webhook",
              "email"
            ]
          },
          "url": {
            "x-laravel-rules": [
              "required_if:actions.*.type,webhook",
              "nullable",
              "url",
              "max:500"
            ],
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Obrigatório quando actions.*.type,webhook.",
            "maxLength": 500
          },
          "secret": {
            "x-laravel-rules": [
              "nullable",
              "string",
              "max:128"
            ],
            "type": [
              "string",
              "null"
            ],
            "maxLength": 128
          },
          "to": {
            "x-laravel-rules": [
              "required_if:actions.*.type,email",
              "nullable",
              "email",
              "max:255"
            ],
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Obrigatório quando actions.*.type,email.",
            "maxLength": 255
          },
          "subject": {
            "x-laravel-rules": [
              "nullable",
              "string",
              "max:120"
            ],
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          }
        },
        "required": [
          "type"
        ]
      }
    }
  },
  "required": [
    "name",
    "trigger_event",
    "actions"
  ]
}