openapi: 3.0.0

info:
  title: Workflows Executions
  version: 1.0.0
  description: |
    Service for Workflow Executions which covers executions of processes defined in an Organization

servers:
  - url: https://workflows-execution.sls.epilot.io

tags:
  - name: Workflows
    description: Interact with workflow executions - start / close / retrieve one or all / search / delete

security:
  - BearerAuth: []

paths:
  /v1/workflows/executions:
    get:
      operationId: getExecutions
      summary: getExecutions
      description: Retrieve Workflow Executions. Optionally, you can filter them by context & schema. Please be aware, these executions are more light weight - steps are not loaded with all information.
      tags:
        - Workflows
      parameters:
        - in: query
          name: context
          schema:
            type: string
          required: false
          description: Id of an Entity
          example: 2843c005-c5b0-4df2-94ee-1ca2ddd998ac
        - in: query
          name: schema
          schema:
            type: string
          required: false
          description: Schema of an Entity
          example: contact
      responses:
        200:
          description: Success - executions loaded with success. Empty array if org has no executions.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/WorkflowExecutionSlim"
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
    post:
      operationId: createExecution
      summary: createExecution
      description: Create a Workflow Execution. Start a new workflow execution, based on a workflow definition (template).
      tags:
        - Workflows
      requestBody:
        description: Workflow Execution payload
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WorkflowExecutionCreateReq"
      responses:
        201:
          description: Success - if the execution is created successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WorkflowExecution"

        400:
          description: Validation Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        401:
          description: Authentication Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"

  /v1/workflows/executions/{executionId}:
    get:
      operationId: getExecution
      summary: getExecution
      description: Get a full workflow execution, included steps information, by execution id.
      tags:
        - Workflows
      parameters:
        - in: path
          name: executionId
          schema:
            type: string
          required: true
          description: Id of the execution
          example: wd561
      responses:
        200:
          description: Success - execution loaded with success. Empty response execution was not found.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WorkflowExecution"
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
    patch:
      operationId: updateExecution
      summary: updateExecution
      description: Patches updates like assignees, status, closingReason for a single Workflow Execution.
      tags:
        - Workflows
      parameters:
        - in: path
          name: executionId
          schema:
            type: string
          required: true
          description: Id of the execution
          example: wd561
      requestBody:
        description: Patch Updates for Workflow Execution payload.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WorkflowExecutionUpdateReq"
      responses:
        204:
          description: Success - execution updated with success.
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
    delete:
      operationId: deleteExecution
      summary: deleteExecution
      description: Delete workflow execution by id. Workflow contexts will NOT be deleted.
      tags:
        - Workflows
      parameters:
        - in: path
          name: executionId
          schema:
            type: string
          required: true
          description: Id of the execution to de deleted.
          example: CustomerRequest
      responses:
        204:
          description: Success - if the execution was deleted successfully
        401:
          description: Failed to authenticate
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        404:
          description: No execution found

  /v1/workflows/executions/{executionId}/steps:
    post:
      operationId: createStep
      summary: createStep
      description: Create a new step in current workflow execution.
      tags:
        - Workflows
      parameters:
        - in: path
          name: executionId
          schema:
            type: string
          required: true
          description: Id of the execution
          example: wd56125gah
      requestBody:
        description: Workflow Execution Step payload
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateStepReq"
      responses:
        201:
          description: Success - if the step is created with success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Step"
        400:
          description: Validation Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        401:
          description: Authentication Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"

  /v1/workflows/executions/{executionId}/steps/{stepId}:
    patch:
      operationId: updateStep
      summary: updateStep
      description: Patches various changes to a workflow execution step.
      tags:
        - Workflows
      parameters:
        - in: path
          name: executionId
          schema:
            type: string
          required: true
          description: Id of the execution
          example: wd56125gah
        - in: path
          name: stepId
          schema:
            type: string
          required: true
          description: Short uuid (length 6) to identify the Workflow Execution Step.
          example: 7hj28a
      requestBody:
        description: Workflow Execution Step payload
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateStepReq"
            examples:
              dynamicDueDate:
                value:
                  stepId: string
                  assignedTo: ["10010730"]
                  dynamicDueDate:
                    numberOfUnits: 2
                    timePeriod: weeks
                    actionTypeCondition: STEP_CLOSED
                    stepId: optional
                  name: "Static Duedate"
                  position:
                    index: 0
                  sectionId: string
                  status: string
      responses:
        200:
          description: Success - if the step is updated successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Step"
        400:
          description: Validation Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        401:
          description: Authentication Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
    delete:
      operationId: deleteStep
      summary: deleteStep
      description: Deletes a step from a workflow execution.
      tags:
        - Workflows
      parameters:
        - in: path
          name: executionId
          schema:
            type: string
          required: true
          description: Id of the execution
          example: wd56125gah
        - in: path
          name: stepId
          schema:
            type: string
          required: true
          description: Short uuid (length 6) to identify the Workflow Execution Step.
          example: 7hj28a
      responses:
        204:
          description: Deletion happened with success.
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"

  /v1/workflows/executions/search:
    post:
      operationId: searchExecutions
      summary: searchExecutions
      description: Search Workflow Executions by different filters.
      tags:
        - Workflows
      requestBody:
        description: Search steps request
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchExecutionsReq"
      responses:
        200:
          description: Success - filtered steps are returned
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SearchExecutionsResp"

        400:
          description: Validation Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        401:
          description: Authentication Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"

  /v1/workflows/executions/steps/search:
    post:
      deprecated: true
      operationId: searchSteps
      summary: searchSteps
      description: Search workflow execution steps by different filters.
      tags:
        - Workflows
      requestBody:
        description: Search steps request
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SearchStepsReq"
      responses:
        200:
          description: Success - filtered steps are returned
          content:
            application/json:
              schema:
                type: object
                $ref: "#/components/schemas/SearchStepsResp"

        400:
          description: Validation Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        401:
          description: Authentication Errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"
        500:
          description: Other errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"

  /v1/workflows/executions/{executionId}/closing-reasons:
    get:
      operationId: getClosingReasonExecution
      summary: getClosingReasonExecution
      description: |
        Shows all Closing Reasons defined at the moment of starting the Workflow Execution.
        The Closing Reasons shown in the execution are just snapshots
        from the state of the Definition when the instance was created.
      tags:
        - Workflows
      parameters:
        - in: path
          name: executionId
          schema:
            type: string
          required: true
          description: Id of the execution
          example: wd561
      responses:
        200:
          description: returns all Closing Reasons for this Execution
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClosingReasonResp"
        500:
          description: Internal Issues
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResp"

components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  schemas:
    WorkflowExecutionCreateReq:
      type: object
      properties:
        workflowId:
          type: string
        trigger:
          $ref: "#/components/schemas/TriggerType"
        assignedTo:
          deprecated: true
          type: array
          items:
            type: string
        contexts:
          type: array
          items:
            $ref: "#/components/schemas/WorkflowContext"
      required:
        - workflowId
      example:
        workflowId: "j3f23fh23uif98"
        trigger: AUTOMATIC
        dueDate: "2021-04-27T12:01:13.000Z"
        contexts:
          - id: "3fa3fa86-0907-4642-a57e-0fe30a19874d"
            schema: "contact"
          - id: "3a6d42fa-5070-4723-b90f-41ead4303e33"
            schema: "opportunity"

    WorkflowExecutionUpdateReq:
      type: object
      properties:
        status:
          $ref: "#/components/schemas/WorkflowStatus"
        assignedTo:
          type: array
          items:
            type: string
        selectedClosingReasons:
          type: array
          items:
            $ref: "#/components/schemas/ClosingReason"
        closingReasonDescription:
          type: string
        dueDate:
          type: string
        dynamicDueDate:
          $ref: "#/components/schemas/DynamicDueDate"
        closedBy:
          type: string
          description: id of the user / partner user who is closing the workflow. For partner pass orgId_userId.
        contexts:
          type: array
          items:
            $ref: "#/components/schemas/WorkflowContext"
        completedTime:
          type: string
          description: Completed time of the workflow execution

    ClosingReason:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
      required:
        - id
        - title

    WorkflowContext:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        schema:
          type: string
      required:
        - id
        - title
        - schema

    WorkflowExecutionBase:
      type: object
      properties:
        id:
          type: string
        definitionId:
          type: string
        orgId:
          type: string
        name:
          type: string
        creationTime:
          type: string
          description: Creation timestamp which will double as started time as well
        lastUpdateTime:
          type: string
          description: Last Update timestamp
        dueDate:
          type: string
          description: Due date for finishing the workflow
        completedTime:
          type: string
          description: Completed time of the workflow execution
        dynamicDueDate:
          $ref: "#/components/schemas/DynamicDueDate"
        status:
          $ref: "#/components/schemas/WorkflowStatus"
        trigger:
          $ref: "#/components/schemas/TriggerType"
        assignedTo:
          type: array
          items:
            type: string
        lastModifiedBy:
          type: string
          description: Id of the user who closed workflow
        contexts:
          type: array
          items:
            $ref: "#/components/schemas/WorkflowContext"
        nextOpenStep:
          $ref: "#/components/schemas/StepId"
        configuredClosingReasonSnapshot:
          type: array
          items:
            $ref: "#/components/schemas/ClosingReason"
        selectedClosingReasons:
          type: array
          items:
            $ref: "#/components/schemas/ClosingReason"
        closingReasonDescription:
          type: string
        enableECPWorkflow:
          type: boolean
          description: Indicates whether this workflow is available for End Customer Portal or not. By default it's not.
        updateEntityAttributes:
          type: array
          items:
            $ref: "#/components/schemas/UpdateEntityAttributes"
        version:
          type: integer
          description: Version of the workflow execution

    WorkflowExecutionSlim:
      allOf:
        - $ref: "#/components/schemas/WorkflowExecutionBase"
        - $ref: "#/components/schemas/FlowSlim"
      example:
        id: 8gja72h6kas6h
        name: Lead Qualification
        trigger: MANUAL
        status: STARTED
        creationTime: "2021-04-27T12:01:13.000Z"
        lastUpdateTime: "2021-04-27T12:01:13.000Z"
        dueDate: "2021-04-27T12:01:13.000Z"
        flow:
          - id: sectionId1
            name: "Initial Information Gathering"
            steps:
              - id: sada5641f3a21
              - id: sada5641f3a22
              - id: sada5641f3a23
          - id: firstLevelStepId1

    FlowSlim:
      type: object
      properties:
        flow:
          type: array
          items:
            anyOf:
              - $ref: "#/components/schemas/Section"
              - $ref: "#/components/schemas/Step"
      required:
        - flow

    Flow:
      type: object
      properties:
        flow:
          type: array
          items:
            anyOf:
              - $ref: "#/components/schemas/Section"
              - $ref: "#/components/schemas/Step"
      required:
        - flow

    WorkflowExecution:
      allOf:
        - $ref: "#/components/schemas/WorkflowExecutionBase"
        - $ref: "#/components/schemas/Flow"
      example:
        id: 8gja72h6kas6h
        name: Lead Qualification
        trigger: MANUAL
        status: STARTED
        creationTime: "2021-04-27T12:01:13.000Z"
        lastUpdateTime: "2021-04-27T12:01:13.000Z"
        dueDate: "2021-04-27T12:01:13.000Z"
        assignedTo:
          - "252"
          - "29052"
        flow:
          - id: sectionId1
            name: "Initial Information Gathering"
            steps:
              - id: sada5641f3a21
                name: "Call client and confirm address and product"
                status: ASSIGNED
                assignedTo:
                  - "11"
              - id: sada5641f3a22
                name: "Check product availability"
                status: UNASSIGNED
              - id: sada5641f3a23
                name: "Send email confirming contact with the client"
                status: SKIPPED
          - id: firstLevelStepId1
            name: "Print and send catalog"
            status: SKIPPED
            dueDate: "2023-01-15T20:00:00"

    WorkflowStatus:
      type: string
      enum:
        - STARTED
        - DONE
        - CLOSED

    SectionSimplified:
      type: object
      description: A group of Steps that define the progress of the Workflow
      properties:
        id:
          type: string
        definitionId:
          type: string
        name:
          type: string
          description: Name for this Section
          example: "Lead Qualification"
        type:
          $ref: "#/components/schemas/ItemType"
        steps:
          type: array
          items:
            $ref: "#/components/schemas/StepSimplified"
      required:
        - id
        - name
        - type
        - steps

    Section:
      type: object
      description: A group of Steps that define the progress of the Workflow
      properties:
        id:
          type: string
        definitionId:
          type: string
        name:
          type: string
          description: Name for this Section
          example: "Lead Qualification"
        userIds:
          type: array
          items:
            type: number
          deprecated: true
          description: This field is deprecated. Please use assignedTo
        assignedTo:
          type: array
          items:
            type: string
        startedTime:
          type: string
        completedTime:
          type: string
        status:
          $ref: "#/components/schemas/SectionStatus"
        type:
          $ref: "#/components/schemas/ItemType"
        steps:
          type: array
          items:
            $ref: "#/components/schemas/Step"
      required:
        - id
        - name
        - type
        - steps

    StepId:
      type: object
      properties:
        id:
          type: string
        entityRefId:
          type: string
          deprecated: true
          description: This field is deprecated. It will be soon removed. Please use only id.

    StepSimplified:
      type: object
      properties:
        id:
          type: string
        definitionId:
          type: string
        entityRefId:
          type: string
          deprecated: true
          description: This field is deprecated. It will be soon removed. Please use only id.
        name:
          type: string
        description:
          $ref: '#/components/schemas/StepDescription'
        type:
          $ref: "#/components/schemas/ItemType"
        ecp:
          $ref: "#/components/schemas/ECPDetails"
        installer:
          $ref: "#/components/schemas/ECPDetails"
        enabled:
          type: boolean
        requirements:
          type: array
          items:
            $ref: "#/components/schemas/StepRequirement"
        executionType:
          description: Manual / Automation step
          $ref: "#/components/schemas/StepType"
      required:
        - id
        - name
        - type

    Step:
      allOf:
        - $ref: "#/components/schemas/StepSimplified"
        - type: object
          properties:
            sectionId:
              type: string
            executionId:
              type: string
            userIds:
              type: array
              items:
                type: number
              deprecated: true
              description: This field is deprecated. Please use assignedTo
            assignedTo:
              type: array
              items:
                type: string
            assignedToInProgress:
              description: The user which moved the step/task to the IN_PROGRESS state. The user should also be present in the assignedTo property of the step/task
              type: string
            status:
              $ref: "#/components/schemas/StepStatus"
            created:
              type: string
            lastUpdated:
              type: string
            startedTime:
              type: string
            completedTime:
              type: string
            dueDate:
              type: string
            dynamicDueDate:
              $ref: "#/components/schemas/DynamicDueDate"
            manuallyCreated:
              type: boolean
            enabled:
              type: boolean
              description: enabled flag results from calculating the requirements
            automationConfig:
              description: Configuration for automated steps
              $ref: "#/components/schemas/AutomationConfig"
            journey:
              $ref: '#/components/schemas/StepJourney'

    StepExtended:
      allOf:
        - $ref: "#/components/schemas/Step"
        - type: object
          properties:
            executionId:
              type: string
            executionName:
              type: string
            executionStatus:
              $ref: "#/components/schemas/WorkflowStatus"
            contexts:
              type: array
              items:
                allOf:
                  - $ref: "#/components/schemas/WorkflowContext"
          required:
            - executionId
            - executionName
            - executionStatus

    StepStatus:
      type: string
      enum:
        - UNASSIGNED
        - ASSIGNED
        - COMPLETED
        - SKIPPED
        - IN_PROGRESS

    SectionStatus:
      type: string
      enum:
        - OPEN
        - IN_PROGRESS
        - COMPLETED

    StepType:
      type: string
      enum:
        - MANUAL
        - AUTOMATION

    StepJourney:
      type: object
      properties:
        id:
          type: string
        journeyId:
          type: string
        name:
          type: string

    AutomationConfig:
      type: object
      description: Configuration for automation execution to run
      properties:
        flowId:
          type: string
          description: Id of the configured automation to run
        executionId:
          type: string
          description: Id of the automation execution which ran
        executionStatus:
          type: string
          description: Status of Automation Execution. Types can be found in Automation API
      required:
        - flowId

    ECPDetails:
      type: object
      description: Details regarding ECP for the workflow step
      properties:
        label:
          type: string
        journey:
          $ref: '#/components/schemas/StepJourney'

    StepDescription:
      type: object
      description: Longer information regarding Task
      properties:
        enabled:
          type: boolean
        value:
          type: string

    ItemType:
      type: string
      enum:
        - STEP
        - SECTION

    TriggerType:
      type: string
      enum:
        - MANUAL
        - AUTOMATIC

    CreateStepReq:
      type: object
      properties:
        insertionIndex:
          type: number
          default: 0
        name:
          type: string
        status:
          $ref: "#/components/schemas/StepStatus"
        sectionId:
          type: string
        executionType:
          description: Manual / Automation step
          $ref: "#/components/schemas/StepType"
        automationConfig:
          description: Configuration for automated steps
          $ref: "#/components/schemas/AutomationConfig"
      required:
        - name
        - insertionIndex

    UpdateStepReq:
      type: object
      properties:
        stepId:
          type: string
        entityRefId:
          type: string
          deprecated: true
          description: This field is deprecated. Please use stepId
        userIds:
          type: array
          items:
            type: number
          deprecated: true
          description: This field is deprecated. Please use assignedTo
        assignedTo:
          type: array
          items:
            type: string
        assignedToInProgress:
          description: The user which moved the step/task to the IN_PROGRESS state. The user should also be present in the assignedTo property of the step/task
          type: string
        status:
          $ref: "#/components/schemas/StepStatus"
        dueDate:
          type: string
        dynamicDueDate:
          $ref: "#/components/schemas/DynamicDueDate"
        name:
          type: string
        position:
          $ref: "#/components/schemas/StepPositionAt"
        automationConfig:
          $ref: "#/components/schemas/AutomationConfig"
        startedTime:
          type: string
        completedTime:
          type: string

    StepPositionAt:
      type: object
      properties:
        index:
          type: number
          default: 0
        sectionId:
          type: string
      required:
        - index

    UpdateStepResp:
      allOf:
        - $ref: "#/components/schemas/Step"

    SearchStepsResp:
      type: object
      properties:
        hits:
          type: number
          example: 50
        results:
          type: array
          items:
            allOf:
              - $ref: "#/components/schemas/StepExtended"

    SearchExecutionsReq:
      type: object
      properties:
        name:
          type: string
        status:
          $ref: "#/components/schemas/WorkflowStatus"
        includeDoneWorkflows:
          type: boolean
        assignedTo:
          type: string
        sorting:
          $ref: "#/components/schemas/SearchSorting"
        pagination:
          $ref: "#/components/schemas/ExecutionPaginationDynamo"

    SearchExecutionsResp:
      type: object
      properties:
        executions:
          type: array
          items:
            $ref: "#/components/schemas/WorkflowExecutionSlim"
        lastEvaluatedKey:
          $ref: "#/components/schemas/LastEvaluatedKey"
      required:
        - executions

    LastEvaluatedKey:
      type: object
      properties:
        orgId:
          type: string
        creationTime:
          type: string

    SearchStepsReq:
      type: object
      properties:
        executionName:
          type: string
        stepName:
          type: string
        assignedTo:
          type: number
        includeDoneWorkflows:
          type: boolean
        manuallyCreated:
          type: boolean
        status:
          type: string
          enum:
            - OPEN
            - COMPLETE
            - NEXT_OPEN_ITEM_IN_WORKFLOW
        sorting:
          $ref: "#/components/schemas/SearchSorting"
        pagination:
          $ref: "#/components/schemas/SearchPagination"

    SearchSorting:
      type: string
      enum:
        - A_Z
        - Z_A
        - DUE_DATE_ASC
        - DUE_DATE_DESC
        - TRIGGER_DATE_ASC
        - TRIGGER_DATE_DESC

    SearchPagination:
      type: object
      properties:
        from:
          type: number
        size:
          type: number

    ExecutionPaginationDynamo:
      type: object
      properties:
        orgId:
          type: string
        creationTime:
          type: string

    ErrorResp:
      type: object
      properties:
        message:
          type: string

    ClosingReasonResp:
      type: object
      properties:
        reasons:
          type: array
          items:
            $ref: "#/components/schemas/ClosingReason"

    PhaseInEntity:
      type: object
      properties:
        phase_id:
          type: string
        phase_name:
          type: string
        phase_progress:
          type: number

    WorkflowInEntity:
      type: object
      properties:
        # workflow information
        id:
          type: string
        definition_id:
          type: string
        name:
          type: string
        status:
          $ref: "#/components/schemas/WorkflowStatus"
        assignees:
          type: array
          items:
            type: string
        duedate:
          type: string
        last_update_time:
          type: string
        progress:
          type: number

        # first open task information from the workflow
        task_id:
          type: string
        task_name:
          type: string
        task_assignees:
          type: array
          items:
            type: string
        task_duedate:
          type: string
        task_execution_type:
          $ref: "#/components/schemas/StepType"
        task_status:
          $ref: "#/components/schemas/StepStatus"

        # first open phase information from the workflow
        phase_id:
          type: string
        phase_name:
          type: string
        phase_assignees:
          type: array
          items:
            type: string
        phase_progress:
          type: number

        # in progress phases
        phases_in_progress:
          type: array
          items:
            $ref: "#/components/schemas/PhaseInEntity"

        # closing reasons in case of wf cancelled
        selected_closing_reasons:
          type: array
          items:
            $ref: "#/components/schemas/ClosingReason"
        closing_reason_description:
          type: string

    UpdateEntityAttributes:
      type: object
      properties:
        source:
          type: string
          enum:
            - "workflow_status"
            - "current_section"
            - "current_step"
        target:
          type: object
          properties:
            # Field "slug" will be used from the entity
            entitySchema:
              type: string
              example: "opportunity"
            # Field "name" will be used from the entity attribute
            entityAttribute:
              type: string
              example: "my_status"
          required:
            - entitySchema
            - entityAttribute
      required:
        - source
        - target

    DynamicDueDate:
      description: set a Duedate for a step then a specific
      type: object
      properties:
        numberOfUnits:
          type: number
        timePeriod:
          type: string
          enum:
            - days
            - weeks
            - months
        actionTypeCondition:
          type: string
          enum:
            - WORKFLOW_STARTED
            - STEP_CLOSED
        stepId:
          type: string
      required:
        - numberOfUnits
        - timePeriod
        - actionType

    StepRequirement:
      description: describe the requirement for step enablement
      type: object
      properties:
        definitionId:
          type: string
        type:
          $ref: "#/components/schemas/ItemType"
        condition:
          type: string
          enum:
            - CLOSED
      required:
        - definitionId
        - type
        - condition
