{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/highlevel/json-schema/highlevel-create-action-dto-schema.json",
  "title": "CreateActionDTO",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/highlevel-actions-api-openapi.yml#/components/schemas/CreateActionDTO",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "triggerWorkflow",
        "updateContactField",
        "appointmentBooking",
        "stopBot",
        "humanHandOver",
        "advancedFollowup",
        "transferBot"
      ]
    },
    "name": {
      "type": "string"
    },
    "details": {
      "description": "Action-specific details. The structure depends on the action type. For TRIGGER_WORKFLOW use triggerWorkflowDto, for UPDATE_CONTACT_FIELD use updateContactFieldDto, for APPOINTMENT_BOOKING use appointmentBookingDto, for STOP_BOT use stopBotDto, for HUMAN_HAND_OVER use humanHandOverDto, for ADVANCED_FOLLOWUP use advancedFollowupDto, and for TRANSFER_BOT use transferBotDto.",
      "oneOf": [
        {
          "$ref": "#/$defs/triggerWorkflowDto"
        },
        {
          "$ref": "#/$defs/updateContactFieldDto"
        },
        {
          "$ref": "#/$defs/appointmentBookingDto"
        },
        {
          "$ref": "#/$defs/stopBotDto"
        },
        {
          "$ref": "#/$defs/humanHandOverDto"
        },
        {
          "$ref": "#/$defs/advancedFollowupDto"
        },
        {
          "$ref": "#/$defs/transferBotDto"
        }
      ]
    }
  },
  "required": [
    "type",
    "name",
    "details"
  ],
  "$defs": {
    "FollowupSequence": {
      "type": "object",
      "properties": {
        "id": {
          "type": "number",
          "description": "Unique identifier for this followup step"
        },
        "followupTimeUnit": {
          "type": "string",
          "enum": [
            "days",
            "hours",
            "minutes"
          ],
          "description": "Time unit for followup delay"
        },
        "followupTime": {
          "type": "number",
          "description": "Time duration before followup (max: 60 minutes, 24 hours, or 180 days depending on unit)"
        },
        "aiEnabledMessage": {
          "type": "boolean",
          "default": true,
          "description": "Whether to use AI to generate the followup message"
        },
        "triggerWorkflow": {
          "type": "boolean",
          "default": false,
          "description": "Whether to trigger a workflow during this followup"
        },
        "customMessage": {
          "type": "string",
          "description": "Custom message to send (when aiEnabledMessage is false)"
        },
        "workflowId": {
          "type": "string",
          "description": "Workflow ID to trigger (when triggerWorkflow is true)"
        },
        "contactRequested": {
          "type": "boolean",
          "description": "Whether contact was requested in this followup"
        }
      },
      "required": [
        "id",
        "followupTimeUnit",
        "followupTime"
      ]
    },
    "FollowupSettings": {
      "type": "object",
      "properties": {
        "dynamicChannelSwitching": {
          "type": "boolean",
          "default": true,
          "description": "Whether to dynamically switch channels for followups"
        },
        "followUpHours": {
          "type": "boolean",
          "description": "Whether to respect working hours for followups"
        },
        "workingHours": {
          "description": "Working hours configuration for followups",
          "type": "array",
          "items": {
            "$ref": "#/$defs/WorkingHours"
          }
        },
        "timezoneToUse": {
          "type": "string",
          "enum": [
            "contact",
            "business"
          ],
          "description": "Timezone to use for followups, contact or location"
        }
      },
      "required": [
        "dynamicChannelSwitching"
      ]
    },
    "Interval": {
      "type": "object",
      "properties": {
        "startHour": {
          "type": "number",
          "description": "Start hour (24-hour format)"
        },
        "startMinute": {
          "type": "number",
          "description": "Start minute"
        },
        "endHour": {
          "type": "number",
          "description": "End hour (24-hour format)"
        },
        "endMinute": {
          "type": "number",
          "description": "End minute"
        }
      },
      "required": [
        "startHour",
        "startMinute",
        "endHour",
        "endMinute"
      ]
    },
    "WorkingHours": {
      "type": "object",
      "properties": {
        "dayOfTheWeek": {
          "type": "number",
          "description": "Day of the week (0=Sunday, 1=Monday, etc.)"
        },
        "intervals": {
          "description": "Time intervals for this day",
          "type": "array",
          "items": {
            "$ref": "#/$defs/Interval"
          }
        }
      },
      "required": [
        "dayOfTheWeek"
      ]
    },
    "advancedFollowupDto": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Whether advanced followup is enabled"
        },
        "scenarioId": {
          "type": "string",
          "enum": [
            "contactStoppedReplying",
            "contactIsBusy",
            "contactRequested"
          ],
          "description": "ID of the followup scenario"
        },
        "followupSequence": {
          "description": "Sequence of followup actions to perform",
          "type": "array",
          "items": {
            "$ref": "#/$defs/FollowupSequence"
          }
        },
        "followupSettings": {
          "description": "Additional settings for followup behavior",
          "allOf": [
            {
              "$ref": "#/$defs/FollowupSettings"
            }
          ]
        }
      },
      "required": [
        "enabled",
        "scenarioId",
        "followupSequence"
      ]
    },
    "appointmentBookingDto": {
      "type": "object",
      "properties": {
        "actionId": {
          "type": "string",
          "description": "Optional action ID reference"
        },
        "calendarId": {
          "type": "string",
          "description": "Calendar ID for appointment booking"
        },
        "onlySendLink": {
          "type": "boolean",
          "description": "If true, only sends the appointment link without booking"
        },
        "triggerWorkflow": {
          "type": "boolean",
          "description": "Whether to trigger a workflow after booking (cannot be true when onlySendLink is true)"
        },
        "workflowIds": {
          "description": "Workflow IDs to trigger after booking (required when triggerWorkflow is true)",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "sleepAfterBooking": {
          "type": "boolean",
          "description": "Whether to put the agent to sleep after booking (cannot be true when onlySendLink is true)"
        },
        "sleepTimeUnit": {
          "type": "string",
          "enum": [
            "days",
            "hours",
            "minutes"
          ],
          "description": "Unit for sleep time (required when sleepAfterBooking is true)"
        },
        "sleepTime": {
          "type": "number",
          "description": "Sleep duration (required when sleepAfterBooking is true)"
        },
        "transferBot": {
          "type": "boolean",
          "description": "Whether to transfer to another agent after booking (cannot be true when onlySendLink is true)"
        },
        "transferAgent": {
          "type": "string",
          "description": "Agent ID to transfer to (required when transferBot is true)"
        },
        "rescheduleEnabled": {
          "type": "boolean",
          "default": false,
          "description": "Whether to allow appointment rescheduling (cannot be true when onlySendLink is true)"
        },
        "cancelEnabled": {
          "type": "boolean",
          "default": false,
          "description": "Whether to allow appointment cancellation (cannot be true when onlySendLink is true)"
        }
      },
      "required": [
        "calendarId",
        "onlySendLink",
        "triggerWorkflow",
        "sleepAfterBooking",
        "transferBot",
        "rescheduleEnabled",
        "cancelEnabled"
      ]
    },
    "humanHandOverDto": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Whether human handover action is enabled"
        },
        "triggerCondition": {
          "type": "string",
          "description": "Condition that triggers human handover"
        },
        "assignToUserId": {
          "type": "string",
          "description": "ID of the user to assign the conversation to"
        },
        "skipAssignToUser": {
          "type": "boolean",
          "description": "Whether to skip assigning to a specific user"
        },
        "createTask": {
          "type": "boolean",
          "description": "Whether to create a task when handing over"
        },
        "reactivateEnabled": {
          "type": "boolean",
          "description": "Whether the agent can be reactivated after handover"
        },
        "sleepTimeUnit": {
          "type": "string",
          "enum": [
            "days",
            "hours",
            "minutes"
          ],
          "description": "Time unit for reactivation delay (required when reactivateEnabled is true)"
        },
        "sleepTime": {
          "type": "number",
          "description": "Time duration before reactivation (required when reactivateEnabled is true)"
        },
        "finalMessage": {
          "type": "string",
          "description": "Final message sent when handing over to human"
        },
        "tags": {
          "description": "Tags to apply during handover",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "handoverType": {
          "type": "string",
          "enum": [
            "contactRequest",
            "lackOfInformation",
            "failedToResolveIssue",
            "custom"
          ],
          "description": "Type of human handover detection"
        }
      },
      "required": [
        "enabled",
        "triggerCondition",
        "reactivateEnabled",
        "finalMessage",
        "handoverType"
      ]
    },
    "stopBotDto": {
      "type": "object",
      "properties": {
        "stopBotDetectionType": {
          "type": "string",
          "enum": [
            "Goodbye",
            "Custom"
          ],
          "description": "Type of stop bot detection - Goodbye or Custom"
        },
        "stopBotTriggerCondition": {
          "type": "string",
          "description": "Condition that triggers stopping the bot"
        },
        "reactivateEnabled": {
          "type": "boolean",
          "description": "Whether the bot can be reactivated after being stopped"
        },
        "sleepTimeUnit": {
          "type": "string",
          "enum": [
            "days",
            "hours",
            "minutes"
          ],
          "description": "Time unit for reactivation delay (required when reactivateEnabled is true)"
        },
        "sleepTime": {
          "type": "number",
          "description": "Time duration before reactivation (required when reactivateEnabled is true)"
        },
        "enabled": {
          "type": "boolean",
          "description": "Whether this action is enabled for the agent"
        },
        "stopBotExamples": {
          "description": "Example phrases that trigger stop bot action (minimum 2 required)",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "finalMessage": {
          "type": "string",
          "description": "Final message sent when stopping the bot"
        },
        "tags": {
          "description": "Tags to apply when stopping the bot",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "stopBotDetectionType",
        "stopBotTriggerCondition",
        "reactivateEnabled",
        "enabled",
        "stopBotExamples",
        "finalMessage"
      ]
    },
    "transferBotDto": {
      "type": "object",
      "properties": {
        "transferBotType": {
          "type": "string",
          "enum": [
            "Default",
            "Custom"
          ],
          "description": "Type of transfer - Default or Custom"
        },
        "transferToBot": {
          "type": "string",
          "description": "ID of the bot/agent to transfer to"
        },
        "enabled": {
          "type": "boolean",
          "description": "Whether this transfer action is enabled"
        },
        "transferBotTriggerCondition": {
          "type": "string",
          "description": "Condition that triggers the transfer (required for Custom type)"
        },
        "transferBotExamples": {
          "description": "Example phrases that trigger transfer (required for Custom type, minimum 2)",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "transferBotType",
        "transferToBot",
        "enabled"
      ]
    },
    "triggerWorkflowDto": {
      "type": "object",
      "properties": {
        "workflowIds": {
          "description": "Array of workflow IDs to trigger",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "triggerCondition": {
          "type": "string",
          "description": "Condition that triggers the workflow"
        },
        "triggerMessage": {
          "type": "string",
          "description": "Optional message to send when triggering the workflow"
        }
      },
      "required": [
        "workflowIds",
        "triggerCondition"
      ]
    },
    "updateContactFieldDto": {
      "type": "object",
      "properties": {
        "contactFieldId": {
          "type": "string",
          "description": "ID of the contact field in Contacts Table"
        },
        "description": {
          "type": "string",
          "description": "Description of the contact field in Contacts Table"
        },
        "contactUpdateExamples": {
          "default": [],
          "description": "Contact update examples in Contacts Table. Not required when using standard fields, Monetory or Date Custom fields.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "contactFieldId",
        "description"
      ]
    }
  }
}