{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Feather AI API"
  },
  "servers": [
    {
      "url": "https://prod.featherhq.com",
      "description": "Production environment"
    }
  ],
  "components": {
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "truncatedKey": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          },
          "lastUsedAt": {
            "type": "string",
            "nullable": true
          },
          "clerkOrgId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "truncatedKey",
          "createdAt",
          "lastUsedAt",
          "clerkOrgId"
        ]
      },
      "GoneError": {
        "type": "object",
        "properties": {
          "status": {
            "type": "number"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "GONE"
            ]
          },
          "success": {
            "type": "boolean"
          }
        },
        "required": [
          "status",
          "message",
          "code",
          "success"
        ]
      },
      "TestingLabScenariosResponse": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number"
          },
          "next": {
            "type": "string",
            "nullable": true
          },
          "previous": {
            "type": "string",
            "nullable": true
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "name": {
                  "type": "string"
                },
                "personality": {
                  "type": "number"
                },
                "personality_name": {
                  "type": "string"
                },
                "phone_number": {
                  "type": "string"
                },
                "instructions": {
                  "type": "string"
                },
                "expected_outcome_prompt": {
                  "type": "string"
                },
                "scenario_language": {
                  "type": "string"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "id",
                "name",
                "personality",
                "personality_name",
                "phone_number",
                "instructions",
                "expected_outcome_prompt",
                "scenario_language",
                "tags"
              ]
            }
          }
        },
        "required": [
          "count",
          "next",
          "previous",
          "results"
        ]
      },
      "TestingLabGenerateScenariosRequest": {
        "type": "object",
        "properties": {
          "agent_id": {
            "type": "number"
          },
          "assistant_id": {
            "type": "string"
          },
          "personalities": {
            "type": "object",
            "additionalProperties": {
              "nullable": true
            }
          },
          "num_scenarios": {
            "type": "number"
          },
          "test_profile": {
            "type": "number"
          },
          "extra_instructions": {
            "type": "string"
          },
          "inbound_phone_number": {
            "type": "number"
          },
          "first_message": {
            "type": "string"
          },
          "generate_expected_outcomes": {
            "type": "boolean"
          },
          "expected_outcome_prompt": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tool_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "number"
            }
          }
        },
        "required": [
          "agent_id",
          "num_scenarios",
          "inbound_phone_number",
          "first_message"
        ]
      },
      "TestingLabScenarioDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "agent": {
            "type": "number"
          },
          "personality": {
            "type": "number"
          },
          "personality_name": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tool_ids": {
            "nullable": true
          },
          "runs": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "metric_names": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "phone_number": {
            "type": "string"
          },
          "first_message": {
            "type": "string"
          },
          "inbound_phone_number": {
            "type": "number"
          },
          "inbound_phone_number_data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "number"
              },
              "number": {
                "type": "string"
              },
              "phone_number_id": {
                "type": "string"
              },
              "common": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "number",
              "phone_number_id",
              "common"
            ]
          },
          "instructions": {
            "type": "string"
          },
          "simulation_description": {
            "type": "string"
          },
          "information_fields": {
            "type": "object",
            "additionalProperties": {
              "nullable": true
            }
          },
          "expected_outcome_prompt": {
            "type": "string"
          },
          "scenario_language": {
            "type": "string"
          },
          "test_profile": {
            "type": "number"
          },
          "test_profile_data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "number"
              },
              "agent": {
                "type": "number"
              },
              "name": {
                "type": "string"
              },
              "information": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              }
            },
            "required": [
              "id",
              "agent",
              "name",
              "information"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "agent",
          "personality",
          "personality_name",
          "tags",
          "runs",
          "metrics",
          "metric_names",
          "phone_number",
          "first_message",
          "inbound_phone_number",
          "inbound_phone_number_data",
          "instructions",
          "simulation_description",
          "information_fields",
          "expected_outcome_prompt",
          "scenario_language",
          "test_profile",
          "test_profile_data"
        ]
      },
      "TestingLabUpdatedScenario": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "agent": {
            "type": "number"
          },
          "personality": {
            "type": "number"
          },
          "personality_name": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tool_ids": {
            "nullable": true
          },
          "runs": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "metric_names": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "phone_number": {
            "type": "string"
          },
          "first_message": {
            "type": "string"
          },
          "inbound_phone_number": {
            "type": "number"
          },
          "inbound_phone_number_data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "number"
              },
              "number": {
                "type": "string"
              },
              "phone_number_id": {
                "type": "string"
              },
              "common": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "number",
              "phone_number_id",
              "common"
            ]
          },
          "instructions": {
            "type": "string"
          },
          "simulation_description": {
            "type": "string"
          },
          "information_fields": {
            "type": "object",
            "additionalProperties": {
              "nullable": true
            }
          },
          "expected_outcome_prompt": {
            "type": "string"
          },
          "scenario_language": {
            "type": "string"
          },
          "test_profile": {
            "type": "number"
          },
          "test_profile_data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "number"
              },
              "agent": {
                "type": "number"
              },
              "name": {
                "type": "string"
              },
              "information": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              }
            },
            "required": [
              "id",
              "agent",
              "name",
              "information"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "agent",
          "personality",
          "personality_name",
          "tags",
          "runs",
          "metrics",
          "metric_names",
          "phone_number",
          "first_message",
          "inbound_phone_number",
          "inbound_phone_number_data",
          "instructions",
          "simulation_description",
          "information_fields",
          "expected_outcome_prompt",
          "scenario_language",
          "test_profile",
          "test_profile_data"
        ]
      },
      "TestingLabUpdateScenarioRequest": {
        "type": "object",
        "properties": {
          "agent": {
            "type": "number"
          },
          "assistant_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "personality": {
            "type": "number"
          },
          "instructions": {
            "type": "string"
          },
          "expected_outcome_prompt": {
            "type": "string"
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tool_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "TestingLabRunScenariosResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "agent": {
            "type": "number"
          },
          "status": {
            "type": "string"
          },
          "success_rate": {
            "type": "number"
          },
          "run_as_text": {
            "type": "boolean"
          },
          "runs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "scenario": {
                  "type": "number"
                },
                "number": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "scenario",
                "number"
              ]
            }
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "agent",
          "status",
          "success_rate",
          "run_as_text",
          "runs",
          "created_at"
        ]
      },
      "TestingLabRunScenariosRequest": {
        "type": "object",
        "properties": {
          "agent_id": {
            "type": "number"
          },
          "assistant_id": {
            "type": "string"
          },
          "scenarios": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "frequency": {
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "outbound_phone_number": {
            "type": "string"
          }
        },
        "required": [
          "agent_id",
          "scenarios",
          "frequency",
          "name",
          "outbound_phone_number"
        ]
      },
      "CreateCekuraMetricResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "slug": {
            "type": "string",
            "nullable": true
          },
          "project": {
            "type": "number",
            "nullable": true
          },
          "agent": {
            "type": "number",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "enum": [
              "basic",
              "custom_prompt",
              "custom_code",
              "llm_judge"
            ]
          },
          "eval_type": {
            "type": "string",
            "enum": [
              "binary_workflow_adherence",
              "binary_qualitative",
              "continuous_qualitative",
              "numeric",
              "enum"
            ]
          },
          "enum_values": {
            "nullable": true
          },
          "audio_enabled": {
            "type": "boolean"
          },
          "prompt": {
            "type": "string",
            "nullable": true
          },
          "evaluation_trigger": {
            "type": "string",
            "enum": [
              "always",
              "automatic",
              "custom"
            ]
          },
          "evaluation_trigger_prompt": {
            "type": "string",
            "nullable": true
          },
          "trigger_type": {
            "type": "string",
            "nullable": true
          },
          "priority_assignment_prompt": {
            "type": "string",
            "nullable": true
          },
          "configuration": {
            "nullable": true
          },
          "overall_score": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "nullable": true
              }
            ]
          },
          "total_score": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "nullable": true
              }
            ]
          },
          "kb_file_ids": {
            "nullable": true
          },
          "knowledge_base_files": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "nullable": true
                }
              },
              {
                "nullable": true
              }
            ]
          },
          "observability_enabled": {
            "type": "boolean"
          },
          "simulation_enabled": {
            "type": "boolean"
          },
          "sampling_enabled": {
            "type": "boolean"
          },
          "alert_enabled": {
            "type": "boolean"
          },
          "alert_type": {
            "type": "string",
            "enum": [
              "disabled",
              "normal",
              "significant_change"
            ]
          },
          "alert_filters": {
            "nullable": true
          },
          "significant_change_alert_status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          },
          "significant_change_alert_direction": {
            "type": "string",
            "enum": [
              "",
              "increase",
              "decrease"
            ]
          },
          "slack_workspace": {
            "nullable": true
          },
          "slack_channel_id": {
            "type": "string",
            "nullable": true
          },
          "function_name": {
            "type": "string",
            "nullable": true
          },
          "custom_code": {
            "type": "string",
            "nullable": true
          },
          "vocera_defined_metric_code": {
            "type": "string",
            "nullable": true
          },
          "agents": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "add_to_new_agents": {
            "type": "boolean",
            "nullable": true
          },
          "assistant_id": {
            "type": "string",
            "nullable": true
          },
          "display_order": {
            "type": "integer",
            "nullable": true
          },
          "scenarios": {
            "type": "array",
            "items": {
              "nullable": true
            }
          },
          "reviews": {
            "type": "array",
            "items": {
              "nullable": true
            }
          },
          "window_size": {
            "type": "number",
            "nullable": true
          },
          "std_multiplier": {
            "type": "number",
            "nullable": true
          },
          "ewma_alpha": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "TestingLabMetricsResponse": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/CreateCekuraMetricResponse"
        }
      },
      "CreateCekuraMetricRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the metric"
          },
          "description": {
            "type": "string",
            "description": "Description of what this metric evaluates"
          },
          "audio_enabled": {
            "type": "boolean",
            "description": "Whether this metric evaluates audio content"
          },
          "prompt": {
            "type": "string",
            "description": "The evaluation prompt used for this metric"
          },
          "agent": {
            "type": "number",
            "nullable": true,
            "description": "ID of the agent for agent-level metrics. Either agent or project must be provided."
          },
          "project": {
            "type": "number",
            "nullable": true,
            "description": "ID of the project for project-level metrics. Either agent or project must be provided."
          },
          "agents": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "List of agent IDs to enable this project-level metric for. Only applicable when project is set."
          },
          "assistant_id": {
            "type": "string",
            "description": "External identifier for the assistant"
          },
          "type": {
            "type": "string",
            "enum": [
              "basic",
              "custom_prompt",
              "custom_code",
              "llm_judge"
            ],
            "description": "Type of metric"
          },
          "eval_type": {
            "type": "string",
            "enum": [
              "binary_workflow_adherence",
              "binary_qualitative",
              "continuous_qualitative",
              "numeric",
              "enum"
            ],
            "description": "Type of evaluation"
          },
          "enum_values": {
            "nullable": true,
            "description": "Possible values for enum-type metrics"
          },
          "evaluation_trigger": {
            "type": "string",
            "enum": [
              "always",
              "automatic",
              "custom"
            ],
            "description": "Evaluation trigger"
          },
          "evaluation_trigger_prompt": {
            "type": "string",
            "description": "Evaluation trigger prompt"
          },
          "simulation_enabled": {
            "type": "boolean",
            "description": "Whether this metric is enabled for simulation/scenario evaluators"
          },
          "observability_enabled": {
            "type": "boolean",
            "description": "Whether this metric is enabled for live observability evaluation"
          }
        },
        "required": [
          "name"
        ]
      },
      "UpdateCekuraMetricResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "slug": {
            "type": "string",
            "nullable": true
          },
          "project": {
            "type": "number",
            "nullable": true
          },
          "agent": {
            "type": "number",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "enum": [
              "basic",
              "custom_prompt",
              "custom_code",
              "llm_judge"
            ]
          },
          "eval_type": {
            "type": "string",
            "enum": [
              "binary_workflow_adherence",
              "binary_qualitative",
              "continuous_qualitative",
              "numeric",
              "enum"
            ]
          },
          "enum_values": {
            "nullable": true
          },
          "audio_enabled": {
            "type": "boolean"
          },
          "prompt": {
            "type": "string",
            "nullable": true
          },
          "evaluation_trigger": {
            "type": "string",
            "enum": [
              "always",
              "automatic",
              "custom"
            ]
          },
          "evaluation_trigger_prompt": {
            "type": "string",
            "nullable": true
          },
          "trigger_type": {
            "type": "string",
            "nullable": true
          },
          "priority_assignment_prompt": {
            "type": "string",
            "nullable": true
          },
          "configuration": {
            "nullable": true
          },
          "overall_score": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "nullable": true
              }
            ]
          },
          "total_score": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "nullable": true
              }
            ]
          },
          "kb_file_ids": {
            "nullable": true
          },
          "knowledge_base_files": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "nullable": true
                }
              },
              {
                "nullable": true
              }
            ]
          },
          "observability_enabled": {
            "type": "boolean"
          },
          "simulation_enabled": {
            "type": "boolean"
          },
          "sampling_enabled": {
            "type": "boolean"
          },
          "alert_enabled": {
            "type": "boolean"
          },
          "alert_type": {
            "type": "string",
            "enum": [
              "disabled",
              "normal",
              "significant_change"
            ]
          },
          "alert_filters": {
            "nullable": true
          },
          "significant_change_alert_status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          },
          "significant_change_alert_direction": {
            "type": "string",
            "enum": [
              "",
              "increase",
              "decrease"
            ]
          },
          "slack_workspace": {
            "nullable": true
          },
          "slack_channel_id": {
            "type": "string",
            "nullable": true
          },
          "function_name": {
            "type": "string",
            "nullable": true
          },
          "custom_code": {
            "type": "string",
            "nullable": true
          },
          "vocera_defined_metric_code": {
            "type": "string",
            "nullable": true
          },
          "agents": {
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "add_to_new_agents": {
            "type": "boolean",
            "nullable": true
          },
          "assistant_id": {
            "type": "string",
            "nullable": true
          },
          "display_order": {
            "type": "integer",
            "nullable": true
          },
          "scenarios": {
            "type": "array",
            "items": {
              "nullable": true
            }
          },
          "reviews": {
            "type": "array",
            "items": {
              "nullable": true
            }
          },
          "window_size": {
            "type": "number",
            "nullable": true
          },
          "std_multiplier": {
            "type": "number",
            "nullable": true
          },
          "ewma_alpha": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "UpdateCekuraMetricRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the metric"
          },
          "description": {
            "type": "string",
            "description": "Description of what this metric evaluates"
          },
          "audio_enabled": {
            "type": "boolean",
            "description": "Whether this metric evaluates audio content"
          },
          "prompt": {
            "type": "string",
            "description": "The evaluation prompt used for this metric"
          },
          "agent": {
            "type": "number",
            "nullable": true,
            "description": "ID of the agent for agent-level metrics. Either agent or project must be provided."
          },
          "project": {
            "type": "number",
            "nullable": true,
            "description": "ID of the project for project-level metrics. Either agent or project must be provided."
          },
          "agents": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "List of agent IDs to enable this project-level metric for. Only applicable when project is set."
          },
          "assistant_id": {
            "type": "string",
            "description": "External identifier for the assistant"
          },
          "type": {
            "type": "string",
            "enum": [
              "basic",
              "custom_prompt",
              "custom_code",
              "llm_judge"
            ],
            "description": "Type of metric"
          },
          "eval_type": {
            "type": "string",
            "enum": [
              "binary_workflow_adherence",
              "binary_qualitative",
              "continuous_qualitative",
              "numeric",
              "enum"
            ],
            "description": "Type of evaluation"
          },
          "enum_values": {
            "nullable": true,
            "description": "Possible values for enum-type metrics"
          },
          "evaluation_trigger": {
            "type": "string",
            "enum": [
              "always",
              "automatic",
              "custom"
            ],
            "description": "Evaluation trigger"
          },
          "evaluation_trigger_prompt": {
            "type": "string",
            "description": "Evaluation trigger prompt"
          },
          "simulation_enabled": {
            "type": "boolean",
            "description": "Whether this metric is enabled for simulation/scenario evaluators"
          },
          "observability_enabled": {
            "type": "boolean",
            "description": "Whether this metric is enabled for live observability evaluation"
          }
        }
      },
      "CekuraCallEvaluation": {
        "type": "object",
        "nullable": true,
        "properties": {
          "metrics": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "binary_workflow_adherence",
                    "binary_qualitative",
                    "continuous_qualitative",
                    "numeric",
                    "enum"
                  ]
                },
                "explanation": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    {
                      "type": "string"
                    },
                    {
                      "nullable": true
                    }
                  ]
                },
                "extra": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": {
                    "nullable": true
                  }
                },
                "vocera_defined_metric_code": {
                  "type": "string",
                  "nullable": true
                },
                "function_name": {
                  "type": "string",
                  "nullable": true
                },
                "thumbs_up": {
                  "type": "boolean",
                  "nullable": true
                },
                "score": {
                  "type": "number",
                  "nullable": true
                },
                "score_normalized": {
                  "type": "number",
                  "nullable": true
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pass",
                    "failed",
                    "trigger_failed"
                  ]
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          }
        }
      },
      "CekuraCallLog": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "call_id": {
            "type": "string",
            "nullable": true
          },
          "duration": {
            "type": "string",
            "nullable": true
          },
          "voice_recording_url": {
            "type": "string",
            "nullable": true
          },
          "transcript": {
            "type": "string",
            "nullable": true
          },
          "transcript_object": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "nullable": true
              }
            ]
          },
          "agent_name": {
            "type": "string",
            "nullable": true
          },
          "agent": {
            "type": "number",
            "nullable": true
          },
          "project": {
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "success",
              "failure",
              "reviewed_success",
              "reviewed_failure"
            ]
          },
          "success": {
            "type": "boolean",
            "nullable": true
          },
          "is_reviewed": {
            "type": "boolean",
            "nullable": true
          },
          "evaluation": {
            "$ref": "#/components/schemas/CekuraCallEvaluation"
          },
          "rubric": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "number",
                  "nullable": true
                },
                "passed": {
                  "type": "boolean",
                  "nullable": true
                },
                "metric_id": {
                  "type": "number"
                },
                "conditions": {
                  "type": "string",
                  "nullable": true
                },
                "explanation": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    {
                      "type": "string"
                    },
                    {
                      "nullable": true
                    }
                  ]
                },
                "metric_name": {
                  "type": "string",
                  "nullable": true
                },
                "expected_conditions": {
                  "nullable": true
                }
              }
            }
          },
          "critical_categories": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "metadata": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "dynamic_variables": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "user_generated_transcript": {
            "nullable": true
          },
          "customer_number": {
            "type": "string",
            "nullable": true
          },
          "call_ended_reason": {
            "type": "string",
            "nullable": true
          },
          "topic": {
            "type": "string",
            "nullable": true
          },
          "dropoff_point": {
            "type": "string",
            "nullable": true
          },
          "feedback": {
            "type": "string",
            "nullable": true
          },
          "error_message": {
            "type": "string",
            "nullable": true
          },
          "testing_channel_index": {
            "type": "number",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "nullable": true
          },
          "agent_call_id": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "CekuraCallLogsResponse": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number"
          },
          "next": {
            "type": "string",
            "nullable": true
          },
          "previous": {
            "type": "string",
            "nullable": true
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CekuraCallLog"
            }
          }
        },
        "required": [
          "results"
        ]
      },
      "CekuraCallDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "call_id": {
            "type": "string",
            "nullable": true
          },
          "duration": {
            "type": "string",
            "nullable": true
          },
          "voice_recording_url": {
            "type": "string",
            "nullable": true
          },
          "transcript": {
            "type": "string",
            "nullable": true
          },
          "transcript_object": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "nullable": true
              }
            ]
          },
          "agent_name": {
            "type": "string",
            "nullable": true
          },
          "agent": {
            "type": "number",
            "nullable": true
          },
          "project": {
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "success",
              "failure",
              "reviewed_success",
              "reviewed_failure"
            ]
          },
          "success": {
            "type": "boolean",
            "nullable": true
          },
          "is_reviewed": {
            "type": "boolean",
            "nullable": true
          },
          "evaluation": {
            "$ref": "#/components/schemas/CekuraCallEvaluation"
          },
          "rubric": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "number",
                  "nullable": true
                },
                "passed": {
                  "type": "boolean",
                  "nullable": true
                },
                "metric_id": {
                  "type": "number"
                },
                "conditions": {
                  "type": "string",
                  "nullable": true
                },
                "explanation": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    {
                      "type": "string"
                    },
                    {
                      "nullable": true
                    }
                  ]
                },
                "metric_name": {
                  "type": "string",
                  "nullable": true
                },
                "expected_conditions": {
                  "nullable": true
                }
              }
            }
          },
          "critical_categories": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "metadata": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "dynamic_variables": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "user_generated_transcript": {
            "nullable": true
          },
          "customer_number": {
            "type": "string",
            "nullable": true
          },
          "call_ended_reason": {
            "type": "string",
            "nullable": true
          },
          "topic": {
            "type": "string",
            "nullable": true
          },
          "dropoff_point": {
            "type": "string",
            "nullable": true
          },
          "feedback": {
            "type": "string",
            "nullable": true
          },
          "error_message": {
            "type": "string",
            "nullable": true
          },
          "testing_channel_index": {
            "type": "number",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "nullable": true
          },
          "agent_call_id": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "CekuraAnalyticsResponse": {
        "type": "object",
        "properties": {
          "total_calls": {
            "type": "number"
          },
          "success_rate": {
            "type": "number",
            "nullable": true
          },
          "avg_duration": {
            "type": "number",
            "nullable": true
          },
          "success_over_time": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "time_interval": {
                  "type": "string"
                },
                "succeeded": {
                  "type": "number"
                },
                "failed": {
                  "type": "number"
                },
                "total": {
                  "type": "number"
                }
              },
              "required": [
                "time_interval",
                "succeeded",
                "failed",
                "total"
              ]
            }
          },
          "call_outcomes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "value": {
                  "type": "number"
                },
                "percentage": {
                  "type": "number"
                }
              },
              "required": [
                "label",
                "value",
                "percentage"
              ]
            }
          },
          "metric_pass_rates": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "pass_rate": {
                  "type": "number",
                  "nullable": true
                },
                "eval_count": {
                  "type": "number"
                },
                "avg_score": {
                  "type": "number",
                  "nullable": true
                }
              },
              "required": [
                "id",
                "name",
                "pass_rate",
                "eval_count",
                "avg_score"
              ]
            }
          }
        },
        "required": [
          "total_calls",
          "success_rate",
          "avg_duration",
          "success_over_time",
          "call_outcomes",
          "metric_pass_rates"
        ]
      },
      "CekuraResultListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "agent": {
            "type": "number",
            "nullable": true
          },
          "agent_name": {
            "type": "string",
            "nullable": true
          },
          "agent_inbound": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "success_rate": {
            "type": "number",
            "nullable": true
          },
          "run_as_text": {
            "type": "boolean"
          },
          "is_cronjob": {
            "type": "boolean"
          },
          "runs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "status": {
                  "type": "string",
                  "nullable": true
                },
                "scenario": {
                  "type": "number",
                  "nullable": true
                },
                "number": {
                  "type": "string",
                  "nullable": true
                },
                "inbound_number": {
                  "type": "string",
                  "nullable": true
                },
                "scenario_name": {
                  "type": "string",
                  "nullable": true
                },
                "test_profile_name": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "id"
              ]
            }
          },
          "met_expected_outcome_count": {
            "type": "number"
          },
          "total_expected_outcome_count": {
            "type": "number"
          },
          "total_runs_count": {
            "type": "number"
          },
          "completed_runs_count": {
            "type": "number"
          },
          "success_runs_count": {
            "type": "number"
          },
          "failed_runs_count": {
            "type": "number"
          },
          "scenarios": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "name": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "id"
              ]
            }
          },
          "run_type": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "CekuraResultsListResponse": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number"
          },
          "next": {
            "type": "string",
            "nullable": true
          },
          "previous": {
            "type": "string",
            "nullable": true
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CekuraResultListItem"
            }
          }
        },
        "required": [
          "results"
        ]
      },
      "CekuraResultDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "agent": {
            "type": "number",
            "nullable": true
          },
          "agent_name": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "met_expected_outcome_count": {
            "type": "number"
          },
          "total_expected_outcome_count": {
            "type": "number"
          },
          "success_rate": {
            "type": "number",
            "nullable": true
          },
          "run_as_text": {
            "type": "boolean"
          },
          "is_cronjob": {
            "type": "boolean"
          },
          "runs": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "scenario": {
                  "type": "object",
                  "nullable": true,
                  "properties": {
                    "id": {
                      "type": "number"
                    },
                    "name": {
                      "type": "string",
                      "nullable": true
                    },
                    "personality_name": {
                      "type": "string",
                      "nullable": true
                    },
                    "phone_number": {
                      "type": "string",
                      "nullable": true
                    },
                    "expected_outcome_prompt": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                },
                "expected_outcome": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": {
                    "nullable": true
                  }
                },
                "success": {
                  "type": "boolean",
                  "nullable": true
                },
                "evaluation": {
                  "$ref": "#/components/schemas/CekuraCallEvaluation"
                },
                "status": {
                  "type": "string",
                  "nullable": true
                },
                "evaluation_status": {
                  "type": "string",
                  "nullable": true
                },
                "transcript_object": {
                  "type": "array",
                  "nullable": true,
                  "items": {
                    "type": "object",
                    "properties": {
                      "content": {
                        "type": "string"
                      },
                      "end_time": {
                        "type": "number"
                      },
                      "role": {
                        "type": "string"
                      },
                      "start_time": {
                        "type": "number"
                      },
                      "time": {
                        "type": "string"
                      }
                    }
                  }
                },
                "voice_recording": {
                  "type": "string",
                  "nullable": true
                },
                "timestamp": {
                  "type": "string",
                  "nullable": true
                },
                "executed_at": {
                  "type": "string",
                  "nullable": true
                },
                "error_message": {
                  "type": "string",
                  "nullable": true
                },
                "test_profile_name": {
                  "type": "string",
                  "nullable": true
                },
                "metadata": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": {
                    "nullable": true
                  }
                }
              },
              "required": [
                "id"
              ]
            }
          },
          "overall_evaluation": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "total_duration": {
            "type": "string",
            "nullable": true
          },
          "total_runs_count": {
            "type": "number"
          },
          "completed_runs_count": {
            "type": "number"
          },
          "success_runs_count": {
            "type": "number"
          },
          "failed_runs_count": {
            "type": "number"
          },
          "connected_runs": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "failed_infrastructure_runs": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "failed_workflow_runs": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "successful_calls": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "scenarios": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "name": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "id"
              ]
            }
          },
          "critical_categories": {
            "type": "array",
            "nullable": true,
            "items": {
              "nullable": true
            }
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "number"
                },
                "name": {
                  "type": "string"
                },
                "eval_type": {
                  "type": "string",
                  "nullable": true
                },
                "simulation_enabled": {
                  "type": "boolean"
                },
                "observability_enabled": {
                  "type": "boolean"
                },
                "function_name": {
                  "type": "string",
                  "nullable": true
                },
                "vocera_defined_metric_code": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "domain": {
            "type": "string",
            "nullable": true
          },
          "domain_logo": {
            "type": "string",
            "nullable": true
          },
          "runs_by_tags": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "latency_data": {
            "type": "object",
            "nullable": true,
            "properties": {
              "mean": {
                "type": "number",
                "nullable": true
              },
              "median": {
                "type": "number",
                "nullable": true
              },
              "p50": {
                "type": "number",
                "nullable": true
              },
              "p95": {
                "type": "number",
                "nullable": true
              },
              "p99": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "failed_reasons": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "run_type": {
            "type": "string",
            "nullable": true
          },
          "run_settings": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "created_at": {
            "type": "string",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "CekuraTestProfile": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "project": {
            "type": "number",
            "nullable": true
          },
          "agent": {
            "type": "number"
          },
          "agent_name": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "information": {
            "type": "object",
            "nullable": true,
            "additionalProperties": {
              "nullable": true
            }
          },
          "created_by": {
            "type": "number",
            "nullable": true
          },
          "last_updated_by": {
            "type": "number",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "nullable": true
          },
          "updated_at": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id",
          "agent"
        ]
      },
      "CekuraTestProfilesListResponse": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number"
          },
          "next": {
            "type": "string",
            "nullable": true
          },
          "previous": {
            "type": "string",
            "nullable": true
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CekuraTestProfile"
            }
          }
        },
        "required": [
          "results"
        ]
      },
      "CreateCekuraTestProfileRequest": {
        "type": "object",
        "properties": {
          "agent": {
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "information": {
            "type": "object",
            "additionalProperties": {
              "nullable": true
            }
          }
        },
        "required": [
          "agent"
        ]
      },
      "UpdateCekuraTestProfileRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "information": {
            "type": "object",
            "additionalProperties": {
              "nullable": true
            }
          }
        }
      },
      "CekuraMockTool": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "information": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object",
              "properties": {
                "input": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                },
                "output": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                }
              },
              "required": [
                "input",
                "output"
              ]
            }
          },
          "freetext_params": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            }
          },
          "mock_url": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "CekuraMockToolsListResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CekuraMockTool"
            }
          }
        },
        "required": [
          "results"
        ]
      },
      "CreateCekuraMockToolRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "description": {
            "type": "string"
          },
          "information": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "input": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                },
                "output": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                }
              },
              "required": [
                "input",
                "output"
              ]
            }
          },
          "freetext_params": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "name"
        ]
      },
      "UpdateCekuraMockToolRequest": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "information": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "input": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                },
                "output": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                }
              },
              "required": [
                "input",
                "output"
              ]
            }
          },
          "freetext_params": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "WorkflowSchedule": {
        "type": "object",
        "properties": {
          "monday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "tuesday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "wednesday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "thursday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "friday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "saturday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "sunday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "globalTimeRanges": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "startHour": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 23,
                  "description": "Start hour (0-23)",
                  "example": 9
                },
                "startMinute": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 59,
                  "description": "Start minute (0-59)",
                  "example": 0
                },
                "endHour": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 23,
                  "description": "End hour (0-23)",
                  "example": 17
                },
                "endMinute": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 59,
                  "description": "End minute (0-59)",
                  "example": 0
                }
              },
              "required": [
                "startHour",
                "startMinute",
                "endHour",
                "endMinute"
              ],
              "description": "Time range for a day using separate hour/minute numbers",
              "example": {
                "startHour": 9,
                "startMinute": 0,
                "endHour": 17,
                "endMinute": 0
              }
            },
            "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
          },
          "exceptions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "Date in YYYY-MM-DD format",
                  "example": "2024-12-25"
                },
                "enabled": {
                  "type": "boolean",
                  "description": "Whether calls are allowed on this date"
                },
                "timeRanges": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "startHour": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 23,
                        "description": "Start hour (0-23)",
                        "example": 9
                      },
                      "startMinute": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 59,
                        "description": "Start minute (0-59)",
                        "example": 0
                      },
                      "endHour": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 23,
                        "description": "End hour (0-23)",
                        "example": 17
                      },
                      "endMinute": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 59,
                        "description": "End minute (0-59)",
                        "example": 0
                      }
                    },
                    "required": [
                      "startHour",
                      "startMinute",
                      "endHour",
                      "endMinute"
                    ],
                    "description": "Time range for a day using separate hour/minute numbers",
                    "example": {
                      "startHour": 9,
                      "startMinute": 0,
                      "endHour": 17,
                      "endMinute": 0
                    }
                  },
                  "description": "Custom time ranges for this exception date"
                },
                "reason": {
                  "type": "string",
                  "description": "Reason for the exception (e.g., \"Christmas Day\")"
                }
              },
              "required": [
                "date",
                "enabled"
              ]
            },
            "default": [],
            "description": "Exception dates (holidays, special events, etc.)"
          }
        },
        "description": "Workflow schedule - operates in workflow timezone defined above",
        "example": {
          "monday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 9,
                "startMinute": 0,
                "endHour": 17,
                "endMinute": 0
              }
            ]
          },
          "tuesday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 9,
                "startMinute": 0,
                "endHour": 17,
                "endMinute": 0
              }
            ]
          },
          "wednesday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 9,
                "startMinute": 0,
                "endHour": 17,
                "endMinute": 0
              }
            ]
          },
          "thursday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 9,
                "startMinute": 0,
                "endHour": 17,
                "endMinute": 0
              }
            ]
          },
          "friday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 9,
                "startMinute": 0,
                "endHour": 17,
                "endMinute": 0
              }
            ]
          },
          "saturday": {
            "enabled": false,
            "timeRanges": []
          },
          "sunday": {
            "enabled": false,
            "timeRanges": []
          }
        }
      },
      "TcpaSchedule": {
        "type": "object",
        "properties": {
          "monday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "tuesday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "wednesday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "thursday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "friday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "saturday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "sunday": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true,
                "description": "Whether this day is enabled"
              },
              "timeRanges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "startHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Start hour (0-23)",
                      "example": 9
                    },
                    "startMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "Start minute (0-59)",
                      "example": 0
                    },
                    "endHour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "End hour (0-23)",
                      "example": 17
                    },
                    "endMinute": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 59,
                      "description": "End minute (0-59)",
                      "example": 0
                    }
                  },
                  "required": [
                    "startHour",
                    "startMinute",
                    "endHour",
                    "endMinute"
                  ],
                  "description": "Time range for a day using separate hour/minute numbers",
                  "example": {
                    "startHour": 9,
                    "startMinute": 0,
                    "endHour": 17,
                    "endMinute": 0
                  }
                },
                "minItems": 0,
                "default": [],
                "description": "Time ranges when calls are allowed on this day"
              }
            },
            "description": "Schedule configuration for a specific day"
          },
          "globalTimeRanges": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "startHour": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 23,
                  "description": "Start hour (0-23)",
                  "example": 9
                },
                "startMinute": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 59,
                  "description": "Start minute (0-59)",
                  "example": 0
                },
                "endHour": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 23,
                  "description": "End hour (0-23)",
                  "example": 17
                },
                "endMinute": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 59,
                  "description": "End minute (0-59)",
                  "example": 0
                }
              },
              "required": [
                "startHour",
                "startMinute",
                "endHour",
                "endMinute"
              ],
              "description": "Time range for a day using separate hour/minute numbers",
              "example": {
                "startHour": 9,
                "startMinute": 0,
                "endHour": 17,
                "endMinute": 0
              }
            },
            "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
          },
          "stateOverrides": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "monday": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "default": true,
                      "description": "Whether this day is enabled"
                    },
                    "timeRanges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "startHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "Start hour (0-23)",
                            "example": 9
                          },
                          "startMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "Start minute (0-59)",
                            "example": 0
                          },
                          "endHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "End hour (0-23)",
                            "example": 17
                          },
                          "endMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "End minute (0-59)",
                            "example": 0
                          }
                        },
                        "required": [
                          "startHour",
                          "startMinute",
                          "endHour",
                          "endMinute"
                        ],
                        "description": "Time range for a day using separate hour/minute numbers",
                        "example": {
                          "startHour": 9,
                          "startMinute": 0,
                          "endHour": 17,
                          "endMinute": 0
                        }
                      },
                      "minItems": 0,
                      "default": [],
                      "description": "Time ranges when calls are allowed on this day"
                    }
                  },
                  "description": "Schedule configuration for a specific day"
                },
                "tuesday": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "default": true,
                      "description": "Whether this day is enabled"
                    },
                    "timeRanges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "startHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "Start hour (0-23)",
                            "example": 9
                          },
                          "startMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "Start minute (0-59)",
                            "example": 0
                          },
                          "endHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "End hour (0-23)",
                            "example": 17
                          },
                          "endMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "End minute (0-59)",
                            "example": 0
                          }
                        },
                        "required": [
                          "startHour",
                          "startMinute",
                          "endHour",
                          "endMinute"
                        ],
                        "description": "Time range for a day using separate hour/minute numbers",
                        "example": {
                          "startHour": 9,
                          "startMinute": 0,
                          "endHour": 17,
                          "endMinute": 0
                        }
                      },
                      "minItems": 0,
                      "default": [],
                      "description": "Time ranges when calls are allowed on this day"
                    }
                  },
                  "description": "Schedule configuration for a specific day"
                },
                "wednesday": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "default": true,
                      "description": "Whether this day is enabled"
                    },
                    "timeRanges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "startHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "Start hour (0-23)",
                            "example": 9
                          },
                          "startMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "Start minute (0-59)",
                            "example": 0
                          },
                          "endHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "End hour (0-23)",
                            "example": 17
                          },
                          "endMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "End minute (0-59)",
                            "example": 0
                          }
                        },
                        "required": [
                          "startHour",
                          "startMinute",
                          "endHour",
                          "endMinute"
                        ],
                        "description": "Time range for a day using separate hour/minute numbers",
                        "example": {
                          "startHour": 9,
                          "startMinute": 0,
                          "endHour": 17,
                          "endMinute": 0
                        }
                      },
                      "minItems": 0,
                      "default": [],
                      "description": "Time ranges when calls are allowed on this day"
                    }
                  },
                  "description": "Schedule configuration for a specific day"
                },
                "thursday": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "default": true,
                      "description": "Whether this day is enabled"
                    },
                    "timeRanges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "startHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "Start hour (0-23)",
                            "example": 9
                          },
                          "startMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "Start minute (0-59)",
                            "example": 0
                          },
                          "endHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "End hour (0-23)",
                            "example": 17
                          },
                          "endMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "End minute (0-59)",
                            "example": 0
                          }
                        },
                        "required": [
                          "startHour",
                          "startMinute",
                          "endHour",
                          "endMinute"
                        ],
                        "description": "Time range for a day using separate hour/minute numbers",
                        "example": {
                          "startHour": 9,
                          "startMinute": 0,
                          "endHour": 17,
                          "endMinute": 0
                        }
                      },
                      "minItems": 0,
                      "default": [],
                      "description": "Time ranges when calls are allowed on this day"
                    }
                  },
                  "description": "Schedule configuration for a specific day"
                },
                "friday": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "default": true,
                      "description": "Whether this day is enabled"
                    },
                    "timeRanges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "startHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "Start hour (0-23)",
                            "example": 9
                          },
                          "startMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "Start minute (0-59)",
                            "example": 0
                          },
                          "endHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "End hour (0-23)",
                            "example": 17
                          },
                          "endMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "End minute (0-59)",
                            "example": 0
                          }
                        },
                        "required": [
                          "startHour",
                          "startMinute",
                          "endHour",
                          "endMinute"
                        ],
                        "description": "Time range for a day using separate hour/minute numbers",
                        "example": {
                          "startHour": 9,
                          "startMinute": 0,
                          "endHour": 17,
                          "endMinute": 0
                        }
                      },
                      "minItems": 0,
                      "default": [],
                      "description": "Time ranges when calls are allowed on this day"
                    }
                  },
                  "description": "Schedule configuration for a specific day"
                },
                "saturday": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "default": true,
                      "description": "Whether this day is enabled"
                    },
                    "timeRanges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "startHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "Start hour (0-23)",
                            "example": 9
                          },
                          "startMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "Start minute (0-59)",
                            "example": 0
                          },
                          "endHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "End hour (0-23)",
                            "example": 17
                          },
                          "endMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "End minute (0-59)",
                            "example": 0
                          }
                        },
                        "required": [
                          "startHour",
                          "startMinute",
                          "endHour",
                          "endMinute"
                        ],
                        "description": "Time range for a day using separate hour/minute numbers",
                        "example": {
                          "startHour": 9,
                          "startMinute": 0,
                          "endHour": 17,
                          "endMinute": 0
                        }
                      },
                      "minItems": 0,
                      "default": [],
                      "description": "Time ranges when calls are allowed on this day"
                    }
                  },
                  "description": "Schedule configuration for a specific day"
                },
                "sunday": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean",
                      "default": true,
                      "description": "Whether this day is enabled"
                    },
                    "timeRanges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "startHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "Start hour (0-23)",
                            "example": 9
                          },
                          "startMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "Start minute (0-59)",
                            "example": 0
                          },
                          "endHour": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 23,
                            "description": "End hour (0-23)",
                            "example": 17
                          },
                          "endMinute": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 59,
                            "description": "End minute (0-59)",
                            "example": 0
                          }
                        },
                        "required": [
                          "startHour",
                          "startMinute",
                          "endHour",
                          "endMinute"
                        ],
                        "description": "Time range for a day using separate hour/minute numbers",
                        "example": {
                          "startHour": 9,
                          "startMinute": 0,
                          "endHour": 17,
                          "endMinute": 0
                        }
                      },
                      "minItems": 0,
                      "default": [],
                      "description": "Time ranges when calls are allowed on this day"
                    }
                  },
                  "description": "Schedule configuration for a specific day"
                }
              }
            },
            "description": "State-specific TCPA schedule overrides (e.g., different rules for CA, NY)"
          }
        },
        "description": "TCPA schedule - applies to borrower local timezone",
        "example": {
          "monday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 8,
                "startMinute": 0,
                "endHour": 21,
                "endMinute": 0
              }
            ]
          },
          "tuesday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 8,
                "startMinute": 0,
                "endHour": 21,
                "endMinute": 0
              }
            ]
          },
          "wednesday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 8,
                "startMinute": 0,
                "endHour": 21,
                "endMinute": 0
              }
            ]
          },
          "thursday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 8,
                "startMinute": 0,
                "endHour": 21,
                "endMinute": 0
              }
            ]
          },
          "friday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 8,
                "startMinute": 0,
                "endHour": 21,
                "endMinute": 0
              }
            ]
          },
          "saturday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 8,
                "startMinute": 0,
                "endHour": 21,
                "endMinute": 0
              }
            ]
          },
          "sunday": {
            "enabled": true,
            "timeRanges": [
              {
                "startHour": 13,
                "startMinute": 0,
                "endHour": 21,
                "endMinute": 0
              }
            ]
          }
        }
      },
      "PronunciationRule": {
        "type": "object",
        "properties": {
          "word": {
            "type": "string",
            "minLength": 1
          },
          "pronunciation": {
            "type": "string",
            "minLength": 1
          },
          "case_sensitive": {
            "type": "boolean",
            "default": false
          }
        },
        "required": [
          "word",
          "pronunciation"
        ]
      },
      "OverrideTTSConfig": {
        "type": "object",
        "nullable": true,
        "properties": {
          "pronunciations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PronunciationRule"
            },
            "default": []
          }
        }
      },
      "PostCallVariable": {
        "type": "object",
        "properties": {
          "variableName": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "STRING",
              "NUMBER",
              "BOOLEAN",
              "ARRAY"
            ]
          },
          "description": {
            "type": "string"
          },
          "required": {
            "type": "boolean",
            "default": false
          }
        },
        "required": [
          "variableName",
          "type"
        ]
      },
      "PreCallWebhook": {
        "type": "object",
        "nullable": true,
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "tool"
            ]
          },
          "toolId": {
            "type": "string",
            "minLength": 1
          },
          "toolSlug": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "mode",
          "toolId"
        ]
      },
      "WebDispatchConnectionDetails": {
        "type": "object",
        "properties": {
          "serverUrl": {
            "type": "string"
          },
          "roomName": {
            "type": "string"
          },
          "participantName": {
            "type": "string"
          },
          "participantToken": {
            "type": "string"
          }
        },
        "required": [
          "serverUrl",
          "roomName",
          "participantName",
          "participantToken"
        ]
      },
      "StartTestSessionResponse": {
        "type": "object",
        "properties": {
          "callId": {
            "type": "string"
          },
          "roomName": {
            "type": "string"
          },
          "livekitUrl": {
            "type": "string"
          },
          "accessToken": {
            "type": "string"
          },
          "agentVersion": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "number"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "version",
              "name"
            ]
          }
        },
        "required": [
          "callId",
          "roomName",
          "livekitUrl",
          "accessToken",
          "agentVersion"
        ]
      },
      "StartTestSessionRequest": {
        "type": "object",
        "properties": {
          "agentId": {
            "type": "string",
            "format": "uuid"
          },
          "agentVersionId": {
            "type": "string",
            "format": "uuid"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "variables": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "agentId",
          "agentVersionId"
        ]
      },
      "Calendar": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "organizationId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "string",
            "nullable": true
          },
          "archived": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "organizationId",
          "name",
          "description",
          "userId",
          "archived",
          "createdAt",
          "updatedAt"
        ]
      },
      "CalendarAvailability": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "days": {
            "type": "array",
            "items": {
              "type": "number",
              "minimum": 0,
              "maximum": 6
            }
          },
          "startTime": {
            "type": "number",
            "minimum": 0,
            "maximum": 1440
          },
          "endTime": {
            "type": "number",
            "minimum": 0,
            "maximum": 1440
          },
          "date": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id",
          "days",
          "startTime",
          "endTime",
          "date"
        ]
      },
      "CalendarSchedule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "calendarId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "isDefault": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "availabilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalendarAvailability"
            }
          }
        },
        "required": [
          "id",
          "calendarId",
          "name",
          "timezone",
          "isDefault",
          "createdAt",
          "updatedAt",
          "availabilities"
        ]
      },
      "CalendarEventType": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "calendarId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "duration": {
            "type": "number"
          },
          "slotInterval": {
            "type": "number",
            "nullable": true
          },
          "minimumBookingNotice": {
            "type": "number"
          },
          "beforeEventBuffer": {
            "type": "number"
          },
          "afterEventBuffer": {
            "type": "number"
          },
          "periodType": {
            "type": "string",
            "enum": [
              "UNLIMITED",
              "ROLLING",
              "RANGE"
            ]
          },
          "periodDays": {
            "type": "number",
            "nullable": true
          },
          "periodStartDate": {
            "type": "string",
            "nullable": true
          },
          "periodEndDate": {
            "type": "string",
            "nullable": true
          },
          "scheduleId": {
            "type": "string",
            "nullable": true
          },
          "location": {
            "type": "string",
            "nullable": true
          },
          "addGoogleMeet": {
            "type": "boolean"
          },
          "metadata": {
            "nullable": true
          },
          "active": {
            "type": "boolean"
          },
          "archived": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "calendarId",
          "name",
          "slug",
          "description",
          "duration",
          "slotInterval",
          "minimumBookingNotice",
          "beforeEventBuffer",
          "afterEventBuffer",
          "periodType",
          "periodDays",
          "periodStartDate",
          "periodEndDate",
          "scheduleId",
          "location",
          "addGoogleMeet",
          "active",
          "archived",
          "createdAt",
          "updatedAt"
        ]
      },
      "AvailableSlots": {
        "type": "object",
        "properties": {
          "slots": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "time": {
                    "type": "string"
                  }
                },
                "required": [
                  "time"
                ]
              }
            }
          }
        },
        "required": [
          "slots"
        ]
      },
      "CalendarBooking": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "organizationId": {
            "type": "string"
          },
          "calendarId": {
            "type": "string"
          },
          "eventTypeId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "startTime": {
            "type": "string"
          },
          "endTime": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "CONFIRMED",
              "CANCELLED",
              "RESCHEDULED",
              "NO_SHOW"
            ]
          },
          "attendeeName": {
            "type": "string",
            "nullable": true
          },
          "attendeeEmail": {
            "type": "string",
            "nullable": true
          },
          "attendeePhone": {
            "type": "string",
            "nullable": true
          },
          "location": {
            "type": "string",
            "nullable": true
          },
          "meetLink": {
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "nullable": true
          },
          "agentCallId": {
            "type": "string",
            "nullable": true
          },
          "leadId": {
            "type": "string",
            "nullable": true
          },
          "cancelledAt": {
            "type": "string",
            "nullable": true
          },
          "cancellationReason": {
            "type": "string",
            "nullable": true
          },
          "rescheduledFromId": {
            "type": "string",
            "nullable": true
          },
          "rescheduledToId": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "organizationId",
          "calendarId",
          "eventTypeId",
          "title",
          "description",
          "startTime",
          "endTime",
          "timezone",
          "status",
          "attendeeName",
          "attendeeEmail",
          "attendeePhone",
          "location",
          "meetLink",
          "agentCallId",
          "leadId",
          "cancelledAt",
          "cancellationReason",
          "rescheduledFromId",
          "rescheduledToId",
          "createdAt",
          "updatedAt"
        ]
      },
      "CalendarConnection": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "calendarId": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "GOOGLE",
              "OUTLOOK"
            ]
          },
          "accountEmail": {
            "type": "string"
          },
          "externalCalendarId": {
            "type": "string"
          },
          "invalid": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "calendarId",
          "provider",
          "accountEmail",
          "externalCalendarId",
          "invalid",
          "createdAt",
          "updatedAt"
        ]
      }
    },
    "parameters": {}
  },
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "Health check successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "status",
                    "timestamp"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/leads": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "List all leads",
        "description": "List all leads with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of leads retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "leads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "organizationId": {
                            "type": "string"
                          },
                          "customerLeadId": {
                            "type": "string"
                          },
                          "customer": {
                            "type": "object",
                            "nullable": true,
                            "additionalProperties": {
                              "type": "string"
                            }
                          },
                          "conversationHistory": {
                            "type": "array",
                            "nullable": true,
                            "items": {
                              "nullable": true
                            }
                          },
                          "phoneNumber": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "customerLeadId",
                          "customer",
                          "conversationHistory",
                          "phoneNumber",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "leads",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/leads/{leadId}/memories": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "List memories for a lead",
        "description": "List all memories for a lead with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "leadId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "page",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of memories retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "memories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "memory": {
                            "type": "string",
                            "nullable": true
                          },
                          "metadata": {
                            "type": "object",
                            "additionalProperties": {
                              "nullable": true
                            }
                          },
                          "createdAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "updatedAt": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "id",
                          "memory",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "memories",
                    "hasMore"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/twilio/import": {
      "post": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Connect Twilio account",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "accountSid": {
                    "type": "string"
                  },
                  "authToken": {
                    "type": "string"
                  },
                  "phoneNumber": {
                    "type": "string"
                  }
                },
                "required": [
                  "accountSid",
                  "authToken",
                  "phoneNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Twilio account connected successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "displayMessage": {
                      "type": "string"
                    },
                    "phoneNumberId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "displayMessage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/phone-number/inbound/{id}/dispatch-rule": {
      "delete": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Remove inbound dispatch rule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Dispatch rule removed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "displayMessage": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "displayMessage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Create inbound dispatch rule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentId": {
                    "type": "string"
                  },
                  "squadId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dispatch rule created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "displayMessage": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "displayMessage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/phone-number/{id}": {
      "delete": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Delete phone number",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Phone number deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "displayMessage": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "displayMessage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/phone-number/outbound/{id}/dispatch-rule": {
      "put": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Update outbound dispatch rules with bulk agent IDs",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "agentIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dispatch rules updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "displayMessage": {
                      "type": "string"
                    },
                    "agentIds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "success",
                    "displayMessage",
                    "agentIds"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/phone-numbers": {
      "get": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "List organization phone numbers",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "default": "100",
              "description": "Number of records to return (max 100)"
            },
            "required": false,
            "description": "Number of records to return (max 100)",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Cursor for pagination (format: createdAt_id)"
            },
            "required": false,
            "description": "Cursor for pagination (format: createdAt_id)",
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved organization phone numbers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "phoneNumbers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "city": {
                            "type": "string",
                            "nullable": true
                          },
                          "state": {
                            "type": "string",
                            "nullable": true
                          },
                          "country": {
                            "type": "string"
                          },
                          "ownership": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "FEATHER",
                              "CLIENT"
                            ]
                          },
                          "inboundAgent": {
                            "type": "object",
                            "properties": {
                              "agentId": {
                                "type": "string",
                                "nullable": true
                              },
                              "agentName": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          },
                          "outboundAgents": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "agentId": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "agentName": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "agentId",
                                "agentName"
                              ]
                            }
                          },
                          "smsLinkedAgent": {
                            "type": "object",
                            "properties": {
                              "agentId": {
                                "type": "string",
                                "nullable": true
                              },
                              "agentName": {
                                "type": "string",
                                "nullable": true
                              }
                            },
                            "required": [
                              "agentId",
                              "agentName"
                            ]
                          },
                          "squad": {
                            "type": "object",
                            "properties": {
                              "squadId": {
                                "type": "string"
                              },
                              "squadName": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "squadId",
                              "squadName"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "phoneNumber",
                          "city",
                          "state",
                          "country",
                          "ownership",
                          "inboundAgent",
                          "outboundAgents",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "phoneNumbers",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/phone-number/lookup/{phoneNumber}": {
      "get": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Get phone number by E.164 format",
        "description": "Get a phone number record by E.164 phone number (URL encoded, e.g., %2B14155551234)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The phone number in E.164 format (URL encoded)"
            },
            "required": true,
            "description": "The phone number in E.164 format (URL encoded)",
            "name": "phoneNumber",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Phone number retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "phoneNumber": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "phoneNumber": {
                          "type": "string"
                        },
                        "twilioSid": {
                          "type": "string",
                          "nullable": true
                        },
                        "ownership": {
                          "type": "string",
                          "nullable": true
                        },
                        "inboundAgentId": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "phoneNumber",
                        "twilioSid",
                        "ownership",
                        "inboundAgentId",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "phoneNumber"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Phone number not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/twilio/search": {
      "get": {
        "security": [
          {
            "ApiKey": []
          }
        ],
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Search available Twilio phone numbers",
        "description": "Search for available phone numbers from Twilio based on various criteria",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^\\d{3}$",
              "example": "415"
            },
            "required": false,
            "name": "areaCode",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^\\d{3}$",
              "example": "555"
            },
            "required": false,
            "name": "contains",
            "in": "query"
          },
          {
            "schema": {
              "type": "number",
              "minimum": 1,
              "maximum": 1000,
              "default": 20,
              "example": 20
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Available phone numbers retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "phoneNumbers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "friendlyName": {
                            "type": "string"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "lata": {
                            "type": "string",
                            "nullable": true
                          },
                          "rateCenter": {
                            "type": "string",
                            "nullable": true
                          },
                          "latitude": {
                            "type": "string",
                            "nullable": true
                          },
                          "longitude": {
                            "type": "string",
                            "nullable": true
                          },
                          "region": {
                            "type": "string",
                            "nullable": true
                          },
                          "postalCode": {
                            "type": "string",
                            "nullable": true
                          },
                          "isoCountry": {
                            "type": "string",
                            "nullable": true
                          },
                          "addressRequirements": {
                            "type": "string",
                            "nullable": true
                          },
                          "capabilities": {
                            "type": "object",
                            "properties": {
                              "voice": {
                                "type": "boolean",
                                "nullable": true
                              },
                              "SMS": {
                                "type": "boolean",
                                "nullable": true
                              },
                              "MMS": {
                                "type": "boolean",
                                "nullable": true
                              },
                              "fax": {
                                "type": "boolean",
                                "nullable": true
                              }
                            },
                            "required": [
                              "voice",
                              "SMS",
                              "MMS",
                              "fax"
                            ]
                          }
                        },
                        "required": [
                          "friendlyName",
                          "phoneNumber",
                          "lata",
                          "rateCenter",
                          "latitude",
                          "longitude",
                          "region",
                          "postalCode",
                          "isoCountry",
                          "addressRequirements",
                          "capabilities"
                        ]
                      }
                    }
                  },
                  "required": [
                    "success",
                    "phoneNumbers"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/twilio/purchase": {
      "post": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Purchase a Twilio phone number",
        "description": "Purchase a phone number from Twilio and add it to the organization. Requires sufficient phone_lines credits.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "string",
                    "pattern": "^\\+1\\d{10}$",
                    "description": "The phone number to purchase in E.164 format",
                    "example": "+14155551234"
                  },
                  "friendlyName": {
                    "type": "string",
                    "description": "A friendly name for the phone number",
                    "example": "My Business Line"
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Phone number purchased successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "phoneNumber": {
                      "type": "string"
                    },
                    "city": {
                      "type": "string",
                      "nullable": true
                    },
                    "state": {
                      "type": "string",
                      "nullable": true
                    },
                    "country": {
                      "type": "string"
                    },
                    "ownership": {
                      "type": "string",
                      "nullable": true,
                      "enum": [
                        "FEATHER",
                        "CLIENT"
                      ]
                    },
                    "inboundAgent": {
                      "type": "object",
                      "properties": {
                        "agentId": {
                          "type": "string",
                          "nullable": true
                        },
                        "agentName": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    },
                    "outboundAgents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "agentId": {
                            "type": "string",
                            "nullable": true
                          },
                          "agentName": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "agentId",
                          "agentName"
                        ]
                      }
                    },
                    "smsLinkedAgent": {
                      "type": "object",
                      "properties": {
                        "agentId": {
                          "type": "string",
                          "nullable": true
                        },
                        "agentName": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "agentId",
                        "agentName"
                      ]
                    },
                    "squad": {
                      "type": "object",
                      "properties": {
                        "squadId": {
                          "type": "string"
                        },
                        "squadName": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "squadId",
                        "squadName"
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "phoneNumber",
                    "city",
                    "state",
                    "country",
                    "ownership",
                    "inboundAgent",
                    "outboundAgents",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - insufficient credits or validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/phone-number/sms/{id}/link-agent": {
      "post": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Link SMS agent to phone number",
        "description": "Link an SMS agent to a phone number for SMS conversations. Only one SMS agent can be linked to a phone number at a time.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentId": {
                    "type": "string"
                  }
                },
                "required": [
                  "agentId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SMS agent linked successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "displayMessage": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "displayMessage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/phone-number/sms/{id}/unlink-agent": {
      "post": {
        "tags": [
          "Phone Numbers"
        ],
        "summary": "Unlink SMS agent from phone number",
        "description": "Remove the SMS agent link from a phone number",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "SMS agent unlinked successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "displayMessage": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "displayMessage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/twilio/bridging-number": {
      "post": {
        "tags": [
          "Bridging Numbers"
        ],
        "summary": "Import bridging number from Twilio account",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "twilioAccountSid": {
                    "type": "string",
                    "description": "Twilio Account SID",
                    "example": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                  },
                  "twilioAuthToken": {
                    "type": "string",
                    "description": "Twilio Auth Token",
                    "example": "your_auth_token_here"
                  },
                  "twilioNumberSid": {
                    "type": "string",
                    "description": "Twilio Phone Number SID",
                    "example": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                  }
                },
                "required": [
                  "twilioAccountSid",
                  "twilioAuthToken",
                  "twilioNumberSid"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bridging number imported successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bridgingNumber": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "phoneNumber": {
                          "type": "string"
                        },
                        "twilioSid": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "phoneNumber",
                        "twilioSid",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "bridgingNumber"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Bridging Numbers"
        ],
        "summary": "List organization bridging numbers",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved organization bridging numbers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bridgingNumbers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "twilioSid": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "phoneNumber",
                          "twilioSid",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "bridgingNumbers"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/twilio/bridging-number/{id}": {
      "delete": {
        "tags": [
          "Bridging Numbers"
        ],
        "summary": "Delete bridging number",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Bridging number deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/collections": {
      "get": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Get knowledge base collections",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of knowledge base collections retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "collections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "nullable": true
                          },
                          "description": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "files": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "fileName": {
                                  "type": "string"
                                },
                                "key": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string"
                                },
                                "createdAt": {
                                  "type": "string"
                                },
                                "updatedAt": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "size": {
                                  "type": "number",
                                  "nullable": true
                                },
                                "url": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "id",
                                "fileName",
                                "key",
                                "status",
                                "createdAt",
                                "updatedAt"
                              ]
                            }
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "createdAt",
                          "updatedAt",
                          "files"
                        ]
                      }
                    }
                  },
                  "required": [
                    "collections"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/files": {
      "get": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Get knowledge base files",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of knowledge base files retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "files": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "fileName": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "UPLOADED",
                              "INGESTED",
                              "FAILED"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "collectionIds": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "prompt": {
                            "type": "string",
                            "nullable": true
                          },
                          "size": {
                            "type": "number",
                            "nullable": true
                          },
                          "url": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "id",
                          "fileName",
                          "status",
                          "createdAt",
                          "updatedAt",
                          "collectionIds"
                        ]
                      }
                    }
                  },
                  "required": [
                    "files"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/collection/{collectionId}/file/{fileId}": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Add file to collection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "collectionId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "fileId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "File added to knowledge base collection successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/collection/{collectionId}/files/bulk-add": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Bulk add files to collection",
        "description": "Add multiple knowledge base files to a collection at once (max 100)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "collectionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fileIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 100,
                    "description": "Knowledge base file IDs (max 100, unique)"
                  }
                },
                "required": [
                  "fileIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bulk add results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "successful": {
                      "type": "number"
                    },
                    "failed": {
                      "type": "number"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "fileId": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "error": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "fileId",
                          "success",
                          "error"
                        ]
                      }
                    }
                  },
                  "required": [
                    "total",
                    "successful",
                    "failed",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/files/bulk-delete": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Bulk delete knowledge base files",
        "description": "Delete multiple knowledge base files at once (max 100)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fileIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 100,
                    "description": "Knowledge base file IDs (max 100, unique)"
                  }
                },
                "required": [
                  "fileIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bulk delete results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "successful": {
                      "type": "number"
                    },
                    "failed": {
                      "type": "number"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "fileId": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "error": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "fileId",
                          "success",
                          "error"
                        ]
                      }
                    }
                  },
                  "required": [
                    "total",
                    "successful",
                    "failed",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/collection/{collectionId}/files/bulk-remove": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Bulk remove files from collection",
        "description": "Remove multiple knowledge base files from a collection at once (max 100)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "collectionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fileIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 100,
                    "description": "Knowledge base file IDs (max 100, unique)"
                  }
                },
                "required": [
                  "fileIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bulk remove results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "successful": {
                      "type": "number"
                    },
                    "failed": {
                      "type": "number"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "fileId": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "error": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "fileId",
                          "success",
                          "error"
                        ]
                      }
                    }
                  },
                  "required": [
                    "total",
                    "successful",
                    "failed",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/collection/{id}": {
      "delete": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Delete knowledge base collection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge base collection deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/collection": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Create knowledge base collection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Knowledge base collection created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string",
                      "nullable": true
                    },
                    "description": {
                      "type": "string",
                      "nullable": true
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "description",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 401
                    },
                    "message": {
                      "type": "string",
                      "default": "Unauthorized"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "UNAUTHORIZED"
                      ],
                      "default": "UNAUTHORIZED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/file": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Create knowledge base file",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fileId": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  }
                },
                "required": [
                  "fileId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Knowledge base file created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "fileName": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "PENDING",
                        "UPLOADED",
                        "INGESTED",
                        "FAILED"
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "fileName",
                    "key",
                    "status",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/file/{id}": {
      "delete": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Delete knowledge base file",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge base file deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/generate-presigned-url": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Generate presigned URL for uploading a file",
        "description": "Generate a pre-signed URL for uploading a file to S3",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fileName": {
                    "type": "string"
                  }
                },
                "required": [
                  "fileName"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pre-signed URL generated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "fileId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url",
                    "fileId"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/collection/{collectionId}/file/{fileId}/remove": {
      "delete": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Remove file from collection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "collectionId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "fileId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge base file deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/file/{fileId}/status": {
      "patch": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "Update file status",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The ID of the knowledge base file to update"
            },
            "required": true,
            "description": "The ID of the knowledge base file to update",
            "name": "fileId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "INGESTED",
                      "FAILED"
                    ]
                  },
                  "documentCount": {
                    "type": "number"
                  },
                  "chunksCount": {
                    "type": "number"
                  }
                },
                "required": [
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Knowledge base file status updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 401
                    },
                    "message": {
                      "type": "string",
                      "default": "Unauthorized"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "UNAUTHORIZED"
                      ],
                      "default": "UNAUTHORIZED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/knowledge-base/file/{fileId}/view": {
      "post": {
        "tags": [
          "Knowledge Base"
        ],
        "summary": "View knowledge base file",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "fileId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge base file presigned URL generated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "presignedUrl": {
                      "type": "string"
                    },
                    "expiresIn": {
                      "type": "number"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "key",
                    "presignedUrl",
                    "expiresIn",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/scenarios": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Get testing lab scenarios",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Get the cekura test scenarios",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestingLabScenariosResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - Agent ID is required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/scenarios/generate": {
      "post": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Generate testing lab scenarios",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestingLabGenerateScenariosRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scenario generation initiated successfully. Generation is in progress.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad request - validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/scenarios/{id}": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Get testing lab scenario by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Get the cekura scenario details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestingLabScenarioDetail"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Scenario not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Delete testing lab scenario by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Scenario deleted successfully"
          },
          "400": {
            "description": "Bad request - Scenario ID is required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Scenario not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Update testing lab scenario by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestingLabUpdateScenarioRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scenario updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestingLabUpdatedScenario"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - validation error or missing scenario ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Scenario not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/scenarios/run": {
      "post": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Run testing lab scenarios",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestingLabRunScenariosRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Scenarios run initiated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestingLabRunScenariosResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/calls": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Get observed call logs for an agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "page_size",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "timestamp_from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "timestamp_to",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Call logs retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraCallLogsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - agentId is required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found or not connected to Cekura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/calls/{agentCallId}": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Get detail for a single observed call including per-metric scores",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentCallId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Call detail retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraCallDetail"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Call not found or not connected to Cekura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/analytics": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Get aggregated metric scores over time for an agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "start_time",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "end_time",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "hour",
                "day",
                "week"
              ]
            },
            "required": false,
            "name": "aggregation_period",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Analytics retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraAnalyticsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - agentId and start_time are required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found or not connected to Cekura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/results": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "List aggregated testing-lab results (Cekura test_framework/v1/results)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "page_size",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "timestamp_from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "timestamp_to",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Results retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraResultsListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found or not connected to Cekura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/results/{resultId}": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Get one aggregated testing-lab result with nested runs",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "resultId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Result detail retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraResultDetail"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Result not found, or agent not connected to Cekura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/test-profiles": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "List Cekura test profiles for an agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Test profiles retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraTestProfilesListResponse"
                }
              }
            }
          },
          "400": {
            "description": "agentId is required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found or not connected to Cekura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Create a Cekura test profile",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCekuraTestProfileRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Test profile created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraTestProfile"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/test-profiles/{id}": {
      "patch": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Update a Cekura test profile",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCekuraTestProfileRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Test profile updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraTestProfile"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Test profile not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Delete a Cekura test profile",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Test profile deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Test profile not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/mock-tools": {
      "get": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "List Cekura mock tools for an agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Mock tools retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraMockToolsListResponse"
                }
              }
            }
          },
          "400": {
            "description": "agentId is required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found or not connected to Cekura",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Create a Cekura mock tool",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/CreateCekuraMockToolRequest"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "agentId": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "agentId"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Mock tool created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraMockTool"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/testing-lab/mock-tools/by-name/{toolName}": {
      "patch": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Update a Cekura mock tool",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "toolName",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCekuraMockToolRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Mock tool updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CekuraMockTool"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Mock tool not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Testing Lab"
        ],
        "summary": "Delete a Cekura mock tool",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "toolName",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Mock tool deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "agentId is required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Mock tool not found in this organization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Create agent workflow",
        "description": "Create a new agent workflow",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255,
                    "description": "Workflow name"
                  },
                  "description": {
                    "type": "string",
                    "description": "Workflow description"
                  },
                  "active": {
                    "type": "boolean",
                    "default": true,
                    "description": "Whether the workflow is active"
                  },
                  "startHour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "default": 9,
                    "description": "Start hour (0-23) for backward compatibility"
                  },
                  "endHour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "default": 17,
                    "description": "End hour (0-23) for backward compatibility"
                  },
                  "timezone": {
                    "type": "string",
                    "default": "America/Los_Angeles",
                    "description": "Timezone for workflow execution and schedule interpretation"
                  },
                  "workflowSchedule": {
                    "$ref": "#/components/schemas/WorkflowSchedule"
                  },
                  "tcpaSchedule": {
                    "$ref": "#/components/schemas/TcpaSchedule"
                  },
                  "definition": {
                    "type": "object",
                    "properties": {
                      "steps": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ],
                              "description": "Type of workflow step"
                            },
                            "order": {
                              "type": "integer",
                              "minimum": 1,
                              "description": "Order of execution (1-indexed)"
                            },
                            "delayInSecs": {
                              "type": "integer",
                              "minimum": 0,
                              "default": 0,
                              "description": "Delay in seconds before executing this step"
                            },
                            "finishOn": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "COULD_NOT_CONNECT",
                                  "NO_ANSWER",
                                  "LEFT_VOICEMAIL",
                                  "VOICEMAIL_DETECTED",
                                  "SILENCE_TIMEOUT",
                                  "BAD_NUMBER",
                                  "NOT_INTERESTED",
                                  "WARM_TRANSFER",
                                  "WARM_TRANSFER_FAILED",
                                  "CALENDLY",
                                  "DNC",
                                  "ENDED",
                                  "FRAUD",
                                  "LINE_BUSY",
                                  "TEXT_CONSENT",
                                  "CALL_AGAIN"
                                ]
                              },
                              "default": [],
                              "description": "Call end reasons that should finish the workflow"
                            },
                            "agentId": {
                              "type": "string",
                              "format": "uuid",
                              "description": "Agent to use for this step"
                            },
                            "leaveVoicemail": {
                              "type": "boolean",
                              "default": false,
                              "description": "Whether to leave voicemail for call steps"
                            },
                            "initialMessage": {
                              "type": "string",
                              "maxLength": 1600,
                              "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                            },
                            "count": {
                              "type": "integer",
                              "minimum": 1,
                              "default": 1,
                              "description": "Number of times to repeat this step before moving to next"
                            }
                          },
                          "required": [
                            "type",
                            "order",
                            "agentId"
                          ]
                        },
                        "minItems": 1,
                        "description": "Workflow steps"
                      },
                      "isInfinite": {
                        "type": "boolean",
                        "default": false,
                        "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                      }
                    },
                    "required": [
                      "steps"
                    ],
                    "description": "Workflow definition"
                  },
                  "maxDialsPerTick": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1,
                    "description": "Per-workflow max dials per scheduler tick. null = uncapped (uses shared org budget)."
                  }
                },
                "required": [
                  "name",
                  "definition"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Agent workflow created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Workflow ID"
                    },
                    "name": {
                      "type": "string",
                      "description": "Workflow name"
                    },
                    "description": {
                      "type": "string",
                      "nullable": true,
                      "description": "Workflow description"
                    },
                    "organizationId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Organization ID"
                    },
                    "userId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "User ID who created the workflow"
                    },
                    "active": {
                      "type": "boolean",
                      "description": "Whether the workflow is active"
                    },
                    "startHour": {
                      "type": "integer",
                      "description": "Start hour (0-23) for backward compatibility"
                    },
                    "endHour": {
                      "type": "integer",
                      "description": "End hour (0-23) for backward compatibility"
                    },
                    "timezone": {
                      "type": "string",
                      "description": "Timezone for workflow execution and schedule interpretation"
                    },
                    "workflowSchedule": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "monday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "tuesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "wednesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "thursday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "friday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "saturday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "sunday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "globalTimeRanges": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "startHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "Start hour (0-23)",
                                "example": 9
                              },
                              "startMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "Start minute (0-59)",
                                "example": 0
                              },
                              "endHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "End hour (0-23)",
                                "example": 17
                              },
                              "endMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "End minute (0-59)",
                                "example": 0
                              }
                            },
                            "required": [
                              "startHour",
                              "startMinute",
                              "endHour",
                              "endMinute"
                            ],
                            "description": "Time range for a day using separate hour/minute numbers",
                            "example": {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          },
                          "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                        },
                        "exceptions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "date": {
                                "type": "string",
                                "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                                "description": "Date in YYYY-MM-DD format",
                                "example": "2024-12-25"
                              },
                              "enabled": {
                                "type": "boolean",
                                "description": "Whether calls are allowed on this date"
                              },
                              "timeRanges": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "startHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "Start hour (0-23)",
                                      "example": 9
                                    },
                                    "startMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "Start minute (0-59)",
                                      "example": 0
                                    },
                                    "endHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "End hour (0-23)",
                                      "example": 17
                                    },
                                    "endMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "End minute (0-59)",
                                      "example": 0
                                    }
                                  },
                                  "required": [
                                    "startHour",
                                    "startMinute",
                                    "endHour",
                                    "endMinute"
                                  ],
                                  "description": "Time range for a day using separate hour/minute numbers",
                                  "example": {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                },
                                "description": "Custom time ranges for this exception date"
                              },
                              "reason": {
                                "type": "string",
                                "description": "Reason for the exception (e.g., \"Christmas Day\")"
                              }
                            },
                            "required": [
                              "date",
                              "enabled"
                            ]
                          },
                          "default": [],
                          "description": "Exception dates (holidays, special events, etc.)"
                        }
                      },
                      "description": "Workflow schedule - operates in workflow timezone",
                      "example": {
                        "monday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "tuesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "wednesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "thursday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "friday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "saturday": {
                          "enabled": false,
                          "timeRanges": []
                        },
                        "sunday": {
                          "enabled": false,
                          "timeRanges": []
                        }
                      }
                    },
                    "tcpaSchedule": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "monday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "tuesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "wednesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "thursday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "friday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "saturday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "sunday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "globalTimeRanges": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "startHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "Start hour (0-23)",
                                "example": 9
                              },
                              "startMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "Start minute (0-59)",
                                "example": 0
                              },
                              "endHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "End hour (0-23)",
                                "example": 17
                              },
                              "endMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "End minute (0-59)",
                                "example": 0
                              }
                            },
                            "required": [
                              "startHour",
                              "startMinute",
                              "endHour",
                              "endMinute"
                            ],
                            "description": "Time range for a day using separate hour/minute numbers",
                            "example": {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          },
                          "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                        },
                        "stateOverrides": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "monday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "tuesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "wednesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "thursday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "friday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "saturday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "sunday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              }
                            }
                          },
                          "description": "State-specific TCPA schedule overrides (e.g., different rules for CA, NY)"
                        }
                      },
                      "description": "TCPA schedule - applies to borrower local timezone",
                      "example": {
                        "monday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "tuesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "wednesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "thursday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "friday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "saturday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "sunday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 13,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        }
                      }
                    },
                    "definition": {
                      "type": "object",
                      "properties": {
                        "steps": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ],
                                "description": "Type of workflow step"
                              },
                              "order": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Order of execution (1-indexed)"
                              },
                              "delayInSecs": {
                                "type": "integer",
                                "minimum": 0,
                                "default": 0,
                                "description": "Delay in seconds before executing this step"
                              },
                              "finishOn": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "COULD_NOT_CONNECT",
                                    "NO_ANSWER",
                                    "LEFT_VOICEMAIL",
                                    "VOICEMAIL_DETECTED",
                                    "SILENCE_TIMEOUT",
                                    "BAD_NUMBER",
                                    "NOT_INTERESTED",
                                    "WARM_TRANSFER",
                                    "WARM_TRANSFER_FAILED",
                                    "CALENDLY",
                                    "DNC",
                                    "ENDED",
                                    "FRAUD",
                                    "LINE_BUSY",
                                    "TEXT_CONSENT",
                                    "CALL_AGAIN"
                                  ]
                                },
                                "default": [],
                                "description": "Call end reasons that should finish the workflow"
                              },
                              "agentId": {
                                "type": "string",
                                "format": "uuid",
                                "description": "Agent to use for this step"
                              },
                              "leaveVoicemail": {
                                "type": "boolean",
                                "default": false,
                                "description": "Whether to leave voicemail for call steps"
                              },
                              "initialMessage": {
                                "type": "string",
                                "maxLength": 1600,
                                "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                              },
                              "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 1,
                                "description": "Number of times to repeat this step before moving to next"
                              }
                            },
                            "required": [
                              "type",
                              "order",
                              "agentId"
                            ]
                          },
                          "minItems": 1,
                          "description": "Workflow steps"
                        },
                        "isInfinite": {
                          "type": "boolean",
                          "default": false,
                          "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                        }
                      },
                      "required": [
                        "steps"
                      ],
                      "description": "Workflow definition"
                    },
                    "maxDialsPerTick": {
                      "type": "integer",
                      "nullable": true,
                      "minimum": 1,
                      "description": "Per-workflow max dials per scheduler tick. null = uncapped (uses shared org budget)."
                    },
                    "createdAt": {
                      "type": "string",
                      "description": "Creation timestamp"
                    },
                    "updatedAt": {
                      "type": "string",
                      "description": "Last update timestamp"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "description",
                    "organizationId",
                    "userId",
                    "active",
                    "startHour",
                    "endHour",
                    "timezone",
                    "workflowSchedule",
                    "tcpaSchedule",
                    "definition",
                    "maxDialsPerTick",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "List agent workflows",
        "description": "List agent workflows",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Filter by active status"
            },
            "required": false,
            "name": "active",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflows retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workflows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Workflow ID"
                          },
                          "name": {
                            "type": "string",
                            "description": "Workflow name"
                          },
                          "description": {
                            "type": "string",
                            "nullable": true,
                            "description": "Workflow description"
                          },
                          "organizationId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Organization ID"
                          },
                          "userId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "User ID who created the workflow"
                          },
                          "active": {
                            "type": "boolean",
                            "description": "Whether the workflow is active"
                          },
                          "startHour": {
                            "type": "integer",
                            "description": "Start hour (0-23) for backward compatibility"
                          },
                          "endHour": {
                            "type": "integer",
                            "description": "End hour (0-23) for backward compatibility"
                          },
                          "timezone": {
                            "type": "string",
                            "description": "Timezone for workflow execution and schedule interpretation"
                          },
                          "workflowSchedule": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "monday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "tuesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "wednesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "thursday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "friday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "saturday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "sunday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "globalTimeRanges": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "startHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "Start hour (0-23)",
                                      "example": 9
                                    },
                                    "startMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "Start minute (0-59)",
                                      "example": 0
                                    },
                                    "endHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "End hour (0-23)",
                                      "example": 17
                                    },
                                    "endMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "End minute (0-59)",
                                      "example": 0
                                    }
                                  },
                                  "required": [
                                    "startHour",
                                    "startMinute",
                                    "endHour",
                                    "endMinute"
                                  ],
                                  "description": "Time range for a day using separate hour/minute numbers",
                                  "example": {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                },
                                "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                              },
                              "exceptions": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "date": {
                                      "type": "string",
                                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                                      "description": "Date in YYYY-MM-DD format",
                                      "example": "2024-12-25"
                                    },
                                    "enabled": {
                                      "type": "boolean",
                                      "description": "Whether calls are allowed on this date"
                                    },
                                    "timeRanges": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "startHour": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 23,
                                            "description": "Start hour (0-23)",
                                            "example": 9
                                          },
                                          "startMinute": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 59,
                                            "description": "Start minute (0-59)",
                                            "example": 0
                                          },
                                          "endHour": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 23,
                                            "description": "End hour (0-23)",
                                            "example": 17
                                          },
                                          "endMinute": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 59,
                                            "description": "End minute (0-59)",
                                            "example": 0
                                          }
                                        },
                                        "required": [
                                          "startHour",
                                          "startMinute",
                                          "endHour",
                                          "endMinute"
                                        ],
                                        "description": "Time range for a day using separate hour/minute numbers",
                                        "example": {
                                          "startHour": 9,
                                          "startMinute": 0,
                                          "endHour": 17,
                                          "endMinute": 0
                                        }
                                      },
                                      "description": "Custom time ranges for this exception date"
                                    },
                                    "reason": {
                                      "type": "string",
                                      "description": "Reason for the exception (e.g., \"Christmas Day\")"
                                    }
                                  },
                                  "required": [
                                    "date",
                                    "enabled"
                                  ]
                                },
                                "default": [],
                                "description": "Exception dates (holidays, special events, etc.)"
                              }
                            },
                            "description": "Workflow schedule - operates in workflow timezone",
                            "example": {
                              "monday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "tuesday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "wednesday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "thursday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "friday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "saturday": {
                                "enabled": false,
                                "timeRanges": []
                              },
                              "sunday": {
                                "enabled": false,
                                "timeRanges": []
                              }
                            }
                          },
                          "tcpaSchedule": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "monday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "tuesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "wednesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "thursday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "friday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "saturday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "sunday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "globalTimeRanges": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "startHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "Start hour (0-23)",
                                      "example": 9
                                    },
                                    "startMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "Start minute (0-59)",
                                      "example": 0
                                    },
                                    "endHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "End hour (0-23)",
                                      "example": 17
                                    },
                                    "endMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "End minute (0-59)",
                                      "example": 0
                                    }
                                  },
                                  "required": [
                                    "startHour",
                                    "startMinute",
                                    "endHour",
                                    "endMinute"
                                  ],
                                  "description": "Time range for a day using separate hour/minute numbers",
                                  "example": {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                },
                                "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                              },
                              "stateOverrides": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "monday": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean",
                                          "default": true,
                                          "description": "Whether this day is enabled"
                                        },
                                        "timeRanges": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "startHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "Start hour (0-23)",
                                                "example": 9
                                              },
                                              "startMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "Start minute (0-59)",
                                                "example": 0
                                              },
                                              "endHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "End hour (0-23)",
                                                "example": 17
                                              },
                                              "endMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "End minute (0-59)",
                                                "example": 0
                                              }
                                            },
                                            "required": [
                                              "startHour",
                                              "startMinute",
                                              "endHour",
                                              "endMinute"
                                            ],
                                            "description": "Time range for a day using separate hour/minute numbers",
                                            "example": {
                                              "startHour": 9,
                                              "startMinute": 0,
                                              "endHour": 17,
                                              "endMinute": 0
                                            }
                                          },
                                          "minItems": 0,
                                          "default": [],
                                          "description": "Time ranges when calls are allowed on this day"
                                        }
                                      },
                                      "description": "Schedule configuration for a specific day"
                                    },
                                    "tuesday": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean",
                                          "default": true,
                                          "description": "Whether this day is enabled"
                                        },
                                        "timeRanges": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "startHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "Start hour (0-23)",
                                                "example": 9
                                              },
                                              "startMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "Start minute (0-59)",
                                                "example": 0
                                              },
                                              "endHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "End hour (0-23)",
                                                "example": 17
                                              },
                                              "endMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "End minute (0-59)",
                                                "example": 0
                                              }
                                            },
                                            "required": [
                                              "startHour",
                                              "startMinute",
                                              "endHour",
                                              "endMinute"
                                            ],
                                            "description": "Time range for a day using separate hour/minute numbers",
                                            "example": {
                                              "startHour": 9,
                                              "startMinute": 0,
                                              "endHour": 17,
                                              "endMinute": 0
                                            }
                                          },
                                          "minItems": 0,
                                          "default": [],
                                          "description": "Time ranges when calls are allowed on this day"
                                        }
                                      },
                                      "description": "Schedule configuration for a specific day"
                                    },
                                    "wednesday": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean",
                                          "default": true,
                                          "description": "Whether this day is enabled"
                                        },
                                        "timeRanges": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "startHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "Start hour (0-23)",
                                                "example": 9
                                              },
                                              "startMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "Start minute (0-59)",
                                                "example": 0
                                              },
                                              "endHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "End hour (0-23)",
                                                "example": 17
                                              },
                                              "endMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "End minute (0-59)",
                                                "example": 0
                                              }
                                            },
                                            "required": [
                                              "startHour",
                                              "startMinute",
                                              "endHour",
                                              "endMinute"
                                            ],
                                            "description": "Time range for a day using separate hour/minute numbers",
                                            "example": {
                                              "startHour": 9,
                                              "startMinute": 0,
                                              "endHour": 17,
                                              "endMinute": 0
                                            }
                                          },
                                          "minItems": 0,
                                          "default": [],
                                          "description": "Time ranges when calls are allowed on this day"
                                        }
                                      },
                                      "description": "Schedule configuration for a specific day"
                                    },
                                    "thursday": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean",
                                          "default": true,
                                          "description": "Whether this day is enabled"
                                        },
                                        "timeRanges": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "startHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "Start hour (0-23)",
                                                "example": 9
                                              },
                                              "startMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "Start minute (0-59)",
                                                "example": 0
                                              },
                                              "endHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "End hour (0-23)",
                                                "example": 17
                                              },
                                              "endMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "End minute (0-59)",
                                                "example": 0
                                              }
                                            },
                                            "required": [
                                              "startHour",
                                              "startMinute",
                                              "endHour",
                                              "endMinute"
                                            ],
                                            "description": "Time range for a day using separate hour/minute numbers",
                                            "example": {
                                              "startHour": 9,
                                              "startMinute": 0,
                                              "endHour": 17,
                                              "endMinute": 0
                                            }
                                          },
                                          "minItems": 0,
                                          "default": [],
                                          "description": "Time ranges when calls are allowed on this day"
                                        }
                                      },
                                      "description": "Schedule configuration for a specific day"
                                    },
                                    "friday": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean",
                                          "default": true,
                                          "description": "Whether this day is enabled"
                                        },
                                        "timeRanges": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "startHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "Start hour (0-23)",
                                                "example": 9
                                              },
                                              "startMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "Start minute (0-59)",
                                                "example": 0
                                              },
                                              "endHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "End hour (0-23)",
                                                "example": 17
                                              },
                                              "endMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "End minute (0-59)",
                                                "example": 0
                                              }
                                            },
                                            "required": [
                                              "startHour",
                                              "startMinute",
                                              "endHour",
                                              "endMinute"
                                            ],
                                            "description": "Time range for a day using separate hour/minute numbers",
                                            "example": {
                                              "startHour": 9,
                                              "startMinute": 0,
                                              "endHour": 17,
                                              "endMinute": 0
                                            }
                                          },
                                          "minItems": 0,
                                          "default": [],
                                          "description": "Time ranges when calls are allowed on this day"
                                        }
                                      },
                                      "description": "Schedule configuration for a specific day"
                                    },
                                    "saturday": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean",
                                          "default": true,
                                          "description": "Whether this day is enabled"
                                        },
                                        "timeRanges": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "startHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "Start hour (0-23)",
                                                "example": 9
                                              },
                                              "startMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "Start minute (0-59)",
                                                "example": 0
                                              },
                                              "endHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "End hour (0-23)",
                                                "example": 17
                                              },
                                              "endMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "End minute (0-59)",
                                                "example": 0
                                              }
                                            },
                                            "required": [
                                              "startHour",
                                              "startMinute",
                                              "endHour",
                                              "endMinute"
                                            ],
                                            "description": "Time range for a day using separate hour/minute numbers",
                                            "example": {
                                              "startHour": 9,
                                              "startMinute": 0,
                                              "endHour": 17,
                                              "endMinute": 0
                                            }
                                          },
                                          "minItems": 0,
                                          "default": [],
                                          "description": "Time ranges when calls are allowed on this day"
                                        }
                                      },
                                      "description": "Schedule configuration for a specific day"
                                    },
                                    "sunday": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean",
                                          "default": true,
                                          "description": "Whether this day is enabled"
                                        },
                                        "timeRanges": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "startHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "Start hour (0-23)",
                                                "example": 9
                                              },
                                              "startMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "Start minute (0-59)",
                                                "example": 0
                                              },
                                              "endHour": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 23,
                                                "description": "End hour (0-23)",
                                                "example": 17
                                              },
                                              "endMinute": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 59,
                                                "description": "End minute (0-59)",
                                                "example": 0
                                              }
                                            },
                                            "required": [
                                              "startHour",
                                              "startMinute",
                                              "endHour",
                                              "endMinute"
                                            ],
                                            "description": "Time range for a day using separate hour/minute numbers",
                                            "example": {
                                              "startHour": 9,
                                              "startMinute": 0,
                                              "endHour": 17,
                                              "endMinute": 0
                                            }
                                          },
                                          "minItems": 0,
                                          "default": [],
                                          "description": "Time ranges when calls are allowed on this day"
                                        }
                                      },
                                      "description": "Schedule configuration for a specific day"
                                    }
                                  }
                                },
                                "description": "State-specific TCPA schedule overrides (e.g., different rules for CA, NY)"
                              }
                            },
                            "description": "TCPA schedule - applies to borrower local timezone",
                            "example": {
                              "monday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 8,
                                    "startMinute": 0,
                                    "endHour": 21,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "tuesday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 8,
                                    "startMinute": 0,
                                    "endHour": 21,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "wednesday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 8,
                                    "startMinute": 0,
                                    "endHour": 21,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "thursday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 8,
                                    "startMinute": 0,
                                    "endHour": 21,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "friday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 8,
                                    "startMinute": 0,
                                    "endHour": 21,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "saturday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 8,
                                    "startMinute": 0,
                                    "endHour": 21,
                                    "endMinute": 0
                                  }
                                ]
                              },
                              "sunday": {
                                "enabled": true,
                                "timeRanges": [
                                  {
                                    "startHour": 13,
                                    "startMinute": 0,
                                    "endHour": 21,
                                    "endMinute": 0
                                  }
                                ]
                              }
                            }
                          },
                          "definition": {
                            "type": "object",
                            "properties": {
                              "steps": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "format": "uuid"
                                    },
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "CALL",
                                        "TEXT"
                                      ],
                                      "description": "Type of workflow step"
                                    },
                                    "order": {
                                      "type": "integer",
                                      "minimum": 1,
                                      "description": "Order of execution (1-indexed)"
                                    },
                                    "delayInSecs": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "default": 0,
                                      "description": "Delay in seconds before executing this step"
                                    },
                                    "finishOn": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "enum": [
                                          "COULD_NOT_CONNECT",
                                          "NO_ANSWER",
                                          "LEFT_VOICEMAIL",
                                          "VOICEMAIL_DETECTED",
                                          "SILENCE_TIMEOUT",
                                          "BAD_NUMBER",
                                          "NOT_INTERESTED",
                                          "WARM_TRANSFER",
                                          "WARM_TRANSFER_FAILED",
                                          "CALENDLY",
                                          "DNC",
                                          "ENDED",
                                          "FRAUD",
                                          "LINE_BUSY",
                                          "TEXT_CONSENT",
                                          "CALL_AGAIN"
                                        ]
                                      },
                                      "default": [],
                                      "description": "Call end reasons that should finish the workflow"
                                    },
                                    "agentId": {
                                      "type": "string",
                                      "format": "uuid",
                                      "description": "Agent to use for this step"
                                    },
                                    "leaveVoicemail": {
                                      "type": "boolean",
                                      "default": false,
                                      "description": "Whether to leave voicemail for call steps"
                                    },
                                    "initialMessage": {
                                      "type": "string",
                                      "maxLength": 1600,
                                      "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                                    },
                                    "count": {
                                      "type": "integer",
                                      "minimum": 1,
                                      "default": 1,
                                      "description": "Number of times to repeat this step before moving to next"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "order",
                                    "agentId"
                                  ]
                                },
                                "minItems": 1,
                                "description": "Workflow steps"
                              },
                              "isInfinite": {
                                "type": "boolean",
                                "default": false,
                                "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                              }
                            },
                            "required": [
                              "steps"
                            ],
                            "description": "Workflow definition"
                          },
                          "maxDialsPerTick": {
                            "type": "integer",
                            "nullable": true,
                            "minimum": 1,
                            "description": "Per-workflow max dials per scheduler tick. null = uncapped (uses shared org budget)."
                          },
                          "createdAt": {
                            "type": "string",
                            "description": "Creation timestamp"
                          },
                          "updatedAt": {
                            "type": "string",
                            "description": "Last update timestamp"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "organizationId",
                          "userId",
                          "active",
                          "startHour",
                          "endHour",
                          "timezone",
                          "workflowSchedule",
                          "tcpaSchedule",
                          "definition",
                          "maxDialsPerTick",
                          "createdAt",
                          "updatedAt"
                        ]
                      },
                      "description": "List of workflows"
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      },
                      "description": "Pagination information"
                    }
                  },
                  "required": [
                    "workflows",
                    "pagination"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{id}": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "Get agent workflow",
        "description": "Get an agent workflow by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Workflow ID"
                    },
                    "name": {
                      "type": "string",
                      "description": "Workflow name"
                    },
                    "description": {
                      "type": "string",
                      "nullable": true,
                      "description": "Workflow description"
                    },
                    "organizationId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Organization ID"
                    },
                    "userId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "User ID who created the workflow"
                    },
                    "active": {
                      "type": "boolean",
                      "description": "Whether the workflow is active"
                    },
                    "startHour": {
                      "type": "integer",
                      "description": "Start hour (0-23) for backward compatibility"
                    },
                    "endHour": {
                      "type": "integer",
                      "description": "End hour (0-23) for backward compatibility"
                    },
                    "timezone": {
                      "type": "string",
                      "description": "Timezone for workflow execution and schedule interpretation"
                    },
                    "workflowSchedule": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "monday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "tuesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "wednesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "thursday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "friday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "saturday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "sunday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "globalTimeRanges": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "startHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "Start hour (0-23)",
                                "example": 9
                              },
                              "startMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "Start minute (0-59)",
                                "example": 0
                              },
                              "endHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "End hour (0-23)",
                                "example": 17
                              },
                              "endMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "End minute (0-59)",
                                "example": 0
                              }
                            },
                            "required": [
                              "startHour",
                              "startMinute",
                              "endHour",
                              "endMinute"
                            ],
                            "description": "Time range for a day using separate hour/minute numbers",
                            "example": {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          },
                          "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                        },
                        "exceptions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "date": {
                                "type": "string",
                                "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                                "description": "Date in YYYY-MM-DD format",
                                "example": "2024-12-25"
                              },
                              "enabled": {
                                "type": "boolean",
                                "description": "Whether calls are allowed on this date"
                              },
                              "timeRanges": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "startHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "Start hour (0-23)",
                                      "example": 9
                                    },
                                    "startMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "Start minute (0-59)",
                                      "example": 0
                                    },
                                    "endHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "End hour (0-23)",
                                      "example": 17
                                    },
                                    "endMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "End minute (0-59)",
                                      "example": 0
                                    }
                                  },
                                  "required": [
                                    "startHour",
                                    "startMinute",
                                    "endHour",
                                    "endMinute"
                                  ],
                                  "description": "Time range for a day using separate hour/minute numbers",
                                  "example": {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                },
                                "description": "Custom time ranges for this exception date"
                              },
                              "reason": {
                                "type": "string",
                                "description": "Reason for the exception (e.g., \"Christmas Day\")"
                              }
                            },
                            "required": [
                              "date",
                              "enabled"
                            ]
                          },
                          "default": [],
                          "description": "Exception dates (holidays, special events, etc.)"
                        }
                      },
                      "description": "Workflow schedule - operates in workflow timezone",
                      "example": {
                        "monday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "tuesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "wednesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "thursday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "friday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "saturday": {
                          "enabled": false,
                          "timeRanges": []
                        },
                        "sunday": {
                          "enabled": false,
                          "timeRanges": []
                        }
                      }
                    },
                    "tcpaSchedule": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "monday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "tuesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "wednesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "thursday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "friday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "saturday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "sunday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "globalTimeRanges": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "startHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "Start hour (0-23)",
                                "example": 9
                              },
                              "startMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "Start minute (0-59)",
                                "example": 0
                              },
                              "endHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "End hour (0-23)",
                                "example": 17
                              },
                              "endMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "End minute (0-59)",
                                "example": 0
                              }
                            },
                            "required": [
                              "startHour",
                              "startMinute",
                              "endHour",
                              "endMinute"
                            ],
                            "description": "Time range for a day using separate hour/minute numbers",
                            "example": {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          },
                          "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                        },
                        "stateOverrides": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "monday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "tuesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "wednesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "thursday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "friday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "saturday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "sunday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              }
                            }
                          },
                          "description": "State-specific TCPA schedule overrides (e.g., different rules for CA, NY)"
                        }
                      },
                      "description": "TCPA schedule - applies to borrower local timezone",
                      "example": {
                        "monday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "tuesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "wednesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "thursday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "friday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "saturday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "sunday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 13,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        }
                      }
                    },
                    "definition": {
                      "type": "object",
                      "properties": {
                        "steps": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ],
                                "description": "Type of workflow step"
                              },
                              "order": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Order of execution (1-indexed)"
                              },
                              "delayInSecs": {
                                "type": "integer",
                                "minimum": 0,
                                "default": 0,
                                "description": "Delay in seconds before executing this step"
                              },
                              "finishOn": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "COULD_NOT_CONNECT",
                                    "NO_ANSWER",
                                    "LEFT_VOICEMAIL",
                                    "VOICEMAIL_DETECTED",
                                    "SILENCE_TIMEOUT",
                                    "BAD_NUMBER",
                                    "NOT_INTERESTED",
                                    "WARM_TRANSFER",
                                    "WARM_TRANSFER_FAILED",
                                    "CALENDLY",
                                    "DNC",
                                    "ENDED",
                                    "FRAUD",
                                    "LINE_BUSY",
                                    "TEXT_CONSENT",
                                    "CALL_AGAIN"
                                  ]
                                },
                                "default": [],
                                "description": "Call end reasons that should finish the workflow"
                              },
                              "agentId": {
                                "type": "string",
                                "format": "uuid",
                                "description": "Agent to use for this step"
                              },
                              "leaveVoicemail": {
                                "type": "boolean",
                                "default": false,
                                "description": "Whether to leave voicemail for call steps"
                              },
                              "initialMessage": {
                                "type": "string",
                                "maxLength": 1600,
                                "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                              },
                              "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 1,
                                "description": "Number of times to repeat this step before moving to next"
                              }
                            },
                            "required": [
                              "type",
                              "order",
                              "agentId"
                            ]
                          },
                          "minItems": 1,
                          "description": "Workflow steps"
                        },
                        "isInfinite": {
                          "type": "boolean",
                          "default": false,
                          "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                        }
                      },
                      "required": [
                        "steps"
                      ],
                      "description": "Workflow definition"
                    },
                    "maxDialsPerTick": {
                      "type": "integer",
                      "nullable": true,
                      "minimum": 1,
                      "description": "Per-workflow max dials per scheduler tick. null = uncapped (uses shared org budget)."
                    },
                    "createdAt": {
                      "type": "string",
                      "description": "Creation timestamp"
                    },
                    "updatedAt": {
                      "type": "string",
                      "description": "Last update timestamp"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "description",
                    "organizationId",
                    "userId",
                    "active",
                    "startHour",
                    "endHour",
                    "timezone",
                    "workflowSchedule",
                    "tcpaSchedule",
                    "definition",
                    "maxDialsPerTick",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Workflows"
        ],
        "summary": "Update agent workflow",
        "description": "Update an agent workflow",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255,
                    "description": "Workflow name"
                  },
                  "description": {
                    "type": "string",
                    "description": "Workflow description"
                  },
                  "active": {
                    "type": "boolean",
                    "default": true,
                    "description": "Whether the workflow is active"
                  },
                  "startHour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "default": 9,
                    "description": "Start hour (0-23) for backward compatibility"
                  },
                  "endHour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "default": 17,
                    "description": "End hour (0-23) for backward compatibility"
                  },
                  "timezone": {
                    "type": "string",
                    "default": "America/Los_Angeles",
                    "description": "Timezone for workflow execution and schedule interpretation"
                  },
                  "workflowSchedule": {
                    "$ref": "#/components/schemas/WorkflowSchedule"
                  },
                  "tcpaSchedule": {
                    "$ref": "#/components/schemas/TcpaSchedule"
                  },
                  "definition": {
                    "type": "object",
                    "properties": {
                      "steps": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ],
                              "description": "Type of workflow step"
                            },
                            "order": {
                              "type": "integer",
                              "minimum": 1,
                              "description": "Order of execution (1-indexed)"
                            },
                            "delayInSecs": {
                              "type": "integer",
                              "minimum": 0,
                              "default": 0,
                              "description": "Delay in seconds before executing this step"
                            },
                            "finishOn": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "COULD_NOT_CONNECT",
                                  "NO_ANSWER",
                                  "LEFT_VOICEMAIL",
                                  "VOICEMAIL_DETECTED",
                                  "SILENCE_TIMEOUT",
                                  "BAD_NUMBER",
                                  "NOT_INTERESTED",
                                  "WARM_TRANSFER",
                                  "WARM_TRANSFER_FAILED",
                                  "CALENDLY",
                                  "DNC",
                                  "ENDED",
                                  "FRAUD",
                                  "LINE_BUSY",
                                  "TEXT_CONSENT",
                                  "CALL_AGAIN"
                                ]
                              },
                              "default": [],
                              "description": "Call end reasons that should finish the workflow"
                            },
                            "agentId": {
                              "type": "string",
                              "format": "uuid",
                              "description": "Agent to use for this step"
                            },
                            "leaveVoicemail": {
                              "type": "boolean",
                              "default": false,
                              "description": "Whether to leave voicemail for call steps"
                            },
                            "initialMessage": {
                              "type": "string",
                              "maxLength": 1600,
                              "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                            },
                            "count": {
                              "type": "integer",
                              "minimum": 1,
                              "default": 1,
                              "description": "Number of times to repeat this step before moving to next"
                            }
                          },
                          "required": [
                            "type",
                            "order",
                            "agentId"
                          ]
                        },
                        "minItems": 1,
                        "description": "Workflow steps"
                      },
                      "isInfinite": {
                        "type": "boolean",
                        "default": false,
                        "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                      }
                    },
                    "required": [
                      "steps"
                    ],
                    "description": "Workflow definition"
                  },
                  "maxDialsPerTick": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1,
                    "description": "Per-workflow max dials per scheduler tick. null = uncapped (uses shared org budget)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent workflow updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Workflow ID"
                    },
                    "name": {
                      "type": "string",
                      "description": "Workflow name"
                    },
                    "description": {
                      "type": "string",
                      "nullable": true,
                      "description": "Workflow description"
                    },
                    "organizationId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Organization ID"
                    },
                    "userId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "User ID who created the workflow"
                    },
                    "active": {
                      "type": "boolean",
                      "description": "Whether the workflow is active"
                    },
                    "startHour": {
                      "type": "integer",
                      "description": "Start hour (0-23) for backward compatibility"
                    },
                    "endHour": {
                      "type": "integer",
                      "description": "End hour (0-23) for backward compatibility"
                    },
                    "timezone": {
                      "type": "string",
                      "description": "Timezone for workflow execution and schedule interpretation"
                    },
                    "workflowSchedule": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "monday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "tuesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "wednesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "thursday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "friday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "saturday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "sunday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "globalTimeRanges": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "startHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "Start hour (0-23)",
                                "example": 9
                              },
                              "startMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "Start minute (0-59)",
                                "example": 0
                              },
                              "endHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "End hour (0-23)",
                                "example": 17
                              },
                              "endMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "End minute (0-59)",
                                "example": 0
                              }
                            },
                            "required": [
                              "startHour",
                              "startMinute",
                              "endHour",
                              "endMinute"
                            ],
                            "description": "Time range for a day using separate hour/minute numbers",
                            "example": {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          },
                          "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                        },
                        "exceptions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "date": {
                                "type": "string",
                                "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                                "description": "Date in YYYY-MM-DD format",
                                "example": "2024-12-25"
                              },
                              "enabled": {
                                "type": "boolean",
                                "description": "Whether calls are allowed on this date"
                              },
                              "timeRanges": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "startHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "Start hour (0-23)",
                                      "example": 9
                                    },
                                    "startMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "Start minute (0-59)",
                                      "example": 0
                                    },
                                    "endHour": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 23,
                                      "description": "End hour (0-23)",
                                      "example": 17
                                    },
                                    "endMinute": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 59,
                                      "description": "End minute (0-59)",
                                      "example": 0
                                    }
                                  },
                                  "required": [
                                    "startHour",
                                    "startMinute",
                                    "endHour",
                                    "endMinute"
                                  ],
                                  "description": "Time range for a day using separate hour/minute numbers",
                                  "example": {
                                    "startHour": 9,
                                    "startMinute": 0,
                                    "endHour": 17,
                                    "endMinute": 0
                                  }
                                },
                                "description": "Custom time ranges for this exception date"
                              },
                              "reason": {
                                "type": "string",
                                "description": "Reason for the exception (e.g., \"Christmas Day\")"
                              }
                            },
                            "required": [
                              "date",
                              "enabled"
                            ]
                          },
                          "default": [],
                          "description": "Exception dates (holidays, special events, etc.)"
                        }
                      },
                      "description": "Workflow schedule - operates in workflow timezone",
                      "example": {
                        "monday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "tuesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "wednesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "thursday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "friday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          ]
                        },
                        "saturday": {
                          "enabled": false,
                          "timeRanges": []
                        },
                        "sunday": {
                          "enabled": false,
                          "timeRanges": []
                        }
                      }
                    },
                    "tcpaSchedule": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "monday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "tuesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "wednesday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "thursday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "friday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "saturday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "sunday": {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true,
                              "description": "Whether this day is enabled"
                            },
                            "timeRanges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "startHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "Start hour (0-23)",
                                    "example": 9
                                  },
                                  "startMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "Start minute (0-59)",
                                    "example": 0
                                  },
                                  "endHour": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 23,
                                    "description": "End hour (0-23)",
                                    "example": 17
                                  },
                                  "endMinute": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 59,
                                    "description": "End minute (0-59)",
                                    "example": 0
                                  }
                                },
                                "required": [
                                  "startHour",
                                  "startMinute",
                                  "endHour",
                                  "endMinute"
                                ],
                                "description": "Time range for a day using separate hour/minute numbers",
                                "example": {
                                  "startHour": 9,
                                  "startMinute": 0,
                                  "endHour": 17,
                                  "endMinute": 0
                                }
                              },
                              "minItems": 0,
                              "default": [],
                              "description": "Time ranges when calls are allowed on this day"
                            }
                          },
                          "description": "Schedule configuration for a specific day"
                        },
                        "globalTimeRanges": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "startHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "Start hour (0-23)",
                                "example": 9
                              },
                              "startMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "Start minute (0-59)",
                                "example": 0
                              },
                              "endHour": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 23,
                                "description": "End hour (0-23)",
                                "example": 17
                              },
                              "endMinute": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 59,
                                "description": "End minute (0-59)",
                                "example": 0
                              }
                            },
                            "required": [
                              "startHour",
                              "startMinute",
                              "endHour",
                              "endMinute"
                            ],
                            "description": "Time range for a day using separate hour/minute numbers",
                            "example": {
                              "startHour": 9,
                              "startMinute": 0,
                              "endHour": 17,
                              "endMinute": 0
                            }
                          },
                          "description": "Global time ranges that apply to all enabled days if day-specific ranges are not set"
                        },
                        "stateOverrides": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "monday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "tuesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "wednesday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "thursday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "friday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "saturday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              },
                              "sunday": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean",
                                    "default": true,
                                    "description": "Whether this day is enabled"
                                  },
                                  "timeRanges": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "startHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "Start hour (0-23)",
                                          "example": 9
                                        },
                                        "startMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "Start minute (0-59)",
                                          "example": 0
                                        },
                                        "endHour": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 23,
                                          "description": "End hour (0-23)",
                                          "example": 17
                                        },
                                        "endMinute": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 59,
                                          "description": "End minute (0-59)",
                                          "example": 0
                                        }
                                      },
                                      "required": [
                                        "startHour",
                                        "startMinute",
                                        "endHour",
                                        "endMinute"
                                      ],
                                      "description": "Time range for a day using separate hour/minute numbers",
                                      "example": {
                                        "startHour": 9,
                                        "startMinute": 0,
                                        "endHour": 17,
                                        "endMinute": 0
                                      }
                                    },
                                    "minItems": 0,
                                    "default": [],
                                    "description": "Time ranges when calls are allowed on this day"
                                  }
                                },
                                "description": "Schedule configuration for a specific day"
                              }
                            }
                          },
                          "description": "State-specific TCPA schedule overrides (e.g., different rules for CA, NY)"
                        }
                      },
                      "description": "TCPA schedule - applies to borrower local timezone",
                      "example": {
                        "monday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "tuesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "wednesday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "thursday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "friday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "saturday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 8,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        },
                        "sunday": {
                          "enabled": true,
                          "timeRanges": [
                            {
                              "startHour": 13,
                              "startMinute": 0,
                              "endHour": 21,
                              "endMinute": 0
                            }
                          ]
                        }
                      }
                    },
                    "definition": {
                      "type": "object",
                      "properties": {
                        "steps": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ],
                                "description": "Type of workflow step"
                              },
                              "order": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Order of execution (1-indexed)"
                              },
                              "delayInSecs": {
                                "type": "integer",
                                "minimum": 0,
                                "default": 0,
                                "description": "Delay in seconds before executing this step"
                              },
                              "finishOn": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "COULD_NOT_CONNECT",
                                    "NO_ANSWER",
                                    "LEFT_VOICEMAIL",
                                    "VOICEMAIL_DETECTED",
                                    "SILENCE_TIMEOUT",
                                    "BAD_NUMBER",
                                    "NOT_INTERESTED",
                                    "WARM_TRANSFER",
                                    "WARM_TRANSFER_FAILED",
                                    "CALENDLY",
                                    "DNC",
                                    "ENDED",
                                    "FRAUD",
                                    "LINE_BUSY",
                                    "TEXT_CONSENT",
                                    "CALL_AGAIN"
                                  ]
                                },
                                "default": [],
                                "description": "Call end reasons that should finish the workflow"
                              },
                              "agentId": {
                                "type": "string",
                                "format": "uuid",
                                "description": "Agent to use for this step"
                              },
                              "leaveVoicemail": {
                                "type": "boolean",
                                "default": false,
                                "description": "Whether to leave voicemail for call steps"
                              },
                              "initialMessage": {
                                "type": "string",
                                "maxLength": 1600,
                                "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                              },
                              "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 1,
                                "description": "Number of times to repeat this step before moving to next"
                              }
                            },
                            "required": [
                              "type",
                              "order",
                              "agentId"
                            ]
                          },
                          "minItems": 1,
                          "description": "Workflow steps"
                        },
                        "isInfinite": {
                          "type": "boolean",
                          "default": false,
                          "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                        }
                      },
                      "required": [
                        "steps"
                      ],
                      "description": "Workflow definition"
                    },
                    "maxDialsPerTick": {
                      "type": "integer",
                      "nullable": true,
                      "minimum": 1,
                      "description": "Per-workflow max dials per scheduler tick. null = uncapped (uses shared org budget)."
                    },
                    "createdAt": {
                      "type": "string",
                      "description": "Creation timestamp"
                    },
                    "updatedAt": {
                      "type": "string",
                      "description": "Last update timestamp"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "description",
                    "organizationId",
                    "userId",
                    "active",
                    "startHour",
                    "endHour",
                    "timezone",
                    "workflowSchedule",
                    "tcpaSchedule",
                    "definition",
                    "maxDialsPerTick",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Workflows"
        ],
        "summary": "Delete agent workflow",
        "description": "Delete an agent workflow",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "description": "Success message"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/execution": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Create workflow execution",
        "description": "Create a new agent workflow execution",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerLeadId": {
                    "type": "string",
                    "description": "Customer lead identifier"
                  },
                  "primaryPhone": {
                    "type": "string",
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                  },
                  "zipcode": {
                    "type": "string",
                    "nullable": true,
                    "pattern": "^\\d{5}(-?\\d{4})?$"
                  },
                  "state": {
                    "type": "string",
                    "nullable": true
                  },
                  "forwardingPhoneNumber": {
                    "type": "string",
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "Variables for the execution"
                  },
                  "metadata": {
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "firstName": {
                            "type": "string"
                          },
                          "lastName": {
                            "type": "string"
                          }
                        }
                      },
                      {
                        "type": "object",
                        "additionalProperties": {
                          "nullable": true
                        }
                      }
                    ],
                    "description": "Additional metadata for the execution"
                  },
                  "priorityDate": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Lead priority date (ISO 8601). Later/newer dates = higher priority. Defaults to creation time.",
                    "example": "2025-01-15T00:00:00Z"
                  },
                  "startAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Deferred execution start time (ISO 8601 with timezone). The first workflow step delay is applied after this time.",
                    "example": "2025-01-15T15:30:00Z"
                  },
                  "attempt": {
                    "type": "integer",
                    "minimum": 0,
                    "default": 0,
                    "description": "Starting step index for the execution (0-indexed). Must be less than the total number of steps in the workflow.",
                    "example": 0
                  }
                },
                "required": [
                  "customerLeadId",
                  "primaryPhone"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Agent workflow execution created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Execution ID"
                    },
                    "workflowId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Workflow ID"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "CREATED",
                        "RUNNING",
                        "COMPLETED",
                        "FAILED",
                        "CANCELLED",
                        "PAUSED"
                      ],
                      "description": "Execution status"
                    },
                    "startedAt": {
                      "type": "string",
                      "description": "Execution start timestamp"
                    },
                    "completedAt": {
                      "type": "string",
                      "nullable": true,
                      "description": "Execution completion timestamp"
                    },
                    "customerLeadId": {
                      "type": "string",
                      "nullable": true,
                      "description": "Customer lead identifier"
                    },
                    "primaryPhone": {
                      "type": "string",
                      "nullable": true,
                      "description": "Primary phone number"
                    },
                    "metadata": {
                      "anyOf": [
                        {
                          "allOf": [
                            {
                              "type": "object",
                              "properties": {
                                "firstName": {
                                  "type": "string"
                                },
                                "lastName": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "object",
                              "additionalProperties": {
                                "nullable": true
                              }
                            }
                          ]
                        },
                        {
                          "nullable": true
                        }
                      ],
                      "description": "Execution metadata"
                    },
                    "variables": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "Variables for the execution"
                    },
                    "disposition": {
                      "type": "string",
                      "nullable": true,
                      "enum": [
                        "COULD_NOT_CONNECT",
                        "NO_ANSWER",
                        "LEFT_VOICEMAIL",
                        "VOICEMAIL_DETECTED",
                        "SILENCE_TIMEOUT",
                        "BAD_NUMBER",
                        "NOT_INTERESTED",
                        "WARM_TRANSFER",
                        "WARM_TRANSFER_FAILED",
                        "CALENDLY",
                        "DNC",
                        "ENDED",
                        "FRAUD",
                        "LINE_BUSY",
                        "TEXT_CONSENT",
                        "CALL_AGAIN"
                      ],
                      "description": "Final execution disposition"
                    },
                    "definition": {
                      "type": "object",
                      "properties": {
                        "steps": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ],
                                "description": "Type of workflow step"
                              },
                              "order": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Order of execution (1-indexed)"
                              },
                              "delayInSecs": {
                                "type": "integer",
                                "minimum": 0,
                                "default": 0,
                                "description": "Delay in seconds before executing this step"
                              },
                              "finishOn": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "COULD_NOT_CONNECT",
                                    "NO_ANSWER",
                                    "LEFT_VOICEMAIL",
                                    "VOICEMAIL_DETECTED",
                                    "SILENCE_TIMEOUT",
                                    "BAD_NUMBER",
                                    "NOT_INTERESTED",
                                    "WARM_TRANSFER",
                                    "WARM_TRANSFER_FAILED",
                                    "CALENDLY",
                                    "DNC",
                                    "ENDED",
                                    "FRAUD",
                                    "LINE_BUSY",
                                    "TEXT_CONSENT",
                                    "CALL_AGAIN"
                                  ]
                                },
                                "default": [],
                                "description": "Call end reasons that should finish the workflow"
                              },
                              "agentId": {
                                "type": "string",
                                "format": "uuid",
                                "description": "Agent to use for this step"
                              },
                              "leaveVoicemail": {
                                "type": "boolean",
                                "default": false,
                                "description": "Whether to leave voicemail for call steps"
                              },
                              "initialMessage": {
                                "type": "string",
                                "maxLength": 1600,
                                "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                              },
                              "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 1,
                                "description": "Number of times to repeat this step before moving to next"
                              }
                            },
                            "required": [
                              "type",
                              "order",
                              "agentId"
                            ]
                          },
                          "minItems": 1,
                          "description": "Workflow steps"
                        },
                        "isInfinite": {
                          "type": "boolean",
                          "default": false,
                          "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                        }
                      },
                      "required": [
                        "steps"
                      ],
                      "description": "Workflow definition snapshot"
                    },
                    "stepExecutions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Step execution ID"
                          },
                          "workflowExecutionId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Workflow execution ID"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "IN_PROGRESS",
                              "COMPLETED",
                              "FAILED",
                              "SKIPPED",
                              "CANCELLED"
                            ],
                            "description": "Step status"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "CALL",
                              "TEXT"
                            ],
                            "description": "Step type"
                          },
                          "order": {
                            "type": "integer",
                            "description": "Step order"
                          },
                          "delayInSecs": {
                            "type": "integer",
                            "description": "Delay in seconds"
                          },
                          "finishOn": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "enum": [
                                "COULD_NOT_CONNECT",
                                "NO_ANSWER",
                                "LEFT_VOICEMAIL",
                                "VOICEMAIL_DETECTED",
                                "SILENCE_TIMEOUT",
                                "BAD_NUMBER",
                                "NOT_INTERESTED",
                                "WARM_TRANSFER",
                                "WARM_TRANSFER_FAILED",
                                "CALENDLY",
                                "DNC",
                                "ENDED",
                                "FRAUD",
                                "LINE_BUSY",
                                "TEXT_CONSENT",
                                "CALL_AGAIN"
                              ]
                            },
                            "description": "Workflow finish conditions"
                          },
                          "startedAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Step start timestamp"
                          },
                          "completedAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Step completion timestamp"
                          },
                          "leaveVoicemail": {
                            "type": "boolean",
                            "description": "Whether to leave voicemail"
                          },
                          "disposition": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "COULD_NOT_CONNECT",
                              "NO_ANSWER",
                              "LEFT_VOICEMAIL",
                              "VOICEMAIL_DETECTED",
                              "SILENCE_TIMEOUT",
                              "BAD_NUMBER",
                              "NOT_INTERESTED",
                              "WARM_TRANSFER",
                              "WARM_TRANSFER_FAILED",
                              "CALENDLY",
                              "DNC",
                              "ENDED",
                              "FRAUD",
                              "LINE_BUSY",
                              "TEXT_CONSENT",
                              "CALL_AGAIN"
                            ],
                            "description": "Step disposition"
                          },
                          "agentId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Agent ID"
                          },
                          "agentCall": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "status": {
                                "type": "string"
                              },
                              "callStartedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "callEndedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "callDuration": {
                                "type": "integer"
                              },
                              "callEndedReason": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "COULD_NOT_CONNECT",
                                  "NO_ANSWER",
                                  "LEFT_VOICEMAIL",
                                  "VOICEMAIL_DETECTED",
                                  "SILENCE_TIMEOUT",
                                  "BAD_NUMBER",
                                  "NOT_INTERESTED",
                                  "WARM_TRANSFER",
                                  "WARM_TRANSFER_FAILED",
                                  "CALENDLY",
                                  "DNC",
                                  "ENDED",
                                  "FRAUD",
                                  "LINE_BUSY",
                                  "TEXT_CONSENT",
                                  "CALL_AGAIN"
                                ]
                              },
                              "recordingUrl": {
                                "type": "string",
                                "nullable": true
                              },
                              "supervisorRecordingUrl": {
                                "type": "string",
                                "nullable": true
                              },
                              "summary": {
                                "type": "string",
                                "nullable": true
                              }
                            },
                            "required": [
                              "id",
                              "status",
                              "callStartedAt",
                              "callEndedAt",
                              "callDuration",
                              "callEndedReason",
                              "recordingUrl",
                              "supervisorRecordingUrl",
                              "summary"
                            ],
                            "description": "Associated agent call details"
                          }
                        },
                        "required": [
                          "id",
                          "workflowExecutionId",
                          "status",
                          "type",
                          "order",
                          "delayInSecs",
                          "finishOn",
                          "startedAt",
                          "completedAt",
                          "leaveVoicemail",
                          "disposition",
                          "agentId",
                          "agentCall"
                        ]
                      },
                      "description": "Step executions"
                    },
                    "createdAt": {
                      "type": "string",
                      "description": "Creation timestamp"
                    },
                    "stepIndex": {
                      "type": "number",
                      "description": "Current step index being processed"
                    },
                    "nextRunAt": {
                      "type": "string",
                      "nullable": true,
                      "description": "Next scheduled run timestamp"
                    },
                    "priorityDate": {
                      "type": "string",
                      "nullable": true,
                      "description": "Lead priority date"
                    }
                  },
                  "required": [
                    "id",
                    "workflowId",
                    "status",
                    "startedAt",
                    "completedAt",
                    "customerLeadId",
                    "primaryPhone",
                    "metadata",
                    "disposition",
                    "definition",
                    "stepExecutions",
                    "createdAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Insufficient credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 402
                    },
                    "message": {
                      "type": "string",
                      "default": "Insufficient credits"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "PAYMENT_REQUIRED"
                      ],
                      "default": "PAYMENT_REQUIRED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/execution/bulk": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Bulk create workflow executions",
        "description": "Create multiple agent workflow executions at once (max 25 leads)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "leads": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "customerLeadId": {
                          "type": "string",
                          "description": "Customer lead identifier"
                        },
                        "primaryPhone": {
                          "type": "string",
                          "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                        },
                        "zipcode": {
                          "type": "string",
                          "nullable": true,
                          "pattern": "^\\d{5}(-?\\d{4})?$"
                        },
                        "state": {
                          "type": "string",
                          "nullable": true
                        },
                        "forwardingPhoneNumber": {
                          "type": "string",
                          "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                        },
                        "variables": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          },
                          "description": "Variables for the execution"
                        },
                        "metadata": {
                          "allOf": [
                            {
                              "type": "object",
                              "properties": {
                                "firstName": {
                                  "type": "string"
                                },
                                "lastName": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "object",
                              "additionalProperties": {
                                "nullable": true
                              }
                            }
                          ],
                          "description": "Additional metadata for the execution"
                        },
                        "priorityDate": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Lead priority date (ISO 8601). Later/newer dates = higher priority. Defaults to creation time.",
                          "example": "2025-01-15T00:00:00Z"
                        },
                        "startAt": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Deferred execution start time (ISO 8601 with timezone). The first workflow step delay is applied after this time.",
                          "example": "2025-01-15T15:30:00Z"
                        },
                        "attempt": {
                          "type": "integer",
                          "minimum": 0,
                          "default": 0,
                          "description": "Starting step index for the execution (0-indexed). Must be less than the total number of steps in the workflow.",
                          "example": 0
                        }
                      },
                      "required": [
                        "customerLeadId",
                        "primaryPhone"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 25,
                    "description": "Array of leads to create (max 25)"
                  }
                },
                "required": [
                  "leads"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bulk workflow execution results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer",
                      "description": "Total number of leads processed"
                    },
                    "successful": {
                      "type": "integer",
                      "description": "Number of successful leads"
                    },
                    "failed": {
                      "type": "integer",
                      "description": "Number of failed leads"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "success": {
                            "type": "boolean",
                            "description": "Whether this individual lead was successful"
                          },
                          "executionId": {
                            "type": "string",
                            "nullable": true,
                            "format": "uuid",
                            "description": "Execution ID if successful, null if failed"
                          },
                          "customerLeadId": {
                            "type": "string",
                            "description": "Customer lead identifier"
                          },
                          "error": {
                            "type": "string",
                            "nullable": true,
                            "description": "Error message if failed, null if successful"
                          }
                        },
                        "required": [
                          "success",
                          "executionId",
                          "customerLeadId",
                          "error"
                        ]
                      },
                      "description": "Individual results for each lead"
                    }
                  },
                  "required": [
                    "total",
                    "successful",
                    "failed",
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Insufficient credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 402
                    },
                    "message": {
                      "type": "string",
                      "default": "Insufficient credits"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "PAYMENT_REQUIRED"
                      ],
                      "default": "PAYMENT_REQUIRED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/execution/{executionId}": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "Get workflow execution",
        "description": "Get an agent workflow execution by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "executionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow execution retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Execution ID"
                    },
                    "workflowId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Workflow ID"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "CREATED",
                        "RUNNING",
                        "COMPLETED",
                        "FAILED",
                        "CANCELLED",
                        "PAUSED"
                      ],
                      "description": "Execution status"
                    },
                    "startedAt": {
                      "type": "string",
                      "description": "Execution start timestamp"
                    },
                    "completedAt": {
                      "type": "string",
                      "nullable": true,
                      "description": "Execution completion timestamp"
                    },
                    "customerLeadId": {
                      "type": "string",
                      "nullable": true,
                      "description": "Customer lead identifier"
                    },
                    "primaryPhone": {
                      "type": "string",
                      "nullable": true,
                      "description": "Primary phone number"
                    },
                    "metadata": {
                      "anyOf": [
                        {
                          "allOf": [
                            {
                              "type": "object",
                              "properties": {
                                "firstName": {
                                  "type": "string"
                                },
                                "lastName": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "object",
                              "additionalProperties": {
                                "nullable": true
                              }
                            }
                          ]
                        },
                        {
                          "nullable": true
                        }
                      ],
                      "description": "Execution metadata"
                    },
                    "variables": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "Variables for the execution"
                    },
                    "disposition": {
                      "type": "string",
                      "nullable": true,
                      "enum": [
                        "COULD_NOT_CONNECT",
                        "NO_ANSWER",
                        "LEFT_VOICEMAIL",
                        "VOICEMAIL_DETECTED",
                        "SILENCE_TIMEOUT",
                        "BAD_NUMBER",
                        "NOT_INTERESTED",
                        "WARM_TRANSFER",
                        "WARM_TRANSFER_FAILED",
                        "CALENDLY",
                        "DNC",
                        "ENDED",
                        "FRAUD",
                        "LINE_BUSY",
                        "TEXT_CONSENT",
                        "CALL_AGAIN"
                      ],
                      "description": "Final execution disposition"
                    },
                    "definition": {
                      "type": "object",
                      "properties": {
                        "steps": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ],
                                "description": "Type of workflow step"
                              },
                              "order": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Order of execution (1-indexed)"
                              },
                              "delayInSecs": {
                                "type": "integer",
                                "minimum": 0,
                                "default": 0,
                                "description": "Delay in seconds before executing this step"
                              },
                              "finishOn": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "COULD_NOT_CONNECT",
                                    "NO_ANSWER",
                                    "LEFT_VOICEMAIL",
                                    "VOICEMAIL_DETECTED",
                                    "SILENCE_TIMEOUT",
                                    "BAD_NUMBER",
                                    "NOT_INTERESTED",
                                    "WARM_TRANSFER",
                                    "WARM_TRANSFER_FAILED",
                                    "CALENDLY",
                                    "DNC",
                                    "ENDED",
                                    "FRAUD",
                                    "LINE_BUSY",
                                    "TEXT_CONSENT",
                                    "CALL_AGAIN"
                                  ]
                                },
                                "default": [],
                                "description": "Call end reasons that should finish the workflow"
                              },
                              "agentId": {
                                "type": "string",
                                "format": "uuid",
                                "description": "Agent to use for this step"
                              },
                              "leaveVoicemail": {
                                "type": "boolean",
                                "default": false,
                                "description": "Whether to leave voicemail for call steps"
                              },
                              "initialMessage": {
                                "type": "string",
                                "maxLength": 1600,
                                "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                              },
                              "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 1,
                                "description": "Number of times to repeat this step before moving to next"
                              }
                            },
                            "required": [
                              "type",
                              "order",
                              "agentId"
                            ]
                          },
                          "minItems": 1,
                          "description": "Workflow steps"
                        },
                        "isInfinite": {
                          "type": "boolean",
                          "default": false,
                          "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                        }
                      },
                      "required": [
                        "steps"
                      ],
                      "description": "Workflow definition snapshot"
                    },
                    "stepExecutions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Step execution ID"
                          },
                          "workflowExecutionId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Workflow execution ID"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "IN_PROGRESS",
                              "COMPLETED",
                              "FAILED",
                              "SKIPPED",
                              "CANCELLED"
                            ],
                            "description": "Step status"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "CALL",
                              "TEXT"
                            ],
                            "description": "Step type"
                          },
                          "order": {
                            "type": "integer",
                            "description": "Step order"
                          },
                          "delayInSecs": {
                            "type": "integer",
                            "description": "Delay in seconds"
                          },
                          "finishOn": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "enum": [
                                "COULD_NOT_CONNECT",
                                "NO_ANSWER",
                                "LEFT_VOICEMAIL",
                                "VOICEMAIL_DETECTED",
                                "SILENCE_TIMEOUT",
                                "BAD_NUMBER",
                                "NOT_INTERESTED",
                                "WARM_TRANSFER",
                                "WARM_TRANSFER_FAILED",
                                "CALENDLY",
                                "DNC",
                                "ENDED",
                                "FRAUD",
                                "LINE_BUSY",
                                "TEXT_CONSENT",
                                "CALL_AGAIN"
                              ]
                            },
                            "description": "Workflow finish conditions"
                          },
                          "startedAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Step start timestamp"
                          },
                          "completedAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Step completion timestamp"
                          },
                          "leaveVoicemail": {
                            "type": "boolean",
                            "description": "Whether to leave voicemail"
                          },
                          "disposition": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "COULD_NOT_CONNECT",
                              "NO_ANSWER",
                              "LEFT_VOICEMAIL",
                              "VOICEMAIL_DETECTED",
                              "SILENCE_TIMEOUT",
                              "BAD_NUMBER",
                              "NOT_INTERESTED",
                              "WARM_TRANSFER",
                              "WARM_TRANSFER_FAILED",
                              "CALENDLY",
                              "DNC",
                              "ENDED",
                              "FRAUD",
                              "LINE_BUSY",
                              "TEXT_CONSENT",
                              "CALL_AGAIN"
                            ],
                            "description": "Step disposition"
                          },
                          "agentId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Agent ID"
                          },
                          "agentCall": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "status": {
                                "type": "string"
                              },
                              "callStartedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "callEndedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "callDuration": {
                                "type": "integer"
                              },
                              "callEndedReason": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "COULD_NOT_CONNECT",
                                  "NO_ANSWER",
                                  "LEFT_VOICEMAIL",
                                  "VOICEMAIL_DETECTED",
                                  "SILENCE_TIMEOUT",
                                  "BAD_NUMBER",
                                  "NOT_INTERESTED",
                                  "WARM_TRANSFER",
                                  "WARM_TRANSFER_FAILED",
                                  "CALENDLY",
                                  "DNC",
                                  "ENDED",
                                  "FRAUD",
                                  "LINE_BUSY",
                                  "TEXT_CONSENT",
                                  "CALL_AGAIN"
                                ]
                              },
                              "recordingUrl": {
                                "type": "string",
                                "nullable": true
                              },
                              "supervisorRecordingUrl": {
                                "type": "string",
                                "nullable": true
                              },
                              "summary": {
                                "type": "string",
                                "nullable": true
                              }
                            },
                            "required": [
                              "id",
                              "status",
                              "callStartedAt",
                              "callEndedAt",
                              "callDuration",
                              "callEndedReason",
                              "recordingUrl",
                              "supervisorRecordingUrl",
                              "summary"
                            ],
                            "description": "Associated agent call details"
                          }
                        },
                        "required": [
                          "id",
                          "workflowExecutionId",
                          "status",
                          "type",
                          "order",
                          "delayInSecs",
                          "finishOn",
                          "startedAt",
                          "completedAt",
                          "leaveVoicemail",
                          "disposition",
                          "agentId",
                          "agentCall"
                        ]
                      },
                      "description": "Step executions"
                    },
                    "createdAt": {
                      "type": "string",
                      "description": "Creation timestamp"
                    },
                    "stepIndex": {
                      "type": "number",
                      "description": "Current step index being processed"
                    },
                    "nextRunAt": {
                      "type": "string",
                      "nullable": true,
                      "description": "Next scheduled run timestamp"
                    },
                    "priorityDate": {
                      "type": "string",
                      "nullable": true,
                      "description": "Lead priority date"
                    }
                  },
                  "required": [
                    "id",
                    "workflowId",
                    "status",
                    "startedAt",
                    "completedAt",
                    "customerLeadId",
                    "primaryPhone",
                    "metadata",
                    "disposition",
                    "definition",
                    "stepExecutions",
                    "createdAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Workflows"
        ],
        "summary": "Update workflow execution",
        "description": "Update an agent workflow execution",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "executionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "CREATED",
                      "RUNNING",
                      "COMPLETED",
                      "FAILED",
                      "CANCELLED",
                      "PAUSED"
                    ],
                    "description": "Execution status"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "nullable": true
                    },
                    "description": "Additional metadata for the execution"
                  },
                  "primaryPhone": {
                    "type": "string",
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$",
                    "description": "Primary phone number (E.164 format)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent workflow execution updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Execution ID"
                    },
                    "workflowId": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Workflow ID"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "CREATED",
                        "RUNNING",
                        "COMPLETED",
                        "FAILED",
                        "CANCELLED",
                        "PAUSED"
                      ],
                      "description": "Execution status"
                    },
                    "startedAt": {
                      "type": "string",
                      "description": "Execution start timestamp"
                    },
                    "completedAt": {
                      "type": "string",
                      "nullable": true,
                      "description": "Execution completion timestamp"
                    },
                    "customerLeadId": {
                      "type": "string",
                      "nullable": true,
                      "description": "Customer lead identifier"
                    },
                    "primaryPhone": {
                      "type": "string",
                      "nullable": true,
                      "description": "Primary phone number"
                    },
                    "metadata": {
                      "anyOf": [
                        {
                          "allOf": [
                            {
                              "type": "object",
                              "properties": {
                                "firstName": {
                                  "type": "string"
                                },
                                "lastName": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "object",
                              "additionalProperties": {
                                "nullable": true
                              }
                            }
                          ]
                        },
                        {
                          "nullable": true
                        }
                      ],
                      "description": "Execution metadata"
                    },
                    "variables": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "Variables for the execution"
                    },
                    "disposition": {
                      "type": "string",
                      "nullable": true,
                      "enum": [
                        "COULD_NOT_CONNECT",
                        "NO_ANSWER",
                        "LEFT_VOICEMAIL",
                        "VOICEMAIL_DETECTED",
                        "SILENCE_TIMEOUT",
                        "BAD_NUMBER",
                        "NOT_INTERESTED",
                        "WARM_TRANSFER",
                        "WARM_TRANSFER_FAILED",
                        "CALENDLY",
                        "DNC",
                        "ENDED",
                        "FRAUD",
                        "LINE_BUSY",
                        "TEXT_CONSENT",
                        "CALL_AGAIN"
                      ],
                      "description": "Final execution disposition"
                    },
                    "definition": {
                      "type": "object",
                      "properties": {
                        "steps": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ],
                                "description": "Type of workflow step"
                              },
                              "order": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Order of execution (1-indexed)"
                              },
                              "delayInSecs": {
                                "type": "integer",
                                "minimum": 0,
                                "default": 0,
                                "description": "Delay in seconds before executing this step"
                              },
                              "finishOn": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "COULD_NOT_CONNECT",
                                    "NO_ANSWER",
                                    "LEFT_VOICEMAIL",
                                    "VOICEMAIL_DETECTED",
                                    "SILENCE_TIMEOUT",
                                    "BAD_NUMBER",
                                    "NOT_INTERESTED",
                                    "WARM_TRANSFER",
                                    "WARM_TRANSFER_FAILED",
                                    "CALENDLY",
                                    "DNC",
                                    "ENDED",
                                    "FRAUD",
                                    "LINE_BUSY",
                                    "TEXT_CONSENT",
                                    "CALL_AGAIN"
                                  ]
                                },
                                "default": [],
                                "description": "Call end reasons that should finish the workflow"
                              },
                              "agentId": {
                                "type": "string",
                                "format": "uuid",
                                "description": "Agent to use for this step"
                              },
                              "leaveVoicemail": {
                                "type": "boolean",
                                "default": false,
                                "description": "Whether to leave voicemail for call steps"
                              },
                              "initialMessage": {
                                "type": "string",
                                "maxLength": 1600,
                                "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                              },
                              "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 1,
                                "description": "Number of times to repeat this step before moving to next"
                              }
                            },
                            "required": [
                              "type",
                              "order",
                              "agentId"
                            ]
                          },
                          "minItems": 1,
                          "description": "Workflow steps"
                        },
                        "isInfinite": {
                          "type": "boolean",
                          "default": false,
                          "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                        }
                      },
                      "required": [
                        "steps"
                      ],
                      "description": "Workflow definition snapshot"
                    },
                    "stepExecutions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Step execution ID"
                          },
                          "workflowExecutionId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Workflow execution ID"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "IN_PROGRESS",
                              "COMPLETED",
                              "FAILED",
                              "SKIPPED",
                              "CANCELLED"
                            ],
                            "description": "Step status"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "CALL",
                              "TEXT"
                            ],
                            "description": "Step type"
                          },
                          "order": {
                            "type": "integer",
                            "description": "Step order"
                          },
                          "delayInSecs": {
                            "type": "integer",
                            "description": "Delay in seconds"
                          },
                          "finishOn": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "enum": [
                                "COULD_NOT_CONNECT",
                                "NO_ANSWER",
                                "LEFT_VOICEMAIL",
                                "VOICEMAIL_DETECTED",
                                "SILENCE_TIMEOUT",
                                "BAD_NUMBER",
                                "NOT_INTERESTED",
                                "WARM_TRANSFER",
                                "WARM_TRANSFER_FAILED",
                                "CALENDLY",
                                "DNC",
                                "ENDED",
                                "FRAUD",
                                "LINE_BUSY",
                                "TEXT_CONSENT",
                                "CALL_AGAIN"
                              ]
                            },
                            "description": "Workflow finish conditions"
                          },
                          "startedAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Step start timestamp"
                          },
                          "completedAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Step completion timestamp"
                          },
                          "leaveVoicemail": {
                            "type": "boolean",
                            "description": "Whether to leave voicemail"
                          },
                          "disposition": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "COULD_NOT_CONNECT",
                              "NO_ANSWER",
                              "LEFT_VOICEMAIL",
                              "VOICEMAIL_DETECTED",
                              "SILENCE_TIMEOUT",
                              "BAD_NUMBER",
                              "NOT_INTERESTED",
                              "WARM_TRANSFER",
                              "WARM_TRANSFER_FAILED",
                              "CALENDLY",
                              "DNC",
                              "ENDED",
                              "FRAUD",
                              "LINE_BUSY",
                              "TEXT_CONSENT",
                              "CALL_AGAIN"
                            ],
                            "description": "Step disposition"
                          },
                          "agentId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Agent ID"
                          },
                          "agentCall": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "status": {
                                "type": "string"
                              },
                              "callStartedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "callEndedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "callDuration": {
                                "type": "integer"
                              },
                              "callEndedReason": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "COULD_NOT_CONNECT",
                                  "NO_ANSWER",
                                  "LEFT_VOICEMAIL",
                                  "VOICEMAIL_DETECTED",
                                  "SILENCE_TIMEOUT",
                                  "BAD_NUMBER",
                                  "NOT_INTERESTED",
                                  "WARM_TRANSFER",
                                  "WARM_TRANSFER_FAILED",
                                  "CALENDLY",
                                  "DNC",
                                  "ENDED",
                                  "FRAUD",
                                  "LINE_BUSY",
                                  "TEXT_CONSENT",
                                  "CALL_AGAIN"
                                ]
                              },
                              "recordingUrl": {
                                "type": "string",
                                "nullable": true
                              },
                              "supervisorRecordingUrl": {
                                "type": "string",
                                "nullable": true
                              },
                              "summary": {
                                "type": "string",
                                "nullable": true
                              }
                            },
                            "required": [
                              "id",
                              "status",
                              "callStartedAt",
                              "callEndedAt",
                              "callDuration",
                              "callEndedReason",
                              "recordingUrl",
                              "supervisorRecordingUrl",
                              "summary"
                            ],
                            "description": "Associated agent call details"
                          }
                        },
                        "required": [
                          "id",
                          "workflowExecutionId",
                          "status",
                          "type",
                          "order",
                          "delayInSecs",
                          "finishOn",
                          "startedAt",
                          "completedAt",
                          "leaveVoicemail",
                          "disposition",
                          "agentId",
                          "agentCall"
                        ]
                      },
                      "description": "Step executions"
                    },
                    "createdAt": {
                      "type": "string",
                      "description": "Creation timestamp"
                    },
                    "stepIndex": {
                      "type": "number",
                      "description": "Current step index being processed"
                    },
                    "nextRunAt": {
                      "type": "string",
                      "nullable": true,
                      "description": "Next scheduled run timestamp"
                    },
                    "priorityDate": {
                      "type": "string",
                      "nullable": true,
                      "description": "Lead priority date"
                    }
                  },
                  "required": [
                    "id",
                    "workflowId",
                    "status",
                    "startedAt",
                    "completedAt",
                    "customerLeadId",
                    "primaryPhone",
                    "metadata",
                    "disposition",
                    "definition",
                    "stepExecutions",
                    "createdAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Workflows"
        ],
        "summary": "Delete workflow execution",
        "description": "Delete an agent workflow execution",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "executionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow execution deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "description": "Success message"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/executions": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "List workflow executions",
        "description": "List agent workflow executions",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "CREATED",
                "RUNNING",
                "COMPLETED",
                "FAILED",
                "CANCELLED",
                "PAUSED"
              ],
              "description": "Filter by execution status"
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Filter by customer lead ID"
            },
            "required": false,
            "name": "customerLeadId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "false",
              "description": "Include heavy fields (metadata, definition, variables) in the response"
            },
            "required": false,
            "name": "enriched",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow executions retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "executions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Execution ID"
                          },
                          "workflowId": {
                            "type": "string",
                            "format": "uuid",
                            "description": "Workflow ID"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "CREATED",
                              "RUNNING",
                              "COMPLETED",
                              "FAILED",
                              "CANCELLED",
                              "PAUSED"
                            ],
                            "description": "Execution status"
                          },
                          "startedAt": {
                            "type": "string",
                            "description": "Execution start timestamp"
                          },
                          "completedAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Execution completion timestamp"
                          },
                          "customerLeadId": {
                            "type": "string",
                            "nullable": true,
                            "description": "Customer lead identifier"
                          },
                          "primaryPhone": {
                            "type": "string",
                            "nullable": true,
                            "description": "Primary phone number"
                          },
                          "metadata": {
                            "anyOf": [
                              {
                                "allOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "firstName": {
                                        "type": "string"
                                      },
                                      "lastName": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  {
                                    "type": "object",
                                    "additionalProperties": {
                                      "nullable": true
                                    }
                                  }
                                ]
                              },
                              {
                                "nullable": true
                              }
                            ],
                            "description": "Execution metadata (only included when enriched=true)"
                          },
                          "variables": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "string"
                            },
                            "description": "Variables for the execution"
                          },
                          "disposition": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "COULD_NOT_CONNECT",
                              "NO_ANSWER",
                              "LEFT_VOICEMAIL",
                              "VOICEMAIL_DETECTED",
                              "SILENCE_TIMEOUT",
                              "BAD_NUMBER",
                              "NOT_INTERESTED",
                              "WARM_TRANSFER",
                              "WARM_TRANSFER_FAILED",
                              "CALENDLY",
                              "DNC",
                              "ENDED",
                              "FRAUD",
                              "LINE_BUSY",
                              "TEXT_CONSENT",
                              "CALL_AGAIN"
                            ],
                            "description": "Final execution disposition"
                          },
                          "definition": {
                            "type": "object",
                            "properties": {
                              "steps": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "format": "uuid"
                                    },
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "CALL",
                                        "TEXT"
                                      ],
                                      "description": "Type of workflow step"
                                    },
                                    "order": {
                                      "type": "integer",
                                      "minimum": 1,
                                      "description": "Order of execution (1-indexed)"
                                    },
                                    "delayInSecs": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "default": 0,
                                      "description": "Delay in seconds before executing this step"
                                    },
                                    "finishOn": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "enum": [
                                          "COULD_NOT_CONNECT",
                                          "NO_ANSWER",
                                          "LEFT_VOICEMAIL",
                                          "VOICEMAIL_DETECTED",
                                          "SILENCE_TIMEOUT",
                                          "BAD_NUMBER",
                                          "NOT_INTERESTED",
                                          "WARM_TRANSFER",
                                          "WARM_TRANSFER_FAILED",
                                          "CALENDLY",
                                          "DNC",
                                          "ENDED",
                                          "FRAUD",
                                          "LINE_BUSY",
                                          "TEXT_CONSENT",
                                          "CALL_AGAIN"
                                        ]
                                      },
                                      "default": [],
                                      "description": "Call end reasons that should finish the workflow"
                                    },
                                    "agentId": {
                                      "type": "string",
                                      "format": "uuid",
                                      "description": "Agent to use for this step"
                                    },
                                    "leaveVoicemail": {
                                      "type": "boolean",
                                      "default": false,
                                      "description": "Whether to leave voicemail for call steps"
                                    },
                                    "initialMessage": {
                                      "type": "string",
                                      "maxLength": 1600,
                                      "description": "SMS message body for TEXT steps. Supports {{variableName}} interpolation."
                                    },
                                    "count": {
                                      "type": "integer",
                                      "minimum": 1,
                                      "default": 1,
                                      "description": "Number of times to repeat this step before moving to next"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "order",
                                    "agentId"
                                  ]
                                },
                                "minItems": 1,
                                "description": "Workflow steps"
                              },
                              "isInfinite": {
                                "type": "boolean",
                                "default": false,
                                "description": "If true, workflow loops indefinitely using last step config when defined steps are exhausted"
                              }
                            },
                            "required": [
                              "steps"
                            ],
                            "description": "Workflow definition snapshot (only included when enriched=true)"
                          },
                          "createdAt": {
                            "type": "string",
                            "description": "Creation timestamp"
                          },
                          "stepIndex": {
                            "type": "number",
                            "description": "Current step index being processed"
                          },
                          "nextRunAt": {
                            "type": "string",
                            "nullable": true,
                            "description": "Next scheduled run timestamp"
                          },
                          "priorityDate": {
                            "type": "string",
                            "nullable": true,
                            "description": "Lead priority date"
                          }
                        },
                        "required": [
                          "id",
                          "workflowId",
                          "status",
                          "startedAt",
                          "completedAt",
                          "customerLeadId",
                          "primaryPhone",
                          "disposition",
                          "createdAt"
                        ]
                      },
                      "description": "List of executions"
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "executions",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/executions/by-phone": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "List workflow executions by phone number",
        "description": "List all workflow executions for a given phone number within a workflow, including metadata and variables.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^\\+[1-9]\\d{1,14}$",
              "description": "Phone number in E.164 format",
              "example": "+14155551234"
            },
            "required": true,
            "name": "phoneNumber",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Base64-encoded pagination cursor"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10",
              "description": "Number of results per page (default 10, max 1000)"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Executions retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "executions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "workflowId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string"
                          },
                          "startedAt": {
                            "type": "string"
                          },
                          "completedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "customerLeadId": {
                            "type": "string",
                            "nullable": true
                          },
                          "primaryPhone": {
                            "type": "string",
                            "nullable": true
                          },
                          "disposition": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "stepIndex": {
                            "type": "number"
                          },
                          "nextRunAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "priorityDate": {
                            "type": "string",
                            "nullable": true
                          },
                          "metadata": {
                            "type": "object",
                            "nullable": true,
                            "additionalProperties": {
                              "nullable": true
                            }
                          },
                          "variables": {
                            "type": "object",
                            "nullable": true,
                            "additionalProperties": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "id",
                          "workflowId",
                          "status",
                          "startedAt",
                          "completedAt",
                          "customerLeadId",
                          "primaryPhone",
                          "disposition",
                          "createdAt",
                          "stepIndex",
                          "nextRunAt",
                          "priorityDate"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "limit"
                      ]
                    }
                  },
                  "required": [
                    "executions",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/executions/{executionId}/pause": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Pause workflow execution",
        "description": "Pause an agent workflow execution",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "executionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow execution paused successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Whether the pause operation was successful"
                    },
                    "message": {
                      "type": "string",
                      "description": "Status message"
                    }
                  },
                  "required": [
                    "success",
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/executions/{executionId}/resume": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Resume workflow execution",
        "description": "Resume an agent workflow execution",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "executionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow execution resumed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Whether the resume operation was successful"
                    },
                    "message": {
                      "type": "string",
                      "description": "Status message"
                    }
                  },
                  "required": [
                    "success",
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/executions/{executionId}/cancel": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Cancel workflow execution",
        "description": "Cancel an agent workflow execution",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "executionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow execution cancelled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/leads/{customerLeadId}/execution/cancel": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Cancel workflow execution by lead ID",
        "description": "Cancel an agent workflow execution using the customer lead ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "customerLeadId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent workflow execution cancelled successfully or already in desired state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cancelledCount": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "cancelledCount"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workflow/{workflowId}/executions/cancel": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Cancel workflow executions by phone number",
        "description": "Cancel all running agent workflow executions for a given phone number. Returns the count of cancelled executions.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "workflowId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "string",
                    "pattern": "^\\+[1-9]\\d{1,14}$",
                    "description": "Phone number in E.164 format",
                    "example": "+14155551234"
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent workflow executions cancelled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cancelledCount": {
                      "type": "number",
                      "description": "Number of executions that were cancelled"
                    }
                  },
                  "required": [
                    "cancelledCount"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/executions/cancel": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Cancel all workflow executions by phone number",
        "description": "Cancel all running agent workflow executions across all workflows for a given phone number. Returns the count of cancelled executions.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "string",
                    "pattern": "^\\+[1-9]\\d{1,14}$",
                    "description": "Phone number in E.164 format",
                    "example": "+14155551234"
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent workflow executions cancelled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cancelledCount": {
                      "type": "number",
                      "description": "Number of executions that were cancelled"
                    }
                  },
                  "required": [
                    "cancelledCount"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/organization": {
      "get": {
        "tags": [
          "Organization"
        ],
        "summary": "Get current organization",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Organization retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "organization": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string",
                          "nullable": true
                        },
                        "allowedChatDomains": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "toolFailureSlackWebhookConfigured": {
                          "type": "boolean"
                        },
                        "toolFailureSlackConnected": {
                          "type": "boolean"
                        },
                        "toolFailureSlackChannelConfigured": {
                          "type": "boolean"
                        },
                        "schedulerBatchSize": {
                          "type": "number"
                        },
                        "maxSchedulerBatchSize": {
                          "type": "number"
                        },
                        "priorityDateBucketConfig": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true
                            },
                            "buckets": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "minDays": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "maxDays": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "percentage": {
                                    "type": "number",
                                    "minimum": 0,
                                    "maximum": 100
                                  }
                                },
                                "required": [
                                  "minDays",
                                  "maxDays",
                                  "percentage"
                                ]
                              },
                              "minItems": 1,
                              "maxItems": 100
                            }
                          },
                          "required": [
                            "buckets"
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "activeCallCount": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "allowedChatDomains",
                        "toolFailureSlackWebhookConfigured",
                        "toolFailureSlackConnected",
                        "toolFailureSlackChannelConfigured",
                        "schedulerBatchSize",
                        "maxSchedulerBatchSize",
                        "priorityDateBucketConfig",
                        "createdAt",
                        "updatedAt",
                        "activeCallCount"
                      ]
                    }
                  },
                  "required": [
                    "organization"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Organization"
        ],
        "summary": "Update organization settings",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "allowedChatDomains": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^(\\*\\.)?([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)*[a-zA-Z]{2,}$|^localhost$"
                    },
                    "maxItems": 50
                  },
                  "toolFailureSlackWebhookUrl": {
                    "type": "string",
                    "nullable": true,
                    "format": "uri"
                  },
                  "schedulerBatchSize": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "priorityDateBucketConfig": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "enabled": {
                        "type": "boolean",
                        "default": true
                      },
                      "buckets": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "minDays": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "maxDays": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "percentage": {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 100
                            }
                          },
                          "required": [
                            "minDays",
                            "maxDays",
                            "percentage"
                          ]
                        },
                        "minItems": 1,
                        "maxItems": 100
                      }
                    },
                    "required": [
                      "buckets"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Organization updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "organization": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string",
                          "nullable": true
                        },
                        "allowedChatDomains": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "toolFailureSlackWebhookConfigured": {
                          "type": "boolean"
                        },
                        "toolFailureSlackConnected": {
                          "type": "boolean"
                        },
                        "toolFailureSlackChannelConfigured": {
                          "type": "boolean"
                        },
                        "schedulerBatchSize": {
                          "type": "number"
                        },
                        "maxSchedulerBatchSize": {
                          "type": "number"
                        },
                        "priorityDateBucketConfig": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "default": true
                            },
                            "buckets": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "minDays": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "maxDays": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "percentage": {
                                    "type": "number",
                                    "minimum": 0,
                                    "maximum": 100
                                  }
                                },
                                "required": [
                                  "minDays",
                                  "maxDays",
                                  "percentage"
                                ]
                              },
                              "minItems": 1,
                              "maxItems": 100
                            }
                          },
                          "required": [
                            "buckets"
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "allowedChatDomains",
                        "toolFailureSlackWebhookConfigured",
                        "toolFailureSlackConnected",
                        "toolFailureSlackChannelConfigured",
                        "schedulerBatchSize",
                        "maxSchedulerBatchSize",
                        "priorityDateBucketConfig",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "organization"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/organization/slack/connect-url": {
      "get": {
        "tags": [
          "Slack Alerts"
        ],
        "summary": "Get Slack OAuth connect URL",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Slack OAuth connect URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/slack/callback": {
      "get": {
        "tags": [
          "Slack Alerts"
        ],
        "summary": "Slack OAuth callback",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "code",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "state",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "error",
            "in": "query"
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to frontend"
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/organization/slack": {
      "get": {
        "tags": [
          "Slack Alerts"
        ],
        "summary": "Get Slack alerts connection status",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Slack connection status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "slack": {
                      "type": "object",
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "teamId": {
                          "type": "string",
                          "nullable": true
                        },
                        "teamName": {
                          "type": "string",
                          "nullable": true
                        },
                        "defaultChannelId": {
                          "type": "string",
                          "nullable": true
                        },
                        "defaultChannelName": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "connected",
                        "teamId",
                        "teamName",
                        "defaultChannelId",
                        "defaultChannelName"
                      ]
                    }
                  },
                  "required": [
                    "slack"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Slack Alerts"
        ],
        "summary": "Disconnect Slack alerts integration",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Slack disconnected",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "disconnected": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "disconnected"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/organization/slack/channels": {
      "get": {
        "tags": [
          "Slack Alerts"
        ],
        "summary": "List available Slack channels for alerting",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Slack channels",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "channels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "isPrivate": {
                            "type": "boolean"
                          },
                          "isMember": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "isPrivate",
                          "isMember"
                        ]
                      }
                    }
                  },
                  "required": [
                    "channels"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/organization/slack/channel": {
      "patch": {
        "tags": [
          "Slack Alerts"
        ],
        "summary": "Set default Slack channel for tool failure alerts",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channelId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "channelId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Slack alert channel updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "slack": {
                      "type": "object",
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "teamId": {
                          "type": "string",
                          "nullable": true
                        },
                        "teamName": {
                          "type": "string",
                          "nullable": true
                        },
                        "defaultChannelId": {
                          "type": "string",
                          "nullable": true
                        },
                        "defaultChannelName": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "connected",
                        "teamId",
                        "teamName",
                        "defaultChannelId",
                        "defaultChannelName"
                      ]
                    }
                  },
                  "required": [
                    "slack"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List all available integrations",
        "description": "List all available integrations in the platform",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of available integrations retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integrations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string",
                            "nullable": true
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "ACTIVE",
                              "INACTIVE",
                              "BETA",
                              "DEPRECATED"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "CALENDAR",
                              "HEALTHCARE"
                            ]
                          },
                          "subType": {
                            "type": "string",
                            "enum": [
                              "YCMB",
                              "MODMED",
                              "CALENDLY",
                              "FEATHER_CALENDAR"
                            ]
                          },
                          "logoUrl": {
                            "type": "string",
                            "nullable": true
                          },
                          "websiteUrl": {
                            "type": "string",
                            "nullable": true
                          },
                          "requiredConfig": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "key": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "key"
                              ]
                            },
                            "description": "The required config for the integration"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "status",
                          "type",
                          "subType",
                          "logoUrl",
                          "websiteUrl",
                          "requiredConfig",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "integrations"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/instances": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List integration instances for organization",
        "description": "List all integration instances configured for the organization",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of integration instances retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integrationInstances": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "nullable": true
                          },
                          "slug": {
                            "type": "string",
                            "nullable": true
                          },
                          "integrationId": {
                            "type": "string"
                          },
                          "integration": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "type"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "slug",
                          "integrationId",
                          "integration",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "integrationInstances"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/create": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "summary": "Create an integration instance",
        "description": "Create a new integration instance for the organization",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "integrationId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "slug": {
                    "type": "string",
                    "maxLength": 16,
                    "pattern": "^[a-z0-9_]+$"
                  },
                  "config": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "integrationId",
                  "config"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Integration instance created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integrationInstance": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string",
                          "nullable": true
                        },
                        "slug": {
                          "type": "string",
                          "nullable": true
                        },
                        "integrationId": {
                          "type": "string"
                        },
                        "integration": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "type"
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "slug",
                        "integrationId",
                        "integration",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "integrationInstance"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid input or missing required config",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Integration not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/{integrationInstanceId}": {
      "patch": {
        "tags": [
          "Integrations"
        ],
        "summary": "Update an integration instance",
        "description": "Update an integration instance for the organization",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "integrationInstanceId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "config": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Integration instance updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integrationInstance": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string",
                          "nullable": true
                        },
                        "slug": {
                          "type": "string",
                          "nullable": true
                        },
                        "integrationId": {
                          "type": "string"
                        },
                        "integration": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "type"
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "slug",
                        "integrationId",
                        "integration",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "integrationInstance"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid input or missing required config",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Integration instance not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Integrations"
        ],
        "summary": "Delete an integration instance",
        "description": "Delete an integration instance for the organization",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "integrationInstanceId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Integration instance deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "deletedIntegrationInstanceId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message",
                    "deletedIntegrationInstanceId"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Integration instance not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/prompts/personalities": {
      "get": {
        "tags": [
          "Prompts"
        ],
        "summary": "List all prompt personalities",
        "description": "List all available prompt personalities",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of prompt personalities retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "personalities": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string",
                            "nullable": true
                          },
                          "personalityPrompt": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "personalityPrompt",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "personalities"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/stt-configs": {
      "get": {
        "tags": [
          "Configuration"
        ],
        "summary": "Get STT configs",
        "description": "Get all available STT configurations",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of available STT configurations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string",
                        "nullable": true
                      },
                      "provider": {
                        "type": "string",
                        "enum": [
                          "ASSEMBLY_AI",
                          "AMAZON",
                          "GOOGLE",
                          "MICROSOFT",
                          "DEEPGRAM",
                          "OPENAI",
                          "GLADIA",
                          "SPEECH_MATICS",
                          "ELEVEN_LABS"
                        ]
                      },
                      "language": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "model": {
                        "type": "string"
                      },
                      "additionalConfig": {
                        "type": "object",
                        "nullable": true,
                        "additionalProperties": {
                          "nullable": true
                        }
                      }
                    },
                    "required": [
                      "id",
                      "name",
                      "description",
                      "provider",
                      "language",
                      "model",
                      "additionalConfig"
                    ]
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tts-configs": {
      "get": {
        "tags": [
          "Configuration"
        ],
        "summary": "Get TTS configs",
        "description": "Get all available TTS configurations",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of available TTS configurations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string",
                        "nullable": true
                      },
                      "provider": {
                        "type": "string",
                        "enum": [
                          "DEEPGRAM",
                          "CARTESIA",
                          "AMAZON",
                          "ELEVEN_LABS",
                          "PLAY_HT",
                          "RIME",
                          "OPENAI",
                          "INWORLD",
                          "SESAME"
                        ]
                      },
                      "language": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "model": {
                        "type": "string"
                      },
                      "additionalConfig": {
                        "type": "object",
                        "nullable": true,
                        "additionalProperties": {
                          "nullable": true
                        }
                      }
                    },
                    "required": [
                      "id",
                      "name",
                      "description",
                      "provider",
                      "language",
                      "model",
                      "additionalConfig"
                    ]
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/llm-configs": {
      "get": {
        "tags": [
          "Configuration"
        ],
        "summary": "Get LLM configs",
        "description": "Get all available LLM configurations",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of available LLM configurations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string",
                        "nullable": true
                      },
                      "provider": {
                        "type": "string",
                        "enum": [
                          "OPENAI",
                          "GOOGLE",
                          "AMAZON",
                          "ANTHROPIC",
                          "META"
                        ]
                      },
                      "model": {
                        "type": "string"
                      },
                      "additionalConfig": {
                        "type": "object",
                        "nullable": true,
                        "additionalProperties": {
                          "nullable": true
                        }
                      }
                    },
                    "required": [
                      "id",
                      "name",
                      "description",
                      "provider",
                      "model",
                      "additionalConfig"
                    ]
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "List all agents",
        "description": "List all agents with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of agents retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string",
                            "nullable": true
                          },
                          "agentType": {
                            "type": "string",
                            "enum": [
                              "CALL",
                              "TEXT"
                            ]
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "smsPhoneNumbers": {
                            "type": "array",
                            "nullable": true,
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "phoneNumber": {
                                  "type": "string"
                                },
                                "ownership": {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    "FEATHER",
                                    "CLIENT"
                                  ]
                                },
                                "createdAt": {
                                  "type": "string"
                                },
                                "updatedAt": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "phoneNumber",
                                "ownership",
                                "createdAt",
                                "updatedAt"
                              ]
                            }
                          },
                          "inboundPhoneNumbers": {
                            "type": "array",
                            "nullable": true,
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "phoneNumber": {
                                  "type": "string"
                                },
                                "ownership": {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    "FEATHER",
                                    "CLIENT"
                                  ]
                                },
                                "createdAt": {
                                  "type": "string"
                                },
                                "updatedAt": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "phoneNumber",
                                "ownership",
                                "createdAt",
                                "updatedAt"
                              ]
                            }
                          },
                          "outboundPhoneNumbers": {
                            "type": "array",
                            "nullable": true,
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "phoneNumber": {
                                  "type": "string"
                                },
                                "ownership": {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    "FEATHER",
                                    "CLIENT"
                                  ]
                                },
                                "createdAt": {
                                  "type": "string"
                                },
                                "updatedAt": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "phoneNumber",
                                "ownership",
                                "createdAt",
                                "updatedAt"
                              ]
                            }
                          },
                          "callObservabilityEnabled": {
                            "type": "boolean",
                            "default": false
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "agentType",
                          "createdAt",
                          "updatedAt",
                          "smsPhoneNumbers",
                          "inboundPhoneNumbers",
                          "outboundPhoneNumbers"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "agents",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Create a new agent",
        "description": "Create a new voice or text (SMS) agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "templateId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string",
                    "nullable": true
                  },
                  "agentType": {
                    "type": "string",
                    "enum": [
                      "CALL",
                      "TEXT"
                    ],
                    "default": "CALL"
                  },
                  "useKnowledgeBase": {
                    "type": "boolean",
                    "default": true
                  },
                  "prompt": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "system": {
                        "type": "string"
                      },
                      "systemUIFormatting": {
                        "nullable": true
                      },
                      "variables": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "required": {
                              "type": "boolean",
                              "default": true
                            },
                            "defaultValue": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "name"
                          ]
                        }
                      },
                      "tools": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "preBuiltTools": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": [
                      "system"
                    ]
                  },
                  "promptPersonalityId": {
                    "type": "string",
                    "nullable": true
                  },
                  "llmConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "languageId": {
                    "type": "string",
                    "nullable": true,
                    "format": "uuid"
                  },
                  "voicemailMessage": {
                    "type": "string",
                    "nullable": true
                  },
                  "sttConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "ttsConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "overrideSTTConfig": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "keywords": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "keyword": {
                              "type": "string"
                            },
                            "intensifier": {
                              "type": "string",
                              "enum": [
                                "HIGH_SUPPRESS",
                                "SUPPRESS",
                                "INTENSIFY",
                                "HIGH_INTENSIFY"
                              ],
                              "default": "INTENSIFY"
                            }
                          },
                          "required": [
                            "keyword"
                          ]
                        }
                      }
                    },
                    "required": [
                      "keywords"
                    ]
                  },
                  "voiceId": {
                    "type": "string",
                    "nullable": true
                  },
                  "enableBackgroundAudio": {
                    "type": "boolean",
                    "default": false
                  },
                  "backgroundAudio": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 100,
                    "exclusiveMaximum": true,
                    "default": 50
                  },
                  "voiceVolume": {
                    "type": "integer",
                    "minimum": 10,
                    "maximum": 120,
                    "default": 100
                  },
                  "voiceSpeed": {
                    "type": "number",
                    "minimum": 0.8,
                    "maximum": 1.2,
                    "default": 1
                  },
                  "agentDelayBeforeFirstMessage": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 2500,
                    "default": 500
                  },
                  "initialSilenceTimeout": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 60000,
                    "default": 30000
                  },
                  "finalSilenceTimeout": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 60000,
                    "default": 10000
                  },
                  "transferImmediatelyOnInbound": {
                    "type": "boolean",
                    "default": false
                  },
                  "maxCallDuration": {
                    "type": "integer",
                    "minimum": 300,
                    "maximum": 6000,
                    "default": 900
                  },
                  "voicemailDetectionMode": {
                    "type": "string",
                    "enum": [
                      "ASYNC",
                      "SYNC"
                    ],
                    "default": "ASYNC"
                  },
                  "minInterruptionWords": {
                    "type": "integer",
                    "minimum": 0,
                    "default": 1
                  },
                  "minInterruptionDuration": {
                    "type": "number",
                    "minimum": 0,
                    "default": 1
                  },
                  "minEndpointingDelay": {
                    "type": "number",
                    "minimum": 0,
                    "default": 0.5
                  },
                  "maxEndpointingDelay": {
                    "type": "number",
                    "minimum": 0,
                    "default": 3
                  },
                  "vadActivationThreshold": {
                    "type": "number",
                    "minimum": 0.1,
                    "maximum": 0.9,
                    "default": 0.5
                  },
                  "sms": {
                    "type": "object",
                    "properties": {
                      "inactivityTimeoutHours": {
                        "type": "integer",
                        "nullable": true,
                        "minimum": 1
                      },
                      "smsMaxTokens": {
                        "type": "integer",
                        "minimum": 100,
                        "maximum": 2000,
                        "default": 500
                      },
                      "smsTemperature": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 2,
                        "default": 0.7
                      },
                      "discardInboundSms": {
                        "type": "boolean",
                        "default": false
                      }
                    }
                  },
                  "webChatAggregationWindowSeconds": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1,
                    "maximum": 115
                  },
                  "emailDomainId": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailFromLocalPart": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailFromName": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailMaxTokens": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 100,
                    "maximum": 10000
                  },
                  "emailTemperature": {
                    "type": "number",
                    "nullable": true,
                    "minimum": 0,
                    "maximum": 2
                  },
                  "emailInactivityTimeoutHours": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1
                  },
                  "warmTransferMessageMode": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      "STATIC",
                      "PROMPT"
                    ]
                  },
                  "warmTransferBriefingTemplate": {
                    "type": "string",
                    "nullable": true
                  },
                  "warmTransferInteractive": {
                    "type": "boolean"
                  },
                  "warmTransferInstructions": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "name",
                  "description",
                  "voicemailMessage",
                  "overrideSTTConfig"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Agent created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "agentType": {
                          "type": "string",
                          "enum": [
                            "CALL",
                            "TEXT"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "smsPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "inboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "outboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "callObservabilityEnabled": {
                          "type": "boolean",
                          "default": false
                        },
                        "version": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "version": {
                              "type": "number"
                            },
                            "name": {
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updatedAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "FLOW",
                                "PROMPT"
                              ]
                            },
                            "prompt": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "system": {
                                  "type": "string"
                                },
                                "systemUIFormatting": {
                                  "nullable": true
                                },
                                "variables": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "required": {
                                        "type": "boolean",
                                        "default": true
                                      },
                                      "defaultValue": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "name"
                                    ]
                                  }
                                },
                                "tools": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "preBuiltTools": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "system"
                              ]
                            },
                            "promptPersonalityId": {
                              "type": "string",
                              "nullable": true
                            },
                            "sttConfigId": {
                              "type": "string",
                              "nullable": true
                            },
                            "ttsConfigId": {
                              "type": "string",
                              "nullable": true
                            },
                            "llmConfigId": {
                              "type": "string",
                              "nullable": true
                            },
                            "overrideSTTConfig": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "keywords": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "keyword": {
                                        "type": "string"
                                      },
                                      "intensifier": {
                                        "type": "string",
                                        "enum": [
                                          "HIGH_SUPPRESS",
                                          "SUPPRESS",
                                          "INTENSIFY",
                                          "HIGH_INTENSIFY"
                                        ],
                                        "default": "INTENSIFY"
                                      }
                                    },
                                    "required": [
                                      "keyword"
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "keywords"
                              ]
                            },
                            "overrideTTSConfig": {
                              "$ref": "#/components/schemas/OverrideTTSConfig"
                            },
                            "overrideLLMConfig": {
                              "type": "object",
                              "nullable": true,
                              "additionalProperties": {
                                "nullable": true
                              }
                            },
                            "voiceId": {
                              "type": "string",
                              "nullable": true
                            },
                            "postCallPrompt": {
                              "type": "string",
                              "nullable": true
                            },
                            "postCallVariables": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "$ref": "#/components/schemas/PostCallVariable"
                              }
                            },
                            "knowledgeBaseCollectionIds": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "string"
                              }
                            },
                            "voicemailMessage": {
                              "type": "string",
                              "nullable": true
                            },
                            "voicemailDetectionMode": {
                              "type": "string",
                              "enum": [
                                "ASYNC",
                                "SYNC"
                              ],
                              "default": "ASYNC"
                            },
                            "speakFirst": {
                              "type": "boolean",
                              "default": false
                            },
                            "firstMessage": {
                              "type": "string",
                              "nullable": true
                            },
                            "useKnowledgeBase": {
                              "type": "boolean",
                              "default": true
                            },
                            "enableBackgroundAudio": {
                              "type": "boolean",
                              "default": false
                            },
                            "backgroundAudio": {
                              "type": "number",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 100,
                              "exclusiveMaximum": true,
                              "default": 50
                            },
                            "voiceVolume": {
                              "type": "integer",
                              "minimum": 10,
                              "maximum": 120,
                              "default": 100
                            },
                            "forwardingPhoneNumber": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                            },
                            "warmTransferMessageMode": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "STATIC",
                                "PROMPT"
                              ]
                            },
                            "warmTransferBriefingTemplate": {
                              "type": "string",
                              "nullable": true
                            },
                            "warmTransferInteractive": {
                              "type": "boolean",
                              "default": false
                            },
                            "warmTransferInstructions": {
                              "type": "string",
                              "nullable": true
                            },
                            "voiceSpeed": {
                              "type": "number",
                              "nullable": true,
                              "minimum": 0.8,
                              "maximum": 1.2,
                              "default": 1
                            },
                            "agentDelayBeforeFirstMessage": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 2500,
                              "default": 500
                            },
                            "initialSilenceTimeout": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 60000,
                              "default": 30000
                            },
                            "finalSilenceTimeout": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 60000,
                              "default": 10000
                            },
                            "maxCallDuration": {
                              "type": "integer",
                              "minimum": 300,
                              "maximum": 6000,
                              "default": 900
                            },
                            "minInterruptionWords": {
                              "type": "integer",
                              "minimum": 0,
                              "default": 1
                            },
                            "minInterruptionDuration": {
                              "type": "number",
                              "minimum": 0,
                              "default": 1
                            },
                            "minEndpointingDelay": {
                              "type": "number",
                              "minimum": 0,
                              "default": 0.5
                            },
                            "maxEndpointingDelay": {
                              "type": "number",
                              "minimum": 0,
                              "default": 3
                            },
                            "vadActivationThreshold": {
                              "type": "number",
                              "minimum": 0.1,
                              "maximum": 0.9,
                              "default": 0.5
                            },
                            "language": {
                              "type": "object",
                              "properties": {
                                "languageId": {
                                  "type": "string"
                                },
                                "languageCode": {
                                  "type": "string",
                                  "enum": [
                                    "EN",
                                    "EN_US",
                                    "EN_AU",
                                    "EN_GB",
                                    "EN_IN",
                                    "EN_NZ",
                                    "HI",
                                    "DE",
                                    "FR",
                                    "ES",
                                    "JA",
                                    "PT_BR"
                                  ]
                                },
                                "languageDisplayName": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "languageId",
                                "languageCode",
                                "languageDisplayName"
                              ]
                            },
                            "transferImmediatelyOnInbound": {
                              "type": "boolean",
                              "default": false
                            },
                            "inactivityTimeoutHours": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 1
                            },
                            "smsMaxTokens": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 100,
                              "maximum": 2000
                            },
                            "smsTemperature": {
                              "type": "number",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 2
                            },
                            "discardInboundSms": {
                              "type": "boolean",
                              "default": false
                            },
                            "webChatAggregationWindowSeconds": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 1,
                              "maximum": 115
                            },
                            "emailDomainId": {
                              "type": "string",
                              "nullable": true
                            },
                            "emailFromLocalPart": {
                              "type": "string",
                              "nullable": true
                            },
                            "emailFromName": {
                              "type": "string",
                              "nullable": true
                            },
                            "emailMaxTokens": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 100,
                              "maximum": 10000
                            },
                            "emailTemperature": {
                              "type": "number",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 2
                            },
                            "emailInactivityTimeoutHours": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 1
                            },
                            "emailFilteringEnabled": {
                              "type": "boolean",
                              "default": false
                            },
                            "emailResponseMode": {
                              "type": "string",
                              "enum": [
                                "AUTO_SEND",
                                "SUGGEST_ONLY",
                                "CONFIDENCE_BASED"
                              ],
                              "default": "AUTO_SEND"
                            },
                            "emailConfidenceThreshold": {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1,
                              "default": 0.8
                            },
                            "emailTags": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "autoClose": {
                                    "type": "boolean"
                                  },
                                  "gmailLabelId": {
                                    "type": "string"
                                  },
                                  "gmailLabelName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "name",
                                  "prompt",
                                  "autoClose"
                                ]
                              }
                            },
                            "sentimentAnalysis": {
                              "type": "boolean",
                              "default": false
                            },
                            "preCallWebhook": {
                              "$ref": "#/components/schemas/PreCallWebhook"
                            }
                          },
                          "required": [
                            "id",
                            "version",
                            "name",
                            "createdAt",
                            "updatedAt",
                            "mode",
                            "promptPersonalityId",
                            "sttConfigId",
                            "ttsConfigId",
                            "llmConfigId",
                            "overrideSTTConfig",
                            "overrideTTSConfig",
                            "overrideLLMConfig",
                            "voiceId",
                            "postCallPrompt",
                            "postCallVariables",
                            "knowledgeBaseCollectionIds",
                            "voicemailMessage",
                            "firstMessage",
                            "forwardingPhoneNumber",
                            "warmTransferMessageMode",
                            "warmTransferBriefingTemplate",
                            "warmTransferInstructions",
                            "inactivityTimeoutHours",
                            "smsMaxTokens",
                            "smsTemperature",
                            "webChatAggregationWindowSeconds"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "agentType",
                        "createdAt",
                        "updatedAt",
                        "smsPhoneNumbers",
                        "inboundPhoneNumbers",
                        "outboundPhoneNumbers",
                        "version"
                      ]
                    }
                  },
                  "required": [
                    "agent"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{agentId}/versions": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "List agent versions",
        "description": "List all versions of an agent with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of agent versions retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "agentType": {
                          "type": "string",
                          "enum": [
                            "CALL",
                            "TEXT"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "smsPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "inboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "outboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "callObservabilityEnabled": {
                          "type": "boolean",
                          "default": false
                        },
                        "versions": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "version": {
                                "type": "number"
                              },
                              "name": {
                                "type": "string"
                              },
                              "createdAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "updatedAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "mode": {
                                "type": "string",
                                "enum": [
                                  "FLOW",
                                  "PROMPT"
                                ]
                              },
                              "prompt": {
                                "type": "object",
                                "nullable": true,
                                "properties": {
                                  "system": {
                                    "type": "string"
                                  },
                                  "systemUIFormatting": {
                                    "nullable": true
                                  },
                                  "variables": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "required": {
                                          "type": "boolean",
                                          "default": true
                                        },
                                        "defaultValue": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "name"
                                      ]
                                    }
                                  },
                                  "tools": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "preBuiltTools": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "required": [
                                  "system"
                                ]
                              },
                              "promptPersonalityId": {
                                "type": "string",
                                "nullable": true
                              },
                              "sttConfigId": {
                                "type": "string",
                                "nullable": true
                              },
                              "ttsConfigId": {
                                "type": "string",
                                "nullable": true
                              },
                              "llmConfigId": {
                                "type": "string",
                                "nullable": true
                              },
                              "overrideSTTConfig": {
                                "type": "object",
                                "nullable": true,
                                "properties": {
                                  "keywords": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "keyword": {
                                          "type": "string"
                                        },
                                        "intensifier": {
                                          "type": "string",
                                          "enum": [
                                            "HIGH_SUPPRESS",
                                            "SUPPRESS",
                                            "INTENSIFY",
                                            "HIGH_INTENSIFY"
                                          ],
                                          "default": "INTENSIFY"
                                        }
                                      },
                                      "required": [
                                        "keyword"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "keywords"
                                ]
                              },
                              "overrideTTSConfig": {
                                "$ref": "#/components/schemas/OverrideTTSConfig"
                              },
                              "overrideLLMConfig": {
                                "type": "object",
                                "nullable": true,
                                "additionalProperties": {
                                  "nullable": true
                                }
                              },
                              "voiceId": {
                                "type": "string",
                                "nullable": true
                              },
                              "postCallPrompt": {
                                "type": "string",
                                "nullable": true
                              },
                              "postCallVariables": {
                                "type": "array",
                                "nullable": true,
                                "items": {
                                  "$ref": "#/components/schemas/PostCallVariable"
                                }
                              },
                              "knowledgeBaseCollectionIds": {
                                "type": "array",
                                "nullable": true,
                                "items": {
                                  "type": "string"
                                }
                              },
                              "voicemailMessage": {
                                "type": "string",
                                "nullable": true
                              },
                              "voicemailDetectionMode": {
                                "type": "string",
                                "enum": [
                                  "ASYNC",
                                  "SYNC"
                                ],
                                "default": "ASYNC"
                              },
                              "speakFirst": {
                                "type": "boolean",
                                "default": false
                              },
                              "firstMessage": {
                                "type": "string",
                                "nullable": true
                              },
                              "useKnowledgeBase": {
                                "type": "boolean",
                                "default": true
                              },
                              "enableBackgroundAudio": {
                                "type": "boolean",
                                "default": false
                              },
                              "backgroundAudio": {
                                "type": "number",
                                "minimum": 0,
                                "exclusiveMinimum": true,
                                "maximum": 100,
                                "exclusiveMaximum": true,
                                "default": 50
                              },
                              "voiceVolume": {
                                "type": "integer",
                                "minimum": 10,
                                "maximum": 120,
                                "default": 100
                              },
                              "forwardingPhoneNumber": {
                                "type": "string",
                                "nullable": true,
                                "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                              },
                              "warmTransferMessageMode": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "STATIC",
                                  "PROMPT"
                                ]
                              },
                              "warmTransferBriefingTemplate": {
                                "type": "string",
                                "nullable": true
                              },
                              "warmTransferInteractive": {
                                "type": "boolean",
                                "default": false
                              },
                              "warmTransferInstructions": {
                                "type": "string",
                                "nullable": true
                              },
                              "voiceSpeed": {
                                "type": "number",
                                "nullable": true,
                                "minimum": 0.8,
                                "maximum": 1.2,
                                "default": 1
                              },
                              "agentDelayBeforeFirstMessage": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 2500,
                                "default": 500
                              },
                              "initialSilenceTimeout": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 60000,
                                "default": 30000
                              },
                              "finalSilenceTimeout": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 60000,
                                "default": 10000
                              },
                              "maxCallDuration": {
                                "type": "integer",
                                "minimum": 300,
                                "maximum": 6000,
                                "default": 900
                              },
                              "minInterruptionWords": {
                                "type": "integer",
                                "minimum": 0,
                                "default": 1
                              },
                              "minInterruptionDuration": {
                                "type": "number",
                                "minimum": 0,
                                "default": 1
                              },
                              "minEndpointingDelay": {
                                "type": "number",
                                "minimum": 0,
                                "default": 0.5
                              },
                              "maxEndpointingDelay": {
                                "type": "number",
                                "minimum": 0,
                                "default": 3
                              },
                              "vadActivationThreshold": {
                                "type": "number",
                                "minimum": 0.1,
                                "maximum": 0.9,
                                "default": 0.5
                              },
                              "language": {
                                "type": "object",
                                "properties": {
                                  "languageId": {
                                    "type": "string"
                                  },
                                  "languageCode": {
                                    "type": "string",
                                    "enum": [
                                      "EN",
                                      "EN_US",
                                      "EN_AU",
                                      "EN_GB",
                                      "EN_IN",
                                      "EN_NZ",
                                      "HI",
                                      "DE",
                                      "FR",
                                      "ES",
                                      "JA",
                                      "PT_BR"
                                    ]
                                  },
                                  "languageDisplayName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "languageId",
                                  "languageCode",
                                  "languageDisplayName"
                                ]
                              },
                              "transferImmediatelyOnInbound": {
                                "type": "boolean",
                                "default": false
                              },
                              "inactivityTimeoutHours": {
                                "type": "integer",
                                "nullable": true,
                                "minimum": 1
                              },
                              "smsMaxTokens": {
                                "type": "integer",
                                "nullable": true,
                                "minimum": 100,
                                "maximum": 2000
                              },
                              "smsTemperature": {
                                "type": "number",
                                "nullable": true,
                                "minimum": 0,
                                "maximum": 2
                              },
                              "discardInboundSms": {
                                "type": "boolean",
                                "default": false
                              },
                              "webChatAggregationWindowSeconds": {
                                "type": "integer",
                                "nullable": true,
                                "minimum": 1,
                                "maximum": 115
                              },
                              "emailDomainId": {
                                "type": "string",
                                "nullable": true
                              },
                              "emailFromLocalPart": {
                                "type": "string",
                                "nullable": true
                              },
                              "emailFromName": {
                                "type": "string",
                                "nullable": true
                              },
                              "emailMaxTokens": {
                                "type": "integer",
                                "nullable": true,
                                "minimum": 100,
                                "maximum": 10000
                              },
                              "emailTemperature": {
                                "type": "number",
                                "nullable": true,
                                "minimum": 0,
                                "maximum": 2
                              },
                              "emailInactivityTimeoutHours": {
                                "type": "integer",
                                "nullable": true,
                                "minimum": 1
                              },
                              "emailFilteringEnabled": {
                                "type": "boolean",
                                "default": false
                              },
                              "emailResponseMode": {
                                "type": "string",
                                "enum": [
                                  "AUTO_SEND",
                                  "SUGGEST_ONLY",
                                  "CONFIDENCE_BASED"
                                ],
                                "default": "AUTO_SEND"
                              },
                              "emailConfidenceThreshold": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 1,
                                "default": 0.8
                              },
                              "emailTags": {
                                "type": "array",
                                "nullable": true,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "autoClose": {
                                      "type": "boolean"
                                    },
                                    "gmailLabelId": {
                                      "type": "string"
                                    },
                                    "gmailLabelName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "prompt",
                                    "autoClose"
                                  ]
                                }
                              },
                              "sentimentAnalysis": {
                                "type": "boolean",
                                "default": false
                              },
                              "preCallWebhook": {
                                "$ref": "#/components/schemas/PreCallWebhook"
                              }
                            },
                            "required": [
                              "id",
                              "version",
                              "name",
                              "createdAt",
                              "updatedAt",
                              "mode",
                              "promptPersonalityId",
                              "sttConfigId",
                              "ttsConfigId",
                              "llmConfigId",
                              "overrideSTTConfig",
                              "overrideTTSConfig",
                              "overrideLLMConfig",
                              "voiceId",
                              "postCallPrompt",
                              "postCallVariables",
                              "knowledgeBaseCollectionIds",
                              "voicemailMessage",
                              "firstMessage",
                              "forwardingPhoneNumber",
                              "warmTransferMessageMode",
                              "warmTransferBriefingTemplate",
                              "warmTransferInstructions",
                              "inactivityTimeoutHours",
                              "smsMaxTokens",
                              "smsTemperature",
                              "webChatAggregationWindowSeconds"
                            ]
                          }
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "agentType",
                        "createdAt",
                        "updatedAt",
                        "smsPhoneNumbers",
                        "inboundPhoneNumbers",
                        "outboundPhoneNumbers",
                        "versions"
                      ]
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "agent",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{id}/clone": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Clone an existing agent",
        "description": "Clone an existing agent with either the latest or deployed version",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The ID of the agent to clone",
              "example": "123"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "versionType": {
                    "type": "string",
                    "enum": [
                      "latest",
                      "deployed"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "versionType",
                  "name",
                  "description"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Agent cloned successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "agentType": {
                          "type": "string",
                          "enum": [
                            "CALL",
                            "TEXT"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "smsPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "inboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "outboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "callObservabilityEnabled": {
                          "type": "boolean",
                          "default": false
                        },
                        "version": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "version": {
                              "type": "number"
                            },
                            "name": {
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updatedAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "FLOW",
                                "PROMPT"
                              ]
                            },
                            "prompt": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "system": {
                                  "type": "string"
                                },
                                "systemUIFormatting": {
                                  "nullable": true
                                },
                                "variables": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "required": {
                                        "type": "boolean",
                                        "default": true
                                      },
                                      "defaultValue": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "name"
                                    ]
                                  }
                                },
                                "tools": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "preBuiltTools": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "system"
                              ]
                            },
                            "promptPersonalityId": {
                              "type": "string",
                              "nullable": true
                            },
                            "sttConfigId": {
                              "type": "string",
                              "nullable": true
                            },
                            "ttsConfigId": {
                              "type": "string",
                              "nullable": true
                            },
                            "llmConfigId": {
                              "type": "string",
                              "nullable": true
                            },
                            "overrideSTTConfig": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "keywords": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "keyword": {
                                        "type": "string"
                                      },
                                      "intensifier": {
                                        "type": "string",
                                        "enum": [
                                          "HIGH_SUPPRESS",
                                          "SUPPRESS",
                                          "INTENSIFY",
                                          "HIGH_INTENSIFY"
                                        ],
                                        "default": "INTENSIFY"
                                      }
                                    },
                                    "required": [
                                      "keyword"
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "keywords"
                              ]
                            },
                            "overrideTTSConfig": {
                              "$ref": "#/components/schemas/OverrideTTSConfig"
                            },
                            "overrideLLMConfig": {
                              "type": "object",
                              "nullable": true,
                              "additionalProperties": {
                                "nullable": true
                              }
                            },
                            "voiceId": {
                              "type": "string",
                              "nullable": true
                            },
                            "postCallPrompt": {
                              "type": "string",
                              "nullable": true
                            },
                            "postCallVariables": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "$ref": "#/components/schemas/PostCallVariable"
                              }
                            },
                            "knowledgeBaseCollectionIds": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "string"
                              }
                            },
                            "voicemailMessage": {
                              "type": "string",
                              "nullable": true
                            },
                            "voicemailDetectionMode": {
                              "type": "string",
                              "enum": [
                                "ASYNC",
                                "SYNC"
                              ],
                              "default": "ASYNC"
                            },
                            "speakFirst": {
                              "type": "boolean",
                              "default": false
                            },
                            "firstMessage": {
                              "type": "string",
                              "nullable": true
                            },
                            "useKnowledgeBase": {
                              "type": "boolean",
                              "default": true
                            },
                            "enableBackgroundAudio": {
                              "type": "boolean",
                              "default": false
                            },
                            "backgroundAudio": {
                              "type": "number",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 100,
                              "exclusiveMaximum": true,
                              "default": 50
                            },
                            "voiceVolume": {
                              "type": "integer",
                              "minimum": 10,
                              "maximum": 120,
                              "default": 100
                            },
                            "forwardingPhoneNumber": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                            },
                            "warmTransferMessageMode": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "STATIC",
                                "PROMPT"
                              ]
                            },
                            "warmTransferBriefingTemplate": {
                              "type": "string",
                              "nullable": true
                            },
                            "warmTransferInteractive": {
                              "type": "boolean",
                              "default": false
                            },
                            "warmTransferInstructions": {
                              "type": "string",
                              "nullable": true
                            },
                            "voiceSpeed": {
                              "type": "number",
                              "nullable": true,
                              "minimum": 0.8,
                              "maximum": 1.2,
                              "default": 1
                            },
                            "agentDelayBeforeFirstMessage": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 2500,
                              "default": 500
                            },
                            "initialSilenceTimeout": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 60000,
                              "default": 30000
                            },
                            "finalSilenceTimeout": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 60000,
                              "default": 10000
                            },
                            "maxCallDuration": {
                              "type": "integer",
                              "minimum": 300,
                              "maximum": 6000,
                              "default": 900
                            },
                            "minInterruptionWords": {
                              "type": "integer",
                              "minimum": 0,
                              "default": 1
                            },
                            "minInterruptionDuration": {
                              "type": "number",
                              "minimum": 0,
                              "default": 1
                            },
                            "minEndpointingDelay": {
                              "type": "number",
                              "minimum": 0,
                              "default": 0.5
                            },
                            "maxEndpointingDelay": {
                              "type": "number",
                              "minimum": 0,
                              "default": 3
                            },
                            "vadActivationThreshold": {
                              "type": "number",
                              "minimum": 0.1,
                              "maximum": 0.9,
                              "default": 0.5
                            },
                            "language": {
                              "type": "object",
                              "properties": {
                                "languageId": {
                                  "type": "string"
                                },
                                "languageCode": {
                                  "type": "string",
                                  "enum": [
                                    "EN",
                                    "EN_US",
                                    "EN_AU",
                                    "EN_GB",
                                    "EN_IN",
                                    "EN_NZ",
                                    "HI",
                                    "DE",
                                    "FR",
                                    "ES",
                                    "JA",
                                    "PT_BR"
                                  ]
                                },
                                "languageDisplayName": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "languageId",
                                "languageCode",
                                "languageDisplayName"
                              ]
                            },
                            "transferImmediatelyOnInbound": {
                              "type": "boolean",
                              "default": false
                            },
                            "inactivityTimeoutHours": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 1
                            },
                            "smsMaxTokens": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 100,
                              "maximum": 2000
                            },
                            "smsTemperature": {
                              "type": "number",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 2
                            },
                            "discardInboundSms": {
                              "type": "boolean",
                              "default": false
                            },
                            "webChatAggregationWindowSeconds": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 1,
                              "maximum": 115
                            },
                            "emailDomainId": {
                              "type": "string",
                              "nullable": true
                            },
                            "emailFromLocalPart": {
                              "type": "string",
                              "nullable": true
                            },
                            "emailFromName": {
                              "type": "string",
                              "nullable": true
                            },
                            "emailMaxTokens": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 100,
                              "maximum": 10000
                            },
                            "emailTemperature": {
                              "type": "number",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 2
                            },
                            "emailInactivityTimeoutHours": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 1
                            },
                            "emailFilteringEnabled": {
                              "type": "boolean",
                              "default": false
                            },
                            "emailResponseMode": {
                              "type": "string",
                              "enum": [
                                "AUTO_SEND",
                                "SUGGEST_ONLY",
                                "CONFIDENCE_BASED"
                              ],
                              "default": "AUTO_SEND"
                            },
                            "emailConfidenceThreshold": {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1,
                              "default": 0.8
                            },
                            "emailTags": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "autoClose": {
                                    "type": "boolean"
                                  },
                                  "gmailLabelId": {
                                    "type": "string"
                                  },
                                  "gmailLabelName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "name",
                                  "prompt",
                                  "autoClose"
                                ]
                              }
                            },
                            "sentimentAnalysis": {
                              "type": "boolean",
                              "default": false
                            },
                            "preCallWebhook": {
                              "$ref": "#/components/schemas/PreCallWebhook"
                            }
                          },
                          "required": [
                            "id",
                            "version",
                            "name",
                            "createdAt",
                            "updatedAt",
                            "mode",
                            "promptPersonalityId",
                            "sttConfigId",
                            "ttsConfigId",
                            "llmConfigId",
                            "overrideSTTConfig",
                            "overrideTTSConfig",
                            "overrideLLMConfig",
                            "voiceId",
                            "postCallPrompt",
                            "postCallVariables",
                            "knowledgeBaseCollectionIds",
                            "voicemailMessage",
                            "firstMessage",
                            "forwardingPhoneNumber",
                            "warmTransferMessageMode",
                            "warmTransferBriefingTemplate",
                            "warmTransferInstructions",
                            "inactivityTimeoutHours",
                            "smsMaxTokens",
                            "smsTemperature",
                            "webChatAggregationWindowSeconds"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "agentType",
                        "createdAt",
                        "updatedAt",
                        "smsPhoneNumbers",
                        "inboundPhoneNumbers",
                        "outboundPhoneNumbers",
                        "version"
                      ]
                    }
                  },
                  "required": [
                    "agent"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{agentId}": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Create agent version",
        "description": "Create a new version for an existing agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "FLOW",
                      "PROMPT"
                    ]
                  },
                  "prompt": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "system": {
                        "type": "string"
                      },
                      "systemUIFormatting": {
                        "nullable": true
                      },
                      "variables": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "required": {
                              "type": "boolean",
                              "default": true
                            },
                            "defaultValue": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "name"
                          ]
                        }
                      },
                      "tools": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "preBuiltTools": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": [
                      "system"
                    ]
                  },
                  "promptPersonalityId": {
                    "type": "string",
                    "nullable": true
                  },
                  "llmConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "languageId": {
                    "type": "string",
                    "nullable": true,
                    "format": "uuid"
                  },
                  "useKnowledgeBase": {
                    "type": "boolean"
                  },
                  "knowledgeBaseCollectionIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "sttConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "ttsConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "overrideSTTConfig": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "keywords": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "keyword": {
                              "type": "string"
                            },
                            "intensifier": {
                              "type": "string",
                              "enum": [
                                "HIGH_SUPPRESS",
                                "SUPPRESS",
                                "INTENSIFY",
                                "HIGH_INTENSIFY"
                              ],
                              "default": "INTENSIFY"
                            }
                          },
                          "required": [
                            "keyword"
                          ]
                        }
                      }
                    },
                    "required": [
                      "keywords"
                    ]
                  },
                  "overrideTTSConfig": {
                    "$ref": "#/components/schemas/OverrideTTSConfig"
                  },
                  "overrideLLMConfig": {
                    "type": "object",
                    "nullable": true,
                    "additionalProperties": {
                      "nullable": true
                    }
                  },
                  "voiceId": {
                    "type": "string",
                    "nullable": true
                  },
                  "voicemailMessage": {
                    "type": "string",
                    "nullable": true
                  },
                  "voicemailDetectionMode": {
                    "type": "string",
                    "enum": [
                      "ASYNC",
                      "SYNC"
                    ],
                    "default": "ASYNC"
                  },
                  "speakFirst": {
                    "type": "boolean",
                    "default": false
                  },
                  "firstMessage": {
                    "type": "string",
                    "nullable": true
                  },
                  "enableBackgroundAudio": {
                    "type": "boolean"
                  },
                  "backgroundAudio": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "voiceVolume": {
                    "type": "integer",
                    "minimum": 10,
                    "maximum": 120,
                    "default": 100
                  },
                  "voiceSpeed": {
                    "type": "number",
                    "minimum": 0.8,
                    "maximum": 1.2
                  },
                  "postCallPrompt": {
                    "type": "string",
                    "nullable": true
                  },
                  "postCallVariables": {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "$ref": "#/components/schemas/PostCallVariable"
                    }
                  },
                  "preCallWebhook": {
                    "$ref": "#/components/schemas/PreCallWebhook"
                  },
                  "agentDelayBeforeFirstMessage": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 2500
                  },
                  "initialSilenceTimeout": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 60000,
                    "default": 30000
                  },
                  "finalSilenceTimeout": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 60000,
                    "default": 10000
                  },
                  "transferImmediatelyOnInbound": {
                    "type": "boolean",
                    "default": false
                  },
                  "maxCallDuration": {
                    "type": "integer",
                    "minimum": 300,
                    "maximum": 6000,
                    "default": 900
                  },
                  "minInterruptionWords": {
                    "type": "integer",
                    "minimum": 0,
                    "default": 1
                  },
                  "minInterruptionDuration": {
                    "type": "number",
                    "minimum": 0,
                    "default": 1
                  },
                  "minEndpointingDelay": {
                    "type": "number",
                    "minimum": 0,
                    "default": 0.5
                  },
                  "maxEndpointingDelay": {
                    "type": "number",
                    "minimum": 0,
                    "default": 3
                  },
                  "vadActivationThreshold": {
                    "type": "number",
                    "minimum": 0.1,
                    "maximum": 0.9,
                    "default": 0.5
                  },
                  "sms": {
                    "type": "object",
                    "properties": {
                      "inactivityTimeoutHours": {
                        "type": "integer",
                        "nullable": true,
                        "minimum": 1
                      },
                      "smsMaxTokens": {
                        "type": "integer",
                        "minimum": 100,
                        "maximum": 2000,
                        "default": 500
                      },
                      "smsTemperature": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 2,
                        "default": 0.7
                      },
                      "discardInboundSms": {
                        "type": "boolean",
                        "default": false
                      }
                    },
                    "required": [
                      "inactivityTimeoutHours"
                    ]
                  },
                  "webChatAggregationWindowSeconds": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1,
                    "maximum": 115
                  },
                  "emailDomainId": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailFromLocalPart": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailFromName": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailMaxTokens": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 100,
                    "maximum": 10000
                  },
                  "emailTemperature": {
                    "type": "number",
                    "nullable": true,
                    "minimum": 0,
                    "maximum": 2
                  },
                  "emailInactivityTimeoutHours": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1
                  },
                  "emailFilteringEnabled": {
                    "type": "boolean"
                  },
                  "emailResponseMode": {
                    "type": "string",
                    "enum": [
                      "AUTO_SEND",
                      "SUGGEST_ONLY",
                      "CONFIDENCE_BASED"
                    ]
                  },
                  "emailConfidenceThreshold": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "emailTags": {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "autoClose": {
                          "type": "boolean"
                        },
                        "gmailLabelId": {
                          "type": "string"
                        },
                        "gmailLabelName": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "prompt",
                        "autoClose"
                      ]
                    }
                  },
                  "sentimentAnalysis": {
                    "type": "boolean"
                  },
                  "warmTransferMessageMode": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      "STATIC",
                      "PROMPT"
                    ]
                  },
                  "warmTransferBriefingTemplate": {
                    "type": "string",
                    "nullable": true
                  },
                  "warmTransferInteractive": {
                    "type": "boolean"
                  },
                  "warmTransferInstructions": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "mode",
                  "overrideSTTConfig",
                  "overrideTTSConfig",
                  "overrideLLMConfig",
                  "firstMessage"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "New agent version created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "version": {
                          "type": "number"
                        },
                        "name": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "mode": {
                          "type": "string",
                          "enum": [
                            "FLOW",
                            "PROMPT"
                          ]
                        },
                        "prompt": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "system": {
                              "type": "string"
                            },
                            "systemUIFormatting": {
                              "nullable": true
                            },
                            "variables": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "required": {
                                    "type": "boolean",
                                    "default": true
                                  },
                                  "defaultValue": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "name"
                                ]
                              }
                            },
                            "tools": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "preBuiltTools": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "system"
                          ]
                        },
                        "promptPersonalityId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sttConfigId": {
                          "type": "string",
                          "nullable": true
                        },
                        "ttsConfigId": {
                          "type": "string",
                          "nullable": true
                        },
                        "llmConfigId": {
                          "type": "string",
                          "nullable": true
                        },
                        "overrideSTTConfig": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "keywords": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "keyword": {
                                    "type": "string"
                                  },
                                  "intensifier": {
                                    "type": "string",
                                    "enum": [
                                      "HIGH_SUPPRESS",
                                      "SUPPRESS",
                                      "INTENSIFY",
                                      "HIGH_INTENSIFY"
                                    ],
                                    "default": "INTENSIFY"
                                  }
                                },
                                "required": [
                                  "keyword"
                                ]
                              }
                            }
                          },
                          "required": [
                            "keywords"
                          ]
                        },
                        "overrideTTSConfig": {
                          "$ref": "#/components/schemas/OverrideTTSConfig"
                        },
                        "overrideLLMConfig": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "nullable": true
                          }
                        },
                        "voiceId": {
                          "type": "string",
                          "nullable": true
                        },
                        "postCallPrompt": {
                          "type": "string",
                          "nullable": true
                        },
                        "postCallVariables": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "$ref": "#/components/schemas/PostCallVariable"
                          }
                        },
                        "knowledgeBaseCollectionIds": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "string"
                          }
                        },
                        "voicemailMessage": {
                          "type": "string",
                          "nullable": true
                        },
                        "voicemailDetectionMode": {
                          "type": "string",
                          "enum": [
                            "ASYNC",
                            "SYNC"
                          ],
                          "default": "ASYNC"
                        },
                        "speakFirst": {
                          "type": "boolean",
                          "default": false
                        },
                        "firstMessage": {
                          "type": "string",
                          "nullable": true
                        },
                        "useKnowledgeBase": {
                          "type": "boolean",
                          "default": true
                        },
                        "enableBackgroundAudio": {
                          "type": "boolean",
                          "default": false
                        },
                        "backgroundAudio": {
                          "type": "number",
                          "minimum": 0,
                          "exclusiveMinimum": true,
                          "maximum": 100,
                          "exclusiveMaximum": true,
                          "default": 50
                        },
                        "voiceVolume": {
                          "type": "integer",
                          "minimum": 10,
                          "maximum": 120,
                          "default": 100
                        },
                        "forwardingPhoneNumber": {
                          "type": "string",
                          "nullable": true,
                          "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                        },
                        "warmTransferMessageMode": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "STATIC",
                            "PROMPT"
                          ]
                        },
                        "warmTransferBriefingTemplate": {
                          "type": "string",
                          "nullable": true
                        },
                        "warmTransferInteractive": {
                          "type": "boolean",
                          "default": false
                        },
                        "warmTransferInstructions": {
                          "type": "string",
                          "nullable": true
                        },
                        "voiceSpeed": {
                          "type": "number",
                          "nullable": true,
                          "minimum": 0.8,
                          "maximum": 1.2,
                          "default": 1
                        },
                        "agentDelayBeforeFirstMessage": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 2500,
                          "default": 500
                        },
                        "initialSilenceTimeout": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 60000,
                          "default": 30000
                        },
                        "finalSilenceTimeout": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 60000,
                          "default": 10000
                        },
                        "maxCallDuration": {
                          "type": "integer",
                          "minimum": 300,
                          "maximum": 6000,
                          "default": 900
                        },
                        "minInterruptionWords": {
                          "type": "integer",
                          "minimum": 0,
                          "default": 1
                        },
                        "minInterruptionDuration": {
                          "type": "number",
                          "minimum": 0,
                          "default": 1
                        },
                        "minEndpointingDelay": {
                          "type": "number",
                          "minimum": 0,
                          "default": 0.5
                        },
                        "maxEndpointingDelay": {
                          "type": "number",
                          "minimum": 0,
                          "default": 3
                        },
                        "vadActivationThreshold": {
                          "type": "number",
                          "minimum": 0.1,
                          "maximum": 0.9,
                          "default": 0.5
                        },
                        "language": {
                          "type": "object",
                          "properties": {
                            "languageId": {
                              "type": "string"
                            },
                            "languageCode": {
                              "type": "string",
                              "enum": [
                                "EN",
                                "EN_US",
                                "EN_AU",
                                "EN_GB",
                                "EN_IN",
                                "EN_NZ",
                                "HI",
                                "DE",
                                "FR",
                                "ES",
                                "JA",
                                "PT_BR"
                              ]
                            },
                            "languageDisplayName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "languageId",
                            "languageCode",
                            "languageDisplayName"
                          ]
                        },
                        "transferImmediatelyOnInbound": {
                          "type": "boolean",
                          "default": false
                        },
                        "inactivityTimeoutHours": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 1
                        },
                        "smsMaxTokens": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 100,
                          "maximum": 2000
                        },
                        "smsTemperature": {
                          "type": "number",
                          "nullable": true,
                          "minimum": 0,
                          "maximum": 2
                        },
                        "discardInboundSms": {
                          "type": "boolean",
                          "default": false
                        },
                        "webChatAggregationWindowSeconds": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 1,
                          "maximum": 115
                        },
                        "emailDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailFromLocalPart": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailFromName": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailMaxTokens": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 100,
                          "maximum": 10000
                        },
                        "emailTemperature": {
                          "type": "number",
                          "nullable": true,
                          "minimum": 0,
                          "maximum": 2
                        },
                        "emailInactivityTimeoutHours": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 1
                        },
                        "emailFilteringEnabled": {
                          "type": "boolean",
                          "default": false
                        },
                        "emailResponseMode": {
                          "type": "string",
                          "enum": [
                            "AUTO_SEND",
                            "SUGGEST_ONLY",
                            "CONFIDENCE_BASED"
                          ],
                          "default": "AUTO_SEND"
                        },
                        "emailConfidenceThreshold": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1,
                          "default": 0.8
                        },
                        "emailTags": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "autoClose": {
                                "type": "boolean"
                              },
                              "gmailLabelId": {
                                "type": "string"
                              },
                              "gmailLabelName": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "name",
                              "prompt",
                              "autoClose"
                            ]
                          }
                        },
                        "sentimentAnalysis": {
                          "type": "boolean",
                          "default": false
                        },
                        "preCallWebhook": {
                          "$ref": "#/components/schemas/PreCallWebhook"
                        }
                      },
                      "required": [
                        "id",
                        "version",
                        "name",
                        "createdAt",
                        "updatedAt",
                        "mode",
                        "promptPersonalityId",
                        "sttConfigId",
                        "ttsConfigId",
                        "llmConfigId",
                        "overrideSTTConfig",
                        "overrideTTSConfig",
                        "overrideLLMConfig",
                        "voiceId",
                        "postCallPrompt",
                        "postCallVariables",
                        "knowledgeBaseCollectionIds",
                        "voicemailMessage",
                        "firstMessage",
                        "forwardingPhoneNumber",
                        "warmTransferMessageMode",
                        "warmTransferBriefingTemplate",
                        "warmTransferInstructions",
                        "inactivityTimeoutHours",
                        "smsMaxTokens",
                        "smsTemperature",
                        "webChatAggregationWindowSeconds"
                      ]
                    }
                  },
                  "required": [
                    "version"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Agents"
        ],
        "summary": "Update an agent",
        "description": "Update an existing agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string",
                    "nullable": true
                  },
                  "callObservabilityEnabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "agentType": {
                          "type": "string",
                          "enum": [
                            "CALL",
                            "TEXT"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "smsPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "inboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "outboundPhoneNumbers": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "phoneNumber": {
                                "type": "string"
                              },
                              "ownership": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "FEATHER",
                                  "CLIENT"
                                ]
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber",
                              "ownership",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "callObservabilityEnabled": {
                          "type": "boolean",
                          "default": false
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "agentType",
                        "createdAt",
                        "updatedAt",
                        "smsPhoneNumbers",
                        "inboundPhoneNumbers",
                        "outboundPhoneNumbers"
                      ]
                    }
                  },
                  "required": [
                    "agent"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Agents"
        ],
        "summary": "Delete an agent",
        "description": "Delete an agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agentId": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "agentId",
                    "success"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{agentId}/versions/{versionId}": {
      "patch": {
        "tags": [
          "Agents"
        ],
        "summary": "Update agent version",
        "description": "Update an existing agent version",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "nullable": true,
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "FLOW",
                      "PROMPT"
                    ]
                  },
                  "prompt": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "system": {
                        "type": "string"
                      },
                      "systemUIFormatting": {
                        "nullable": true
                      },
                      "variables": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "required": {
                              "type": "boolean",
                              "default": true
                            },
                            "defaultValue": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "name"
                          ]
                        }
                      },
                      "tools": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "preBuiltTools": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": [
                      "system"
                    ]
                  },
                  "promptPersonalityId": {
                    "type": "string",
                    "nullable": true
                  },
                  "sttConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "ttsConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "llmConfigId": {
                    "type": "string",
                    "nullable": true
                  },
                  "overrideSTTConfig": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "keywords": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "keyword": {
                              "type": "string"
                            },
                            "intensifier": {
                              "type": "string",
                              "enum": [
                                "HIGH_SUPPRESS",
                                "SUPPRESS",
                                "INTENSIFY",
                                "HIGH_INTENSIFY"
                              ],
                              "default": "INTENSIFY"
                            }
                          },
                          "required": [
                            "keyword"
                          ]
                        }
                      }
                    },
                    "required": [
                      "keywords"
                    ]
                  },
                  "overrideTTSConfig": {
                    "$ref": "#/components/schemas/OverrideTTSConfig"
                  },
                  "overrideLLMConfig": {
                    "type": "object",
                    "nullable": true,
                    "additionalProperties": {
                      "nullable": true
                    }
                  },
                  "voiceId": {
                    "type": "string",
                    "nullable": true
                  },
                  "postCallPrompt": {
                    "type": "string",
                    "nullable": true
                  },
                  "knowledgeBaseCollectionIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "voicemailMessage": {
                    "type": "string",
                    "nullable": true
                  },
                  "voicemailDetectionMode": {
                    "type": "string",
                    "enum": [
                      "ASYNC",
                      "SYNC"
                    ]
                  },
                  "speakFirst": {
                    "type": "boolean"
                  },
                  "firstMessage": {
                    "type": "string",
                    "nullable": true
                  },
                  "useKnowledgeBase": {
                    "type": "boolean"
                  },
                  "enableBackgroundAudio": {
                    "type": "boolean"
                  },
                  "backgroundAudio": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "voiceVolume": {
                    "type": "integer",
                    "minimum": 10,
                    "maximum": 120
                  },
                  "voiceSpeed": {
                    "type": "number",
                    "minimum": 0.8,
                    "maximum": 1.2
                  },
                  "forwardingPhoneNumber": {
                    "type": "string",
                    "nullable": true,
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                  },
                  "postCallVariables": {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "$ref": "#/components/schemas/PostCallVariable"
                    }
                  },
                  "preCallWebhook": {
                    "$ref": "#/components/schemas/PreCallWebhook"
                  },
                  "languageId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "agentDelayBeforeFirstMessage": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 2500
                  },
                  "initialSilenceTimeout": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 60000
                  },
                  "finalSilenceTimeout": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 60000
                  },
                  "transferImmediatelyOnInbound": {
                    "type": "boolean"
                  },
                  "maxCallDuration": {
                    "type": "integer",
                    "minimum": 300,
                    "maximum": 6000
                  },
                  "minInterruptionWords": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "minInterruptionDuration": {
                    "type": "number",
                    "minimum": 0
                  },
                  "minEndpointingDelay": {
                    "type": "number",
                    "minimum": 0
                  },
                  "maxEndpointingDelay": {
                    "type": "number",
                    "minimum": 0
                  },
                  "vadActivationThreshold": {
                    "type": "number",
                    "minimum": 0.1,
                    "maximum": 0.9
                  },
                  "inactivityTimeoutHours": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1
                  },
                  "smsMaxTokens": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 2000
                  },
                  "smsTemperature": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 2
                  },
                  "discardInboundSms": {
                    "type": "boolean"
                  },
                  "webChatAggregationWindowSeconds": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1,
                    "maximum": 115
                  },
                  "emailDomainId": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailFromLocalPart": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailFromName": {
                    "type": "string",
                    "nullable": true
                  },
                  "emailMaxTokens": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 100,
                    "maximum": 10000
                  },
                  "emailTemperature": {
                    "type": "number",
                    "nullable": true,
                    "minimum": 0,
                    "maximum": 2
                  },
                  "emailInactivityTimeoutHours": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1
                  },
                  "emailFilteringEnabled": {
                    "type": "boolean"
                  },
                  "emailResponseMode": {
                    "type": "string",
                    "enum": [
                      "AUTO_SEND",
                      "SUGGEST_ONLY",
                      "CONFIDENCE_BASED"
                    ]
                  },
                  "emailConfidenceThreshold": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "emailTags": {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "autoClose": {
                          "type": "boolean"
                        },
                        "gmailLabelId": {
                          "type": "string"
                        },
                        "gmailLabelName": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "prompt",
                        "autoClose"
                      ]
                    }
                  },
                  "sentimentAnalysis": {
                    "type": "boolean"
                  },
                  "warmTransferMessageMode": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      "STATIC",
                      "PROMPT"
                    ]
                  },
                  "warmTransferBriefingTemplate": {
                    "type": "string",
                    "nullable": true
                  },
                  "warmTransferInteractive": {
                    "type": "boolean"
                  },
                  "warmTransferInstructions": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent version updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "version": {
                          "type": "number"
                        },
                        "name": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "mode": {
                          "type": "string",
                          "enum": [
                            "FLOW",
                            "PROMPT"
                          ]
                        },
                        "prompt": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "system": {
                              "type": "string"
                            },
                            "systemUIFormatting": {
                              "nullable": true
                            },
                            "variables": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "required": {
                                    "type": "boolean",
                                    "default": true
                                  },
                                  "defaultValue": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "name"
                                ]
                              }
                            },
                            "tools": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "preBuiltTools": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "system"
                          ]
                        },
                        "promptPersonalityId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sttConfigId": {
                          "type": "string",
                          "nullable": true
                        },
                        "ttsConfigId": {
                          "type": "string",
                          "nullable": true
                        },
                        "llmConfigId": {
                          "type": "string",
                          "nullable": true
                        },
                        "overrideSTTConfig": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "keywords": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "keyword": {
                                    "type": "string"
                                  },
                                  "intensifier": {
                                    "type": "string",
                                    "enum": [
                                      "HIGH_SUPPRESS",
                                      "SUPPRESS",
                                      "INTENSIFY",
                                      "HIGH_INTENSIFY"
                                    ],
                                    "default": "INTENSIFY"
                                  }
                                },
                                "required": [
                                  "keyword"
                                ]
                              }
                            }
                          },
                          "required": [
                            "keywords"
                          ]
                        },
                        "overrideTTSConfig": {
                          "$ref": "#/components/schemas/OverrideTTSConfig"
                        },
                        "overrideLLMConfig": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "nullable": true
                          }
                        },
                        "voiceId": {
                          "type": "string",
                          "nullable": true
                        },
                        "postCallPrompt": {
                          "type": "string",
                          "nullable": true
                        },
                        "postCallVariables": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "$ref": "#/components/schemas/PostCallVariable"
                          }
                        },
                        "knowledgeBaseCollectionIds": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "string"
                          }
                        },
                        "voicemailMessage": {
                          "type": "string",
                          "nullable": true
                        },
                        "voicemailDetectionMode": {
                          "type": "string",
                          "enum": [
                            "ASYNC",
                            "SYNC"
                          ],
                          "default": "ASYNC"
                        },
                        "speakFirst": {
                          "type": "boolean",
                          "default": false
                        },
                        "firstMessage": {
                          "type": "string",
                          "nullable": true
                        },
                        "useKnowledgeBase": {
                          "type": "boolean",
                          "default": true
                        },
                        "enableBackgroundAudio": {
                          "type": "boolean",
                          "default": false
                        },
                        "backgroundAudio": {
                          "type": "number",
                          "minimum": 0,
                          "exclusiveMinimum": true,
                          "maximum": 100,
                          "exclusiveMaximum": true,
                          "default": 50
                        },
                        "voiceVolume": {
                          "type": "integer",
                          "minimum": 10,
                          "maximum": 120,
                          "default": 100
                        },
                        "forwardingPhoneNumber": {
                          "type": "string",
                          "nullable": true,
                          "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                        },
                        "warmTransferMessageMode": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "STATIC",
                            "PROMPT"
                          ]
                        },
                        "warmTransferBriefingTemplate": {
                          "type": "string",
                          "nullable": true
                        },
                        "warmTransferInteractive": {
                          "type": "boolean",
                          "default": false
                        },
                        "warmTransferInstructions": {
                          "type": "string",
                          "nullable": true
                        },
                        "voiceSpeed": {
                          "type": "number",
                          "nullable": true,
                          "minimum": 0.8,
                          "maximum": 1.2,
                          "default": 1
                        },
                        "agentDelayBeforeFirstMessage": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 2500,
                          "default": 500
                        },
                        "initialSilenceTimeout": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 60000,
                          "default": 30000
                        },
                        "finalSilenceTimeout": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 60000,
                          "default": 10000
                        },
                        "maxCallDuration": {
                          "type": "integer",
                          "minimum": 300,
                          "maximum": 6000,
                          "default": 900
                        },
                        "minInterruptionWords": {
                          "type": "integer",
                          "minimum": 0,
                          "default": 1
                        },
                        "minInterruptionDuration": {
                          "type": "number",
                          "minimum": 0,
                          "default": 1
                        },
                        "minEndpointingDelay": {
                          "type": "number",
                          "minimum": 0,
                          "default": 0.5
                        },
                        "maxEndpointingDelay": {
                          "type": "number",
                          "minimum": 0,
                          "default": 3
                        },
                        "vadActivationThreshold": {
                          "type": "number",
                          "minimum": 0.1,
                          "maximum": 0.9,
                          "default": 0.5
                        },
                        "language": {
                          "type": "object",
                          "properties": {
                            "languageId": {
                              "type": "string"
                            },
                            "languageCode": {
                              "type": "string",
                              "enum": [
                                "EN",
                                "EN_US",
                                "EN_AU",
                                "EN_GB",
                                "EN_IN",
                                "EN_NZ",
                                "HI",
                                "DE",
                                "FR",
                                "ES",
                                "JA",
                                "PT_BR"
                              ]
                            },
                            "languageDisplayName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "languageId",
                            "languageCode",
                            "languageDisplayName"
                          ]
                        },
                        "transferImmediatelyOnInbound": {
                          "type": "boolean",
                          "default": false
                        },
                        "inactivityTimeoutHours": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 1
                        },
                        "smsMaxTokens": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 100,
                          "maximum": 2000
                        },
                        "smsTemperature": {
                          "type": "number",
                          "nullable": true,
                          "minimum": 0,
                          "maximum": 2
                        },
                        "discardInboundSms": {
                          "type": "boolean",
                          "default": false
                        },
                        "webChatAggregationWindowSeconds": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 1,
                          "maximum": 115
                        },
                        "emailDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailFromLocalPart": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailFromName": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailMaxTokens": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 100,
                          "maximum": 10000
                        },
                        "emailTemperature": {
                          "type": "number",
                          "nullable": true,
                          "minimum": 0,
                          "maximum": 2
                        },
                        "emailInactivityTimeoutHours": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 1
                        },
                        "emailFilteringEnabled": {
                          "type": "boolean",
                          "default": false
                        },
                        "emailResponseMode": {
                          "type": "string",
                          "enum": [
                            "AUTO_SEND",
                            "SUGGEST_ONLY",
                            "CONFIDENCE_BASED"
                          ],
                          "default": "AUTO_SEND"
                        },
                        "emailConfidenceThreshold": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1,
                          "default": 0.8
                        },
                        "emailTags": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "autoClose": {
                                "type": "boolean"
                              },
                              "gmailLabelId": {
                                "type": "string"
                              },
                              "gmailLabelName": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "name",
                              "prompt",
                              "autoClose"
                            ]
                          }
                        },
                        "sentimentAnalysis": {
                          "type": "boolean",
                          "default": false
                        },
                        "preCallWebhook": {
                          "$ref": "#/components/schemas/PreCallWebhook"
                        }
                      },
                      "required": [
                        "id",
                        "version",
                        "name",
                        "createdAt",
                        "updatedAt",
                        "mode",
                        "promptPersonalityId",
                        "sttConfigId",
                        "ttsConfigId",
                        "llmConfigId",
                        "overrideSTTConfig",
                        "overrideTTSConfig",
                        "overrideLLMConfig",
                        "voiceId",
                        "postCallPrompt",
                        "postCallVariables",
                        "knowledgeBaseCollectionIds",
                        "voicemailMessage",
                        "firstMessage",
                        "forwardingPhoneNumber",
                        "warmTransferMessageMode",
                        "warmTransferBriefingTemplate",
                        "warmTransferInstructions",
                        "inactivityTimeoutHours",
                        "smsMaxTokens",
                        "smsTemperature",
                        "webChatAggregationWindowSeconds"
                      ]
                    }
                  },
                  "required": [
                    "version"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent or version not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Agents"
        ],
        "summary": "Delete agent version",
        "description": "Delete a version of an agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent version deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agentId": {
                      "type": "string"
                    },
                    "versionId": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "agentId",
                    "versionId",
                    "success"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{agentId}/versions/{versionId}/deploy": {
      "patch": {
        "tags": [
          "Agents"
        ],
        "summary": "Deploy agent version",
        "description": "Deploy an existing agent version",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent version deployed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "displayMessage": {
                      "type": "string",
                      "description": "A message to display to the user"
                    }
                  },
                  "required": [
                    "displayMessage"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent or version not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{agentId}/deployments": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "List agent deployments",
        "description": "List all deployments for an agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of agent deployments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deployments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "agentVersionId": {
                            "type": "string"
                          },
                          "agentId": {
                            "type": "string"
                          },
                          "deploymentStage": {
                            "type": "string",
                            "enum": [
                              "DEV",
                              "PROD"
                            ]
                          },
                          "deployedAt": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "agentVersionId",
                          "agentId",
                          "deploymentStage",
                          "deployedAt",
                          "createdAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "deployments",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/version/{versionId}/share": {
      "post": {
        "tags": [
          "Agent Shares"
        ],
        "summary": "Create or get shareable link for an agent version",
        "description": "Generate a shareable link for a specific agent version. Returns existing link if one already exists.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "secondsLimit": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Shareable link created or retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "shareToken": {
                      "type": "string"
                    },
                    "agentVersionId": {
                      "type": "string"
                    },
                    "secondsLimit": {
                      "type": "number",
                      "nullable": true
                    },
                    "secondsUsed": {
                      "type": "number"
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "shareToken",
                    "agentVersionId",
                    "secondsLimit",
                    "secondsUsed",
                    "createdAt"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Shareable link created or retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "shareToken": {
                      "type": "string"
                    },
                    "agentVersionId": {
                      "type": "string"
                    },
                    "secondsLimit": {
                      "type": "number",
                      "nullable": true
                    },
                    "secondsUsed": {
                      "type": "number"
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "shareToken",
                    "agentVersionId",
                    "secondsLimit",
                    "secondsUsed",
                    "createdAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Agent Shares"
        ],
        "summary": "Get shareable link for an agent version",
        "description": "Get the shareable link for a specific agent version (only one per version)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Shareable link retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "share": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "shareToken": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "secondsLimit": {
                          "type": "number",
                          "nullable": true
                        },
                        "secondsUsed": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "shareToken",
                        "agentVersionId",
                        "secondsLimit",
                        "secondsUsed",
                        "createdAt"
                      ]
                    }
                  },
                  "required": [
                    "share"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Agent Shares"
        ],
        "summary": "Update the shareable link for an agent version",
        "description": "Update the seconds limit for a shareable link",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "secondsLimit": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "exclusiveMinimum": true
                      },
                      {
                        "nullable": true
                      },
                      {
                        "nullable": true
                      }
                    ]
                  }
                },
                "required": [
                  "secondsLimit"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Shareable link updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "shareToken": {
                      "type": "string"
                    },
                    "agentVersionId": {
                      "type": "string"
                    },
                    "secondsLimit": {
                      "type": "number",
                      "nullable": true
                    },
                    "secondsUsed": {
                      "type": "number"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "shareToken",
                    "agentVersionId",
                    "secondsLimit",
                    "secondsUsed",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Agent Shares"
        ],
        "summary": "Delete the shareable link for an agent version",
        "description": "Delete the shareable link for a specific agent version",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Shareable link deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/share/{token}/dispatch": {
      "post": {
        "tags": [
          "Agent Shares"
        ],
        "summary": "Dispatch a shared agent (web mode)",
        "description": "Create a web call session using a shared agent link",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "token",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "leadId": {
                    "type": "string"
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "shareable_link"
                    ]
                  },
                  "zipcode": {
                    "type": "string",
                    "nullable": true,
                    "pattern": "^\\d{5}(-?\\d{4})?$"
                  },
                  "customer": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "firstName"
                    ]
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "leadId",
                  "firstName",
                  "mode"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Dispatch created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connectionDetails": {
                      "$ref": "#/components/schemas/WebDispatchConnectionDetails"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Insufficient credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 402
                    },
                    "message": {
                      "type": "string",
                      "default": "Insufficient credits"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "PAYMENT_REQUIRED"
                      ],
                      "default": "PAYMENT_REQUIRED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/dispatch": {
      "post": {
        "tags": [
          "Dispatch"
        ],
        "summary": "Dispatch audio agent",
        "description": "Create a new explicit dispatch for a specific agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "versionId": {
                    "type": "string"
                  },
                  "outboundPhoneNumberId": {
                    "type": "string"
                  },
                  "leadId": {
                    "type": "string"
                  },
                  "toPhoneNumber": {
                    "type": "string",
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "audio",
                      "web"
                    ],
                    "default": "audio"
                  },
                  "zipcode": {
                    "type": "string",
                    "nullable": true,
                    "pattern": "^\\d{5}(-?\\d{4})?$"
                  },
                  "customer": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "firstName"
                    ]
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "forwardingNumber": {
                    "type": "string",
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                  }
                },
                "required": [
                  "leadId",
                  "firstName"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Explicit dispatch created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued"
                      ]
                    },
                    "connectionDetails": {
                      "$ref": "#/components/schemas/WebDispatchConnectionDetails"
                    }
                  },
                  "required": [
                    "id",
                    "status"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Insufficient credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 402
                    },
                    "message": {
                      "type": "string",
                      "default": "Insufficient credits"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "PAYMENT_REQUIRED"
                      ],
                      "default": "PAYMENT_REQUIRED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/listen": {
      "post": {
        "tags": [
          "Dispatch"
        ],
        "summary": "Listen to audio agent",
        "description": "Create a listener token to join an existing agent call room",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentCallId": {
                    "type": "string"
                  }
                },
                "required": [
                  "agentCallId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Listener token created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connectionDetails": {
                      "$ref": "#/components/schemas/WebDispatchConnectionDetails"
                    }
                  },
                  "required": [
                    "connectionDetails"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agentId}/version/{version}/disconnect": {
      "post": {
        "tags": [
          "Dispatch"
        ],
        "summary": "Disconnect explicit dispatch",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "version",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "roomName": {
                    "type": "string"
                  }
                },
                "required": [
                  "roomName"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Room disconnected successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent-calls/{id}": {
      "get": {
        "tags": [
          "Calls"
        ],
        "summary": "Get call record",
        "description": "Get an agent call by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent call retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agentCall": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "agentVersionDetails": {
                          "nullable": true
                        },
                        "agentId": {
                          "type": "string"
                        },
                        "agentDetails": {
                          "nullable": true
                        },
                        "mode": {
                          "type": "string",
                          "enum": [
                            "AUDIO",
                            "WEB",
                            "SHAREABLE_LINK",
                            "CHAT_TEST"
                          ]
                        },
                        "fromPhoneNumber": {
                          "type": "string",
                          "nullable": true
                        },
                        "toPhoneNumber": {
                          "type": "string",
                          "nullable": true
                        },
                        "customer": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "phoneNumber": {
                              "type": "string",
                              "nullable": true
                            },
                            "firstName": {
                              "type": "string",
                              "nullable": true
                            },
                            "lastName": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        },
                        "leadId": {
                          "type": "string",
                          "nullable": true
                        },
                        "callEndedReason": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "COULD_NOT_CONNECT",
                            "NO_ANSWER",
                            "LEFT_VOICEMAIL",
                            "VOICEMAIL_DETECTED",
                            "SILENCE_TIMEOUT",
                            "BAD_NUMBER",
                            "NOT_INTERESTED",
                            "WARM_TRANSFER",
                            "WARM_TRANSFER_FAILED",
                            "CALENDLY",
                            "DNC",
                            "ENDED",
                            "FRAUD",
                            "LINE_BUSY",
                            "TEXT_CONSENT",
                            "CALL_AGAIN"
                          ]
                        },
                        "callEndedBy": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "ASSISTANT",
                            "USER",
                            "UNKNOWN"
                          ]
                        },
                        "callStartedAt": {
                          "type": "string",
                          "nullable": true,
                          "format": "date-time"
                        },
                        "callEndedAt": {
                          "type": "string",
                          "nullable": true,
                          "format": "date-time"
                        },
                        "callDuration": {
                          "type": "number"
                        },
                        "recordingUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "supervisorRecordingUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "transcript": {
                          "type": "string",
                          "nullable": true
                        },
                        "transcriptWithTools": {
                          "type": "string",
                          "nullable": true
                        },
                        "summary": {
                          "type": "string",
                          "nullable": true
                        },
                        "variables": {
                          "nullable": true
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "PENDING",
                            "IN_PROGRESS",
                            "COMPLETED",
                            "FAILED"
                          ]
                        },
                        "outbound": {
                          "type": "boolean"
                        },
                        "postCallAnalysis": {
                          "type": "string",
                          "nullable": true
                        },
                        "structuredPostCallAnalysis": {
                          "type": "string",
                          "nullable": true
                        },
                        "leadState": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "AL",
                            "AK",
                            "AZ",
                            "AR",
                            "CA",
                            "CO",
                            "CT",
                            "DE",
                            "DC",
                            "FL",
                            "GA",
                            "HI",
                            "ID",
                            "IL",
                            "IN",
                            "IA",
                            "KS",
                            "KY",
                            "LA",
                            "ME",
                            "MD",
                            "MA",
                            "MI",
                            "MN",
                            "MS",
                            "MO",
                            "MT",
                            "NE",
                            "NV",
                            "NH",
                            "NJ",
                            "NM",
                            "NY",
                            "NC",
                            "ND",
                            "OH",
                            "OK",
                            "OR",
                            "PA",
                            "RI",
                            "SC",
                            "SD",
                            "TN",
                            "TX",
                            "UT",
                            "VA",
                            "VT",
                            "WA",
                            "WV",
                            "WI",
                            "WY"
                          ]
                        },
                        "workflowId": {
                          "type": "string",
                          "nullable": true
                        },
                        "metadata": {
                          "anyOf": [
                            {
                              "allOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "firstName": {
                                      "type": "string"
                                    },
                                    "lastName": {
                                      "type": "string"
                                    }
                                  }
                                },
                                {
                                  "type": "object",
                                  "additionalProperties": {
                                    "nullable": true
                                  }
                                }
                              ]
                            },
                            {
                              "nullable": true
                            }
                          ]
                        },
                        "leadPriorityDate": {
                          "type": "string",
                          "nullable": true,
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "createdAt",
                        "updatedAt",
                        "agentVersionId",
                        "agentId",
                        "mode",
                        "fromPhoneNumber",
                        "toPhoneNumber",
                        "customer",
                        "leadId",
                        "callEndedReason",
                        "callEndedBy",
                        "callStartedAt",
                        "callEndedAt",
                        "callDuration",
                        "recordingUrl",
                        "supervisorRecordingUrl",
                        "transcript",
                        "transcriptWithTools",
                        "summary",
                        "status",
                        "outbound",
                        "postCallAnalysis",
                        "leadState",
                        "workflowId",
                        "leadPriorityDate"
                      ]
                    }
                  },
                  "required": [
                    "agentCall"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Agent call not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent-calls": {
      "get": {
        "tags": [
          "Calls"
        ],
        "summary": "List all calls",
        "description": "List agent calls with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "IN_PROGRESS",
                "COMPLETED",
                "FAILED"
              ]
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "AUDIO",
                "WEB",
                "SHAREABLE_LINK",
                "CHAT_TEST"
              ]
            },
            "required": false,
            "name": "mode",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "outbound",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter by specific agent ID",
            "name": "agentId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter by specific workflow ID",
            "name": "workflowId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "COULD_NOT_CONNECT",
                "NO_ANSWER",
                "LEFT_VOICEMAIL",
                "VOICEMAIL_DETECTED",
                "SILENCE_TIMEOUT",
                "BAD_NUMBER",
                "NOT_INTERESTED",
                "WARM_TRANSFER",
                "WARM_TRANSFER_FAILED",
                "CALENDLY",
                "DNC",
                "ENDED",
                "FRAUD",
                "LINE_BUSY",
                "TEXT_CONSENT",
                "CALL_AGAIN"
              ]
            },
            "required": false,
            "description": "Filter by call ended reason",
            "name": "callEndedReason",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter calls with duration >= this value (in seconds)",
            "name": "startDuration",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter calls with duration <= this value (in seconds)",
            "name": "endDuration",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter calls started >= this date (ISO 8601)",
            "name": "startCallStartedAt",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter calls started <= this date (ISO 8601)",
            "name": "endCallStartedAt",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^(?:[+ ]1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|[+ ][1-9]\\d{1,14})$"
            },
            "required": false,
            "description": "Filter by recipient phone number in E.164 format (e.g., +1XXXXXXXXXX)",
            "name": "toPhoneNumber",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^(?:[+ ]1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|[+ ][1-9]\\d{1,14})$"
            },
            "required": false,
            "description": "Filter by caller phone number in E.164 format (e.g., +1XXXXXXXXXX)",
            "name": "fromPhoneNumber",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent calls retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agentCalls": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "organizationId": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "agentVersionId": {
                            "type": "string"
                          },
                          "agentVersionDetails": {
                            "nullable": true
                          },
                          "agentId": {
                            "type": "string"
                          },
                          "agentDetails": {
                            "nullable": true
                          },
                          "mode": {
                            "type": "string",
                            "enum": [
                              "AUDIO",
                              "WEB",
                              "SHAREABLE_LINK",
                              "CHAT_TEST"
                            ]
                          },
                          "fromPhoneNumber": {
                            "type": "string",
                            "nullable": true
                          },
                          "toPhoneNumber": {
                            "type": "string",
                            "nullable": true
                          },
                          "customer": {
                            "type": "object",
                            "nullable": true,
                            "properties": {
                              "phoneNumber": {
                                "type": "string",
                                "nullable": true
                              },
                              "firstName": {
                                "type": "string",
                                "nullable": true
                              },
                              "lastName": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          },
                          "leadId": {
                            "type": "string",
                            "nullable": true
                          },
                          "callEndedReason": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "COULD_NOT_CONNECT",
                              "NO_ANSWER",
                              "LEFT_VOICEMAIL",
                              "VOICEMAIL_DETECTED",
                              "SILENCE_TIMEOUT",
                              "BAD_NUMBER",
                              "NOT_INTERESTED",
                              "WARM_TRANSFER",
                              "WARM_TRANSFER_FAILED",
                              "CALENDLY",
                              "DNC",
                              "ENDED",
                              "FRAUD",
                              "LINE_BUSY",
                              "TEXT_CONSENT",
                              "CALL_AGAIN"
                            ]
                          },
                          "callEndedBy": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "ASSISTANT",
                              "USER",
                              "UNKNOWN"
                            ]
                          },
                          "callStartedAt": {
                            "type": "string",
                            "nullable": true,
                            "format": "date-time"
                          },
                          "callEndedAt": {
                            "type": "string",
                            "nullable": true,
                            "format": "date-time"
                          },
                          "callDuration": {
                            "type": "number"
                          },
                          "recordingUrl": {
                            "type": "string",
                            "nullable": true
                          },
                          "supervisorRecordingUrl": {
                            "type": "string",
                            "nullable": true
                          },
                          "transcript": {
                            "type": "string",
                            "nullable": true
                          },
                          "transcriptWithTools": {
                            "type": "string",
                            "nullable": true
                          },
                          "summary": {
                            "type": "string",
                            "nullable": true
                          },
                          "variables": {
                            "nullable": true
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "IN_PROGRESS",
                              "COMPLETED",
                              "FAILED"
                            ]
                          },
                          "outbound": {
                            "type": "boolean"
                          },
                          "postCallAnalysis": {
                            "type": "string",
                            "nullable": true
                          },
                          "structuredPostCallAnalysis": {
                            "type": "string",
                            "nullable": true
                          },
                          "leadState": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "AL",
                              "AK",
                              "AZ",
                              "AR",
                              "CA",
                              "CO",
                              "CT",
                              "DE",
                              "DC",
                              "FL",
                              "GA",
                              "HI",
                              "ID",
                              "IL",
                              "IN",
                              "IA",
                              "KS",
                              "KY",
                              "LA",
                              "ME",
                              "MD",
                              "MA",
                              "MI",
                              "MN",
                              "MS",
                              "MO",
                              "MT",
                              "NE",
                              "NV",
                              "NH",
                              "NJ",
                              "NM",
                              "NY",
                              "NC",
                              "ND",
                              "OH",
                              "OK",
                              "OR",
                              "PA",
                              "RI",
                              "SC",
                              "SD",
                              "TN",
                              "TX",
                              "UT",
                              "VA",
                              "VT",
                              "WA",
                              "WV",
                              "WI",
                              "WY"
                            ]
                          },
                          "workflowId": {
                            "type": "string",
                            "nullable": true
                          },
                          "metadata": {
                            "anyOf": [
                              {
                                "allOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "firstName": {
                                        "type": "string"
                                      },
                                      "lastName": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  {
                                    "type": "object",
                                    "additionalProperties": {
                                      "nullable": true
                                    }
                                  }
                                ]
                              },
                              {
                                "nullable": true
                              }
                            ]
                          },
                          "leadPriorityDate": {
                            "type": "string",
                            "nullable": true,
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "createdAt",
                          "updatedAt",
                          "agentVersionId",
                          "agentId",
                          "mode",
                          "fromPhoneNumber",
                          "toPhoneNumber",
                          "customer",
                          "leadId",
                          "callEndedReason",
                          "callEndedBy",
                          "callStartedAt",
                          "callEndedAt",
                          "callDuration",
                          "recordingUrl",
                          "supervisorRecordingUrl",
                          "transcript",
                          "transcriptWithTools",
                          "summary",
                          "status",
                          "outbound",
                          "postCallAnalysis",
                          "leadState",
                          "workflowId",
                          "leadPriorityDate"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "agentCalls",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent-calls/{id}/recording-url": {
      "get": {
        "tags": [
          "Calls"
        ],
        "summary": "Get a fresh presigned recording URL",
        "description": "Generate a fresh presigned URL for the agent call recording. Use when the URL delivered in the webhook or list/get endpoints has expired. Pass ?type=supervisor to fetch the warm-transfer supervisor leg recording instead of the main call recording.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "main",
                "supervisor"
              ],
              "default": "main"
            },
            "required": false,
            "name": "type",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Fresh presigned URL generated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url",
                    "expiresAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Agent call not found or has no recording",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Unable to generate a fresh presigned URL; retry shortly",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent-test/sessions/start": {
      "post": {
        "tags": [
          "Agent Test"
        ],
        "summary": "Start chat test session",
        "description": "Initialize a new chat test session for an agent without making a phone call",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartTestSessionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Test session created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StartTestSessionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid input or agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Access denied to agent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 401
                    },
                    "message": {
                      "type": "string",
                      "default": "Unauthorized"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "UNAUTHORIZED"
                      ],
                      "default": "UNAUTHORIZED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools": {
      "get": {
        "tags": [
          "Tools"
        ],
        "summary": "List custom tools",
        "description": "List all tools with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of tools retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tools": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "notifyOnFailure": {
                            "type": "boolean"
                          },
                          "successStatusCodes": {
                            "type": "array",
                            "items": {
                              "type": "integer",
                              "minimum": 100,
                              "maximum": 599
                            },
                            "minItems": 1
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "structure": {
                            "type": "object",
                            "properties": {
                              "url": {
                                "type": "string",
                                "description": "The API endpoint URL"
                              },
                              "method": {
                                "type": "string",
                                "enum": [
                                  "GET",
                                  "POST",
                                  "PATCH",
                                  "PUT",
                                  "DELETE"
                                ],
                                "default": "GET",
                                "description": "HTTP method (GET, POST, PATCH, PUT, DELETE)"
                              },
                              "headers": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "key": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "value": {
                                      "type": "string"
                                    },
                                    "secure": {
                                      "type": "boolean",
                                      "default": false,
                                      "description": "If true, the value will be encrypted in the database"
                                    }
                                  },
                                  "required": [
                                    "key",
                                    "value"
                                  ]
                                },
                                "default": [],
                                "description": "HTTP headers with optional encryption"
                              },
                              "body": {
                                "type": "object",
                                "additionalProperties": {
                                  "nullable": true
                                },
                                "default": {},
                                "description": "Request body for POST/PUT requests"
                              },
                              "timeout": {
                                "type": "number",
                                "default": 30,
                                "description": "Request timeout in seconds"
                              },
                              "variables": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "str",
                                        "int",
                                        "float",
                                        "bool"
                                      ]
                                    },
                                    "description": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "required": {
                                      "type": "boolean",
                                      "default": false
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "type"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "url",
                              "variables"
                            ]
                          },
                          "speech": {
                            "type": "string",
                            "nullable": true
                          },
                          "slug": {
                            "type": "string",
                            "pattern": "^[a-z0-9_]+$"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "notifyOnFailure",
                          "successStatusCodes",
                          "createdAt",
                          "updatedAt",
                          "structure",
                          "speech",
                          "slug"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "tools",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tools"
        ],
        "summary": "Create new tool",
        "description": "Create a new tool",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "structure": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string",
                        "description": "The API endpoint URL"
                      },
                      "method": {
                        "type": "string",
                        "enum": [
                          "GET",
                          "POST",
                          "PATCH",
                          "PUT",
                          "DELETE"
                        ],
                        "default": "GET",
                        "description": "HTTP method (GET, POST, PATCH, PUT, DELETE)"
                      },
                      "headers": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "key": {
                              "type": "string",
                              "minLength": 1
                            },
                            "value": {
                              "type": "string"
                            },
                            "secure": {
                              "type": "boolean",
                              "default": false,
                              "description": "If true, the value will be encrypted in the database"
                            }
                          },
                          "required": [
                            "key",
                            "value"
                          ]
                        },
                        "default": [],
                        "description": "HTTP headers with optional encryption"
                      },
                      "body": {
                        "type": "object",
                        "additionalProperties": {
                          "nullable": true
                        },
                        "default": {},
                        "description": "Request body for POST/PUT requests"
                      },
                      "timeout": {
                        "type": "number",
                        "default": 30,
                        "description": "Request timeout in seconds"
                      },
                      "variables": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "str",
                                "int",
                                "float",
                                "bool"
                              ]
                            },
                            "description": {
                              "type": "string",
                              "nullable": true
                            },
                            "required": {
                              "type": "boolean",
                              "default": false
                            }
                          },
                          "required": [
                            "name",
                            "type"
                          ]
                        }
                      }
                    },
                    "required": [
                      "url",
                      "variables"
                    ]
                  },
                  "speech": {
                    "type": "string"
                  },
                  "notifyOnFailure": {
                    "type": "boolean",
                    "default": false
                  },
                  "successStatusCodes": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "minimum": 100,
                      "maximum": 599
                    },
                    "minItems": 1,
                    "default": [
                      200
                    ]
                  },
                  "slug": {
                    "type": "string",
                    "pattern": "^[a-z0-9_]+$"
                  }
                },
                "required": [
                  "name",
                  "description",
                  "structure",
                  "slug"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "New tool created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tool": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "notifyOnFailure": {
                          "type": "boolean"
                        },
                        "successStatusCodes": {
                          "type": "array",
                          "items": {
                            "type": "integer",
                            "minimum": 100,
                            "maximum": 599
                          },
                          "minItems": 1
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "structure": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "The API endpoint URL"
                            },
                            "method": {
                              "type": "string",
                              "enum": [
                                "GET",
                                "POST",
                                "PATCH",
                                "PUT",
                                "DELETE"
                              ],
                              "default": "GET",
                              "description": "HTTP method (GET, POST, PATCH, PUT, DELETE)"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "value": {
                                    "type": "string"
                                  },
                                  "secure": {
                                    "type": "boolean",
                                    "default": false,
                                    "description": "If true, the value will be encrypted in the database"
                                  }
                                },
                                "required": [
                                  "key",
                                  "value"
                                ]
                              },
                              "default": [],
                              "description": "HTTP headers with optional encryption"
                            },
                            "body": {
                              "type": "object",
                              "additionalProperties": {
                                "nullable": true
                              },
                              "default": {},
                              "description": "Request body for POST/PUT requests"
                            },
                            "timeout": {
                              "type": "number",
                              "default": 30,
                              "description": "Request timeout in seconds"
                            },
                            "variables": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "str",
                                      "int",
                                      "float",
                                      "bool"
                                    ]
                                  },
                                  "description": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "required": {
                                    "type": "boolean",
                                    "default": false
                                  }
                                },
                                "required": [
                                  "name",
                                  "type"
                                ]
                              }
                            }
                          },
                          "required": [
                            "url",
                            "variables"
                          ]
                        },
                        "speech": {
                          "type": "string",
                          "nullable": true
                        },
                        "slug": {
                          "type": "string",
                          "pattern": "^[a-z0-9_]+$"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "notifyOnFailure",
                        "successStatusCodes",
                        "createdAt",
                        "updatedAt",
                        "structure",
                        "speech",
                        "slug"
                      ]
                    }
                  },
                  "required": [
                    "tool"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/{toolId}": {
      "get": {
        "tags": [
          "Tools"
        ],
        "summary": "Get tool details",
        "description": "Get a tool by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The ID of the tool to retrieve"
            },
            "required": true,
            "description": "The ID of the tool to retrieve",
            "name": "toolId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Tool retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tool": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "notifyOnFailure": {
                          "type": "boolean"
                        },
                        "successStatusCodes": {
                          "type": "array",
                          "items": {
                            "type": "integer",
                            "minimum": 100,
                            "maximum": 599
                          },
                          "minItems": 1
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "structure": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "The API endpoint URL"
                            },
                            "method": {
                              "type": "string",
                              "enum": [
                                "GET",
                                "POST",
                                "PATCH",
                                "PUT",
                                "DELETE"
                              ],
                              "default": "GET",
                              "description": "HTTP method (GET, POST, PATCH, PUT, DELETE)"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "value": {
                                    "type": "string"
                                  },
                                  "secure": {
                                    "type": "boolean",
                                    "default": false,
                                    "description": "If true, the value will be encrypted in the database"
                                  }
                                },
                                "required": [
                                  "key",
                                  "value"
                                ]
                              },
                              "default": [],
                              "description": "HTTP headers with optional encryption"
                            },
                            "body": {
                              "type": "object",
                              "additionalProperties": {
                                "nullable": true
                              },
                              "default": {},
                              "description": "Request body for POST/PUT requests"
                            },
                            "timeout": {
                              "type": "number",
                              "default": 30,
                              "description": "Request timeout in seconds"
                            },
                            "variables": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "str",
                                      "int",
                                      "float",
                                      "bool"
                                    ]
                                  },
                                  "description": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "required": {
                                    "type": "boolean",
                                    "default": false
                                  }
                                },
                                "required": [
                                  "name",
                                  "type"
                                ]
                              }
                            }
                          },
                          "required": [
                            "url",
                            "variables"
                          ]
                        },
                        "speech": {
                          "type": "string",
                          "nullable": true
                        },
                        "slug": {
                          "type": "string",
                          "pattern": "^[a-z0-9_]+$"
                        },
                        "organizationId": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "notifyOnFailure",
                        "successStatusCodes",
                        "createdAt",
                        "updatedAt",
                        "structure",
                        "speech",
                        "slug",
                        "organizationId"
                      ]
                    }
                  },
                  "required": [
                    "tool"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tools"
        ],
        "summary": "Delete tool",
        "description": "Delete a tool by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The ID of the tool to delete"
            },
            "required": true,
            "description": "The ID of the tool to delete",
            "name": "toolId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Tool deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Tool not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tools"
        ],
        "summary": "Update tool",
        "description": "Update an existing tool",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "toolId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "structure": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string",
                        "description": "The API endpoint URL"
                      },
                      "method": {
                        "type": "string",
                        "enum": [
                          "GET",
                          "POST",
                          "PATCH",
                          "PUT",
                          "DELETE"
                        ],
                        "default": "GET",
                        "description": "HTTP method (GET, POST, PATCH, PUT, DELETE)"
                      },
                      "headers": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "key": {
                              "type": "string",
                              "minLength": 1
                            },
                            "value": {
                              "type": "string"
                            },
                            "secure": {
                              "type": "boolean",
                              "default": false,
                              "description": "If true, the value will be encrypted in the database"
                            }
                          },
                          "required": [
                            "key",
                            "value"
                          ]
                        },
                        "default": [],
                        "description": "HTTP headers with optional encryption"
                      },
                      "body": {
                        "type": "object",
                        "additionalProperties": {
                          "nullable": true
                        },
                        "default": {},
                        "description": "Request body for POST/PUT requests"
                      },
                      "timeout": {
                        "type": "number",
                        "default": 30,
                        "description": "Request timeout in seconds"
                      },
                      "variables": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "str",
                                "int",
                                "float",
                                "bool"
                              ]
                            },
                            "description": {
                              "type": "string",
                              "nullable": true
                            },
                            "required": {
                              "type": "boolean",
                              "default": false
                            }
                          },
                          "required": [
                            "name",
                            "type"
                          ]
                        }
                      }
                    },
                    "required": [
                      "url",
                      "variables"
                    ]
                  },
                  "speech": {
                    "type": "string"
                  },
                  "notifyOnFailure": {
                    "type": "boolean"
                  },
                  "successStatusCodes": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "minimum": 100,
                      "maximum": 599
                    },
                    "minItems": 1
                  },
                  "slug": {
                    "type": "string",
                    "pattern": "^[a-z0-9_]+$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tool updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tool": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "notifyOnFailure": {
                          "type": "boolean"
                        },
                        "successStatusCodes": {
                          "type": "array",
                          "items": {
                            "type": "integer",
                            "minimum": 100,
                            "maximum": 599
                          },
                          "minItems": 1
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "structure": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "The API endpoint URL"
                            },
                            "method": {
                              "type": "string",
                              "enum": [
                                "GET",
                                "POST",
                                "PATCH",
                                "PUT",
                                "DELETE"
                              ],
                              "default": "GET",
                              "description": "HTTP method (GET, POST, PATCH, PUT, DELETE)"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "value": {
                                    "type": "string"
                                  },
                                  "secure": {
                                    "type": "boolean",
                                    "default": false,
                                    "description": "If true, the value will be encrypted in the database"
                                  }
                                },
                                "required": [
                                  "key",
                                  "value"
                                ]
                              },
                              "default": [],
                              "description": "HTTP headers with optional encryption"
                            },
                            "body": {
                              "type": "object",
                              "additionalProperties": {
                                "nullable": true
                              },
                              "default": {},
                              "description": "Request body for POST/PUT requests"
                            },
                            "timeout": {
                              "type": "number",
                              "default": 30,
                              "description": "Request timeout in seconds"
                            },
                            "variables": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "str",
                                      "int",
                                      "float",
                                      "bool"
                                    ]
                                  },
                                  "description": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "required": {
                                    "type": "boolean",
                                    "default": false
                                  }
                                },
                                "required": [
                                  "name",
                                  "type"
                                ]
                              }
                            }
                          },
                          "required": [
                            "url",
                            "variables"
                          ]
                        },
                        "speech": {
                          "type": "string",
                          "nullable": true
                        },
                        "slug": {
                          "type": "string",
                          "pattern": "^[a-z0-9_]+$"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "notifyOnFailure",
                        "successStatusCodes",
                        "createdAt",
                        "updatedAt",
                        "structure",
                        "speech",
                        "slug"
                      ]
                    }
                  },
                  "required": [
                    "tool"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/pre-built-tools": {
      "get": {
        "tags": [
          "Tools"
        ],
        "summary": "List pre-built tools",
        "description": "List all pre-built tools",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of tools retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tools": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "slug",
                          "name",
                          "description"
                        ]
                      }
                    }
                  },
                  "required": [
                    "tools"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/internal/tools/failure": {
      "post": {
        "tags": [
          "Tools Internal"
        ],
        "summary": "Ingest tool failure for alerting (all tool types)",
        "description": "Unified internal endpoint for agent runtimes to report tool failures (pre-built, integration, and custom). Sends Slack alerts. Replaces the legacy /api/v1/internal/custom-tools/result endpoint.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "organizationId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "agentCallId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "toolName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "toolType": {
                    "type": "string",
                    "enum": [
                      "pre_built",
                      "integration",
                      "custom"
                    ]
                  },
                  "errorMessage": {
                    "type": "string",
                    "nullable": true,
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "organizationId",
                  "agentCallId",
                  "toolName",
                  "toolType",
                  "occurredAt"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Result accepted for processing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "received": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "notified": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "received",
                    "notified"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 401
                    },
                    "message": {
                      "type": "string",
                      "default": "Unauthorized"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "UNAUTHORIZED"
                      ],
                      "default": "UNAUTHORIZED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{agentId}/versions/{versionId}/email-config": {
      "patch": {
        "tags": [
          "Agents"
        ],
        "summary": "Update agent version email configuration",
        "description": "Update the email-specific configuration for an agent version. The linked domain must be VERIFIED before it can be used.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "agentId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "versionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "emailDomainId": {
                    "type": "string",
                    "nullable": true,
                    "format": "uuid"
                  },
                  "emailFromLocalPart": {
                    "type": "string",
                    "nullable": true,
                    "minLength": 1,
                    "maxLength": 64,
                    "pattern": "^[a-zA-Z0-9._%+\\-]+$"
                  },
                  "emailFromName": {
                    "type": "string",
                    "nullable": true,
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "emailMaxTokens": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 8000
                  },
                  "emailTemperature": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 2
                  },
                  "emailInactivityTimeoutHours": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1
                  },
                  "emailFilteringEnabled": {
                    "type": "boolean"
                  },
                  "emailResponseMode": {
                    "type": "string",
                    "enum": [
                      "AUTO_SEND",
                      "SUGGEST_ONLY",
                      "CONFIDENCE_BASED"
                    ]
                  },
                  "emailConfidenceThreshold": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "emailReplyToAddress": {
                    "type": "string",
                    "nullable": true,
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Email configuration updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "agentId": {
                          "type": "string"
                        },
                        "version": {
                          "type": "number"
                        },
                        "emailDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailFromLocalPart": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailFromName": {
                          "type": "string",
                          "nullable": true
                        },
                        "emailMaxTokens": {
                          "type": "number"
                        },
                        "emailTemperature": {
                          "type": "number"
                        },
                        "emailInactivityTimeoutHours": {
                          "type": "number",
                          "nullable": true
                        },
                        "emailFilteringEnabled": {
                          "type": "boolean"
                        },
                        "emailResponseMode": {
                          "type": "string",
                          "enum": [
                            "AUTO_SEND",
                            "SUGGEST_ONLY",
                            "CONFIDENCE_BASED"
                          ]
                        },
                        "emailConfidenceThreshold": {
                          "type": "number"
                        },
                        "emailTags": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "autoClose": {
                                "type": "boolean"
                              },
                              "gmailLabelId": {
                                "type": "string"
                              },
                              "gmailLabelName": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "name",
                              "prompt",
                              "autoClose"
                            ]
                          }
                        },
                        "emailReplyToAddress": {
                          "type": "string",
                          "nullable": true
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "agentId",
                        "version",
                        "emailDomainId",
                        "emailFromLocalPart",
                        "emailFromName",
                        "emailMaxTokens",
                        "emailTemperature",
                        "emailInactivityTimeoutHours",
                        "emailFilteringEnabled",
                        "emailResponseMode",
                        "emailConfidenceThreshold",
                        "emailTags",
                        "emailReplyToAddress",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "version"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent version not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/threads": {
      "post": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Create a new SMS thread",
        "description": "Create a new SMS thread for text-based conversations",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentVersionId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "toPhoneNumber": {
                    "type": "string"
                  },
                  "fromPhoneNumber": {
                    "type": "string"
                  },
                  "fromPhoneNumberId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "initialMessage": {
                    "type": "string"
                  },
                  "leadId": {
                    "type": "string"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "agentVersionId",
                  "toPhoneNumber",
                  "fromPhoneNumber",
                  "fromPhoneNumberId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Thread created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "toPhoneNumber": {
                          "type": "string"
                        },
                        "fromPhoneNumber": {
                          "type": "string",
                          "nullable": true
                        },
                        "fromPhoneNumberId": {
                          "type": "string",
                          "nullable": true
                        },
                        "leadId": {
                          "type": "string",
                          "nullable": true
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "closedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "closedReason": {
                          "type": "string",
                          "nullable": true
                        },
                        "metadata": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "variables": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "agentVersionId",
                        "toPhoneNumber",
                        "fromPhoneNumber",
                        "fromPhoneNumberId",
                        "leadId",
                        "isActive",
                        "createdAt",
                        "updatedAt",
                        "closedAt",
                        "closedReason"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "List threads",
        "description": "List threads with cursor-based pagination and optional filters",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Number of items per page (default: 10, max: 100)",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Cursor for pagination (ID of the last item in previous page)",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "description": "Filter by agent ID",
            "name": "agentId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter by recipient phone number",
            "name": "toPhoneNumber",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Filter by active status",
            "name": "isActive",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "OPTED_OUT",
                "DNC",
                "FRAUD",
                "CONTACT_AGAIN",
                "WRONG_NUMBER",
                "NOT_INTERESTED",
                "APPOINTMENT_BOOKED",
                "ENDED",
                "WORKFLOW_ONE_OFF_TEXT",
                "FILTERED_SPAM",
                "FILTERED_OOO",
                "FILTERED_AUTO_REPLY"
              ]
            },
            "required": false,
            "description": "Filter by chat ended reason",
            "name": "chatEndedReason",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of threads",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "organizationId": {
                            "type": "string"
                          },
                          "agentVersionId": {
                            "type": "string"
                          },
                          "toPhoneNumber": {
                            "type": "string"
                          },
                          "fromPhoneNumber": {
                            "type": "string",
                            "nullable": true
                          },
                          "fromPhoneNumberId": {
                            "type": "string",
                            "nullable": true
                          },
                          "leadId": {
                            "type": "string",
                            "nullable": true
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "closedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "closedReason": {
                            "type": "string",
                            "nullable": true
                          },
                          "metadata": {
                            "type": "object",
                            "nullable": true,
                            "additionalProperties": {
                              "type": "string"
                            }
                          },
                          "variables": {
                            "type": "object",
                            "nullable": true,
                            "additionalProperties": {
                              "type": "string"
                            }
                          },
                          "agentId": {
                            "type": "string"
                          },
                          "agentName": {
                            "type": "string"
                          },
                          "agentDetails": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string",
                                "nullable": true
                              },
                              "agentType": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "description",
                              "agentType"
                            ]
                          },
                          "agentVersionDetails": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "version": {
                                "type": "number"
                              },
                              "name": {
                                "type": "string"
                              },
                              "mode": {
                                "type": "string",
                                "enum": [
                                  "FLOW",
                                  "PROMPT"
                                ]
                              },
                              "smsMaxTokens": {
                                "type": "number",
                                "nullable": true
                              },
                              "smsTemperature": {
                                "type": "number",
                                "nullable": true
                              },
                              "discardInboundSms": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "id",
                              "version",
                              "name",
                              "mode",
                              "smsMaxTokens",
                              "smsTemperature",
                              "discardInboundSms"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "agentVersionId",
                          "toPhoneNumber",
                          "fromPhoneNumber",
                          "fromPhoneNumberId",
                          "leadId",
                          "isActive",
                          "createdAt",
                          "updatedAt",
                          "closedAt",
                          "closedReason",
                          "agentId",
                          "agentName",
                          "agentDetails",
                          "agentVersionDetails"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "threads",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/threads/web": {
      "post": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Create a new web chat thread",
        "description": "Create a new web chat thread for server-side integrations. Use X-API-Key or Clerk auth.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "agentId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Web chat thread created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "toPhoneNumber": {
                          "type": "string"
                        },
                        "fromPhoneNumber": {
                          "type": "string",
                          "nullable": true
                        },
                        "fromPhoneNumberId": {
                          "type": "string",
                          "nullable": true
                        },
                        "leadId": {
                          "type": "string",
                          "nullable": true
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "closedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "closedReason": {
                          "type": "string",
                          "nullable": true
                        },
                        "metadata": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "variables": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "transcriptWithTools": {
                          "type": "string",
                          "nullable": true
                        },
                        "agentId": {
                          "type": "string"
                        },
                        "agentDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string",
                              "nullable": true
                            },
                            "agentType": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "description",
                            "agentType"
                          ]
                        },
                        "agentVersionDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "version": {
                              "type": "number"
                            },
                            "name": {
                              "type": "string"
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "FLOW",
                                "PROMPT"
                              ]
                            },
                            "smsMaxTokens": {
                              "type": "number",
                              "nullable": true
                            },
                            "smsTemperature": {
                              "type": "number",
                              "nullable": true
                            },
                            "discardInboundSms": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "version",
                            "name",
                            "mode",
                            "smsMaxTokens",
                            "smsTemperature",
                            "discardInboundSms"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "agentVersionId",
                        "toPhoneNumber",
                        "fromPhoneNumber",
                        "fromPhoneNumberId",
                        "leadId",
                        "isActive",
                        "createdAt",
                        "updatedAt",
                        "closedAt",
                        "closedReason",
                        "agentId",
                        "agentDetails",
                        "agentVersionDetails"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/threads/{threadId}": {
      "get": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Get a thread by ID",
        "description": "Get details of a specific thread",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Thread details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "toPhoneNumber": {
                          "type": "string"
                        },
                        "fromPhoneNumber": {
                          "type": "string",
                          "nullable": true
                        },
                        "fromPhoneNumberId": {
                          "type": "string",
                          "nullable": true
                        },
                        "leadId": {
                          "type": "string",
                          "nullable": true
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "closedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "closedReason": {
                          "type": "string",
                          "nullable": true
                        },
                        "metadata": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "variables": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "agentId": {
                          "type": "string"
                        },
                        "agentDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string",
                              "nullable": true
                            },
                            "agentType": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "description",
                            "agentType"
                          ]
                        },
                        "agentVersionDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "version": {
                              "type": "number"
                            },
                            "name": {
                              "type": "string"
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "FLOW",
                                "PROMPT"
                              ]
                            },
                            "smsMaxTokens": {
                              "type": "number",
                              "nullable": true
                            },
                            "smsTemperature": {
                              "type": "number",
                              "nullable": true
                            },
                            "discardInboundSms": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "version",
                            "name",
                            "mode",
                            "smsMaxTokens",
                            "smsTemperature",
                            "discardInboundSms"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "agentVersionId",
                        "toPhoneNumber",
                        "fromPhoneNumber",
                        "fromPhoneNumberId",
                        "leadId",
                        "isActive",
                        "createdAt",
                        "updatedAt",
                        "closedAt",
                        "closedReason",
                        "agentId",
                        "agentDetails",
                        "agentVersionDetails"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Update thread metadata",
        "description": "Merge metadata and/or variables on a thread",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated thread",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "toPhoneNumber": {
                          "type": "string"
                        },
                        "fromPhoneNumber": {
                          "type": "string",
                          "nullable": true
                        },
                        "fromPhoneNumberId": {
                          "type": "string",
                          "nullable": true
                        },
                        "leadId": {
                          "type": "string",
                          "nullable": true
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "closedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "closedReason": {
                          "type": "string",
                          "nullable": true
                        },
                        "metadata": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "variables": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "agentId": {
                          "type": "string"
                        },
                        "agentDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string",
                              "nullable": true
                            },
                            "agentType": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "description",
                            "agentType"
                          ]
                        },
                        "agentVersionDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "version": {
                              "type": "number"
                            },
                            "name": {
                              "type": "string"
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "FLOW",
                                "PROMPT"
                              ]
                            },
                            "smsMaxTokens": {
                              "type": "number",
                              "nullable": true
                            },
                            "smsTemperature": {
                              "type": "number",
                              "nullable": true
                            },
                            "discardInboundSms": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "version",
                            "name",
                            "mode",
                            "smsMaxTokens",
                            "smsTemperature",
                            "discardInboundSms"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "agentVersionId",
                        "toPhoneNumber",
                        "fromPhoneNumber",
                        "fromPhoneNumberId",
                        "leadId",
                        "isActive",
                        "createdAt",
                        "updatedAt",
                        "closedAt",
                        "closedReason",
                        "agentId",
                        "agentDetails",
                        "agentVersionDetails"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/threads/{threadId}/close": {
      "patch": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Close a thread",
        "description": "Close an active thread",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Thread closed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "toPhoneNumber": {
                          "type": "string"
                        },
                        "fromPhoneNumber": {
                          "type": "string",
                          "nullable": true
                        },
                        "fromPhoneNumberId": {
                          "type": "string",
                          "nullable": true
                        },
                        "leadId": {
                          "type": "string",
                          "nullable": true
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "closedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "closedReason": {
                          "type": "string",
                          "nullable": true
                        },
                        "metadata": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "variables": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "agentVersionId",
                        "toPhoneNumber",
                        "fromPhoneNumber",
                        "fromPhoneNumberId",
                        "leadId",
                        "isActive",
                        "createdAt",
                        "updatedAt",
                        "closedAt",
                        "closedReason"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/threads/{threadId}/messages": {
      "get": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Get messages for a thread",
        "description": "Get messages for a specific thread with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Number of messages per page (default: 50, max: 100)",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Cursor for pagination (ID of the last message in previous page)",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "INBOUND",
                "OUTBOUND"
              ]
            },
            "required": false,
            "description": "Filter by message direction (INBOUND or OUTBOUND)",
            "name": "direction",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "QUEUED",
                "SENDING",
                "SENT",
                "DELIVERED",
                "FAILED",
                "UNDELIVERED",
                "READ",
                "RECEIVED",
                "DISCARDED"
              ]
            },
            "required": false,
            "description": "Filter by message status",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Thread messages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "agentId": {
                          "type": "string"
                        },
                        "agentDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string",
                              "nullable": true
                            },
                            "agentType": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "description",
                            "agentType"
                          ]
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "agentVersionDetails": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "version": {
                              "type": "number"
                            },
                            "name": {
                              "type": "string"
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "FLOW",
                                "PROMPT"
                              ]
                            },
                            "smsMaxTokens": {
                              "type": "number",
                              "nullable": true
                            },
                            "smsTemperature": {
                              "type": "number",
                              "nullable": true
                            },
                            "discardInboundSms": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "version",
                            "name",
                            "mode",
                            "smsMaxTokens",
                            "smsTemperature",
                            "discardInboundSms"
                          ]
                        },
                        "messages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "threadId": {
                                "type": "string"
                              },
                              "direction": {
                                "type": "string",
                                "enum": [
                                  "INBOUND",
                                  "OUTBOUND"
                                ]
                              },
                              "messageBody": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "QUEUED",
                                  "SENDING",
                                  "SENT",
                                  "DELIVERED",
                                  "FAILED",
                                  "UNDELIVERED",
                                  "READ",
                                  "RECEIVED",
                                  "DISCARDED"
                                ]
                              },
                              "twilioMessageSid": {
                                "type": "string",
                                "nullable": true
                              },
                              "twilioAccountSid": {
                                "type": "string",
                                "nullable": true
                              },
                              "twilioNumSegments": {
                                "type": "number",
                                "nullable": true
                              },
                              "twilioPrice": {
                                "type": "string",
                                "nullable": true
                              },
                              "twilioPriceCurrency": {
                                "type": "string",
                                "nullable": true
                              },
                              "twilioErrorCode": {
                                "type": "string",
                                "nullable": true
                              },
                              "twilioErrorMessage": {
                                "type": "string",
                                "nullable": true
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              },
                              "sentAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "deliveredAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "readAt": {
                                "type": "string",
                                "nullable": true
                              }
                            },
                            "required": [
                              "id",
                              "threadId",
                              "direction",
                              "messageBody",
                              "status",
                              "twilioMessageSid",
                              "twilioAccountSid",
                              "twilioNumSegments",
                              "twilioPrice",
                              "twilioPriceCurrency",
                              "twilioErrorCode",
                              "twilioErrorMessage",
                              "createdAt",
                              "updatedAt",
                              "sentAt",
                              "deliveredAt",
                              "readAt"
                            ]
                          }
                        },
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "limit": {
                              "type": "number",
                              "minimum": 1,
                              "maximum": 100,
                              "default": 10
                            },
                            "nextCursor": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "required": [
                        "agentId",
                        "agentDetails",
                        "agentVersionId",
                        "agentVersionDetails",
                        "messages",
                        "pagination"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Send a message to a web chat thread",
        "description": "Send an inbound user message to a web chat thread. Agent replies are delivered via SSE or polling.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "message"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message accepted for processing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "threadId": {
                      "type": "string"
                    },
                    "messageId": {
                      "type": "string"
                    },
                    "windowExpiresIn": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status",
                    "threadId",
                    "messageId",
                    "windowExpiresIn"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 403
                    },
                    "message": {
                      "type": "string",
                      "default": "Forbidden"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "FORBIDDEN"
                      ],
                      "default": "FORBIDDEN"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/threads/{threadId}/stream": {
      "get": {
        "tags": [
          "SMS Threads"
        ],
        "summary": "Stream new web chat thread messages",
        "description": "Server-Sent Events stream for new outbound agent messages on a web chat thread. Load history separately via GET /api/v1/threads/{threadId}/messages.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "SSE stream of new agent messages",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 403
                    },
                    "message": {
                      "type": "string",
                      "default": "Forbidden"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "FORBIDDEN"
                      ],
                      "default": "FORBIDDEN"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/threads": {
      "post": {
        "tags": [
          "Chat"
        ],
        "summary": "Create a new web chat thread",
        "description": "Create a new chat thread for web-based conversations. Returns thread ID and authentication token.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "agentVersionId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "agentId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat thread created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threadId": {
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "threadId",
                    "token"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Domain not authorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 403
                    },
                    "message": {
                      "type": "string",
                      "default": "Forbidden"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "FORBIDDEN"
                      ],
                      "default": "FORBIDDEN"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded"
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/threads/{threadId}": {
      "get": {
        "tags": [
          "Chat"
        ],
        "summary": "Get web chat thread session details",
        "description": "Get session metadata for a web chat thread. Requires chat JWT authentication.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Chat thread session details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "threadId": {
                          "type": "string"
                        },
                        "metadata": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "variables": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "threadId",
                        "isActive",
                        "createdAt",
                        "lastActivityAt"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 403
                    },
                    "message": {
                      "type": "string",
                      "default": "Forbidden"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "FORBIDDEN"
                      ],
                      "default": "FORBIDDEN"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Chat"
        ],
        "summary": "Update web chat thread session metadata",
        "description": "Merge metadata and/or variables on a web chat thread. Requires chat JWT authentication.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated chat thread session",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "threadId": {
                          "type": "string"
                        },
                        "metadata": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "variables": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "threadId",
                        "isActive",
                        "createdAt",
                        "lastActivityAt"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 403
                    },
                    "message": {
                      "type": "string",
                      "default": "Forbidden"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "FORBIDDEN"
                      ],
                      "default": "FORBIDDEN"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/threads/{threadId}/messages": {
      "get": {
        "tags": [
          "Chat"
        ],
        "summary": "Get messages for a web chat thread",
        "description": "Get paginated message history for a web chat thread. Requires chat JWT authentication.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Number of messages per page (default: 50, max: 100)",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Cursor for pagination (createdAt_id of the last message)",
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Chat thread messages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "direction": {
                            "type": "string",
                            "enum": [
                              "INBOUND",
                              "OUTBOUND"
                            ]
                          },
                          "messageBody": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "QUEUED",
                              "SENDING",
                              "SENT",
                              "DELIVERED",
                              "FAILED",
                              "UNDELIVERED",
                              "READ",
                              "RECEIVED",
                              "DISCARDED"
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "source": {
                            "type": "array",
                            "nullable": true,
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "id",
                          "direction",
                          "messageBody",
                          "status",
                          "createdAt",
                          "source"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "messages",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 403
                    },
                    "message": {
                      "type": "string",
                      "default": "Forbidden"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "FORBIDDEN"
                      ],
                      "default": "FORBIDDEN"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dnc": {
      "post": {
        "tags": [
          "DNC"
        ],
        "summary": "Add phone number to DNC list",
        "description": "Add a phone number to the Do Not Call block list",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "string",
                    "pattern": "^\\+\\d{10,15}$"
                  }
                },
                "required": [
                  "phoneNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Phone number added to DNC list successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dncEntry": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "phoneNumber": {
                          "type": "string"
                        },
                        "callId": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "phoneNumber",
                        "callId",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "dncEntry"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Phone number already exists in DNC list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "DNC"
        ],
        "summary": "List DNC entries",
        "description": "List all DNC entries with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of DNC entries retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dncEntries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "organizationId": {
                            "type": "string"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "callId": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "phoneNumber",
                          "callId",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "dncEntries",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dnc/{id}": {
      "get": {
        "tags": [
          "DNC"
        ],
        "summary": "Get DNC entry by ID",
        "description": "Get a DNC entry by its ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The ID of the DNC entry"
            },
            "required": true,
            "description": "The ID of the DNC entry",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "DNC entry retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dncEntry": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "phoneNumber": {
                          "type": "string"
                        },
                        "callId": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "phoneNumber",
                        "callId",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "dncEntry"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "DNC entry not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "DNC"
        ],
        "summary": "Delete DNC entry by ID",
        "description": "Remove a phone number from the DNC block list by entry ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The ID of the DNC entry to delete"
            },
            "required": true,
            "description": "The ID of the DNC entry to delete",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "DNC entry deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "DNC entry not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dnc/phone/{phoneNumber}": {
      "get": {
        "tags": [
          "DNC"
        ],
        "summary": "Get DNC entry by phone number",
        "description": "Get a DNC entry by phone number (URL encoded, e.g., %2B14155551234)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The phone number (URL encoded)"
            },
            "required": true,
            "description": "The phone number (URL encoded)",
            "name": "phoneNumber",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "DNC entry retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dncEntry": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "phoneNumber": {
                          "type": "string"
                        },
                        "callId": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "phoneNumber",
                        "callId",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "dncEntry"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "DNC entry not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "DNC"
        ],
        "summary": "Delete DNC entry by phone number",
        "description": "Remove a phone number from the DNC block list by phone number (URL encoded, e.g., %2B14155551234)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The phone number (URL encoded)"
            },
            "required": true,
            "description": "The phone number (URL encoded)",
            "name": "phoneNumber",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "DNC entry deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "DNC entry not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dnc/check/{phoneNumber}": {
      "get": {
        "tags": [
          "DNC"
        ],
        "summary": "Check if phone number is on DNC list",
        "description": "Check if a phone number is on the DNC block list (URL encoded, e.g., %2B14155551234)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "The phone number to check (URL encoded)"
            },
            "required": true,
            "description": "The phone number to check (URL encoded)",
            "name": "phoneNumber",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "DNC check completed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "blocked": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "blocked"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/squads": {
      "get": {
        "tags": [
          "Squad"
        ],
        "summary": "List all squads for an organization",
        "description": "Get a paginated list of squads with transfer rule counts",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "archived",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of squads retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "squads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "organizationId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string",
                            "nullable": true
                          },
                          "entrypointAgentId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "entrypointAgent": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": "string"
                              },
                              "agentType": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "agentType"
                            ]
                          },
                          "archived": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "_count": {
                            "type": "object",
                            "properties": {
                              "transferRules": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "transferRules"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "name",
                          "description",
                          "entrypointAgentId",
                          "archived",
                          "createdAt",
                          "updatedAt",
                          "_count"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "squads",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Squad"
        ],
        "summary": "Create a new squad",
        "description": "Create a new squad configuration with an entrypoint agent",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "entrypointAgentId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "name",
                  "entrypointAgentId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Squad created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "squad": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "entrypointAgentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "entrypointAgent": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "agentType": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "agentType"
                          ]
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "name",
                        "description",
                        "entrypointAgentId",
                        "archived",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "squad"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Entrypoint agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/squads/{squadId}": {
      "get": {
        "tags": [
          "Squad"
        ],
        "summary": "Get squad details",
        "description": "Get detailed squad configuration including entrypoint agent, transfer rules, phone numbers, member agents, and basic stats",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Squad retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "squad": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "entrypointAgentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "entrypointAgent": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "agentType": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ]
                            },
                            "description": {
                              "type": "string",
                              "nullable": true
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "agentType",
                            "description"
                          ]
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "transferRules": {
                          "type": "array",
                          "items": {
                            "nullable": true
                          }
                        },
                        "phoneNumbers": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "phoneNumber": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "phoneNumber"
                            ]
                          }
                        },
                        "memberAgents": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": "string"
                              },
                              "agentType": {
                                "type": "string",
                                "enum": [
                                  "CALL",
                                  "TEXT"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "agentType"
                            ]
                          }
                        },
                        "stats": {
                          "type": "object",
                          "properties": {
                            "totalCalls": {
                              "type": "number"
                            },
                            "totalTransfers": {
                              "type": "number"
                            },
                            "avgCallDuration": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "totalCalls",
                            "totalTransfers",
                            "avgCallDuration"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "name",
                        "description",
                        "entrypointAgentId",
                        "entrypointAgent",
                        "archived",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "squad"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Squad not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Squad"
        ],
        "summary": "Update squad",
        "description": "Update squad name, description, entrypoint agent, or archived status",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "entrypointAgentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "archived": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Squad updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "squad": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "entrypointAgentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "entrypointAgent": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "agentType": {
                              "type": "string",
                              "enum": [
                                "CALL",
                                "TEXT"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "agentType"
                          ]
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "name",
                        "description",
                        "entrypointAgentId",
                        "archived",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "squad"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Squad or entrypoint agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Squad"
        ],
        "summary": "Delete squad",
        "description": "Soft delete squad by setting archived=true",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Squad deleted successfully"
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Squad not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/squads/{squadId}/dispatch": {
      "post": {
        "tags": [
          "Squad"
        ],
        "summary": "Dispatch squad",
        "description": "Create a new dispatch for a squad, resolving the entrypoint agent internally",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "versionId": {
                    "type": "string"
                  },
                  "outboundPhoneNumberId": {
                    "type": "string"
                  },
                  "leadId": {
                    "type": "string"
                  },
                  "toPhoneNumber": {
                    "type": "string",
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "audio",
                      "web"
                    ],
                    "default": "audio"
                  },
                  "zipcode": {
                    "type": "string",
                    "nullable": true,
                    "pattern": "^\\d{5}(-?\\d{4})?$"
                  },
                  "customer": {
                    "type": "object",
                    "properties": {
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "firstName"
                    ]
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "forwardingNumber": {
                    "type": "string",
                    "pattern": "^\\+1(\\d{10}|\\d{3}-\\d{3}-\\d{4})|^\\+[1-9]\\d{1,14}$"
                  }
                },
                "required": [
                  "leadId",
                  "firstName"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Squad dispatch created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued"
                      ]
                    },
                    "connectionDetails": {
                      "$ref": "#/components/schemas/WebDispatchConnectionDetails"
                    }
                  },
                  "required": [
                    "id",
                    "status"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Insufficient credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 402
                    },
                    "message": {
                      "type": "string",
                      "default": "Insufficient credits"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "PAYMENT_REQUIRED"
                      ],
                      "default": "PAYMENT_REQUIRED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/squads/{squadId}/transfer-rules": {
      "get": {
        "tags": [
          "Squad"
        ],
        "summary": "List transfer rules",
        "description": "Get all transfer rules for a squad with optional filters",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "fromAgentId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer rules retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transferRules": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "squadId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "fromAgentId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "fromAgent": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "name"
                            ]
                          },
                          "toAgentId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "toAgent": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "name": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "name"
                            ]
                          },
                          "allowManualTrigger": {
                            "type": "boolean"
                          },
                          "toolDescription": {
                            "type": "string",
                            "nullable": true
                          },
                          "variables": {
                            "type": "array",
                            "nullable": true,
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "description": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "required": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "name",
                                "description",
                                "required"
                              ]
                            }
                          },
                          "speakBeforeTransfer": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "squadId",
                          "fromAgentId",
                          "toAgentId",
                          "allowManualTrigger",
                          "toolDescription",
                          "variables",
                          "speakBeforeTransfer",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "transferRules"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Squad not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Squad"
        ],
        "summary": "Create transfer rule",
        "description": "Create a new transfer rule between two agents in a squad",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fromAgentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "toAgentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "allowManualTrigger": {
                    "type": "boolean",
                    "default": true
                  },
                  "toolDescription": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "variables": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1
                        },
                        "required": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "name",
                        "description",
                        "required"
                      ]
                    }
                  },
                  "speakBeforeTransfer": {
                    "type": "string"
                  }
                },
                "required": [
                  "fromAgentId",
                  "toAgentId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Transfer rule created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transferRule": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "squadId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "fromAgentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "fromAgent": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name"
                          ]
                        },
                        "toAgentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "toAgent": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name"
                          ]
                        },
                        "allowManualTrigger": {
                          "type": "boolean"
                        },
                        "toolDescription": {
                          "type": "string",
                          "nullable": true
                        },
                        "variables": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "minLength": 1
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1
                              },
                              "required": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "name",
                              "description",
                              "required"
                            ]
                          }
                        },
                        "speakBeforeTransfer": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "squadId",
                        "fromAgentId",
                        "toAgentId",
                        "allowManualTrigger",
                        "toolDescription",
                        "variables",
                        "speakBeforeTransfer",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "transferRule"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Squad or agent not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/squads/{squadId}/transfer-rules/{ruleId}": {
      "patch": {
        "tags": [
          "Squad"
        ],
        "summary": "Update transfer rule",
        "description": "Update an existing transfer rule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "ruleId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "allowManualTrigger": {
                    "type": "boolean"
                  },
                  "toolDescription": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "variables": {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1
                        },
                        "required": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "name",
                        "description",
                        "required"
                      ]
                    }
                  },
                  "speakBeforeTransfer": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transfer rule updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transferRule": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "squadId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "fromAgentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "fromAgent": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name"
                          ]
                        },
                        "toAgentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "toAgent": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name"
                          ]
                        },
                        "allowManualTrigger": {
                          "type": "boolean"
                        },
                        "toolDescription": {
                          "type": "string",
                          "nullable": true
                        },
                        "variables": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "minLength": 1
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1
                              },
                              "required": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "name",
                              "description",
                              "required"
                            ]
                          }
                        },
                        "speakBeforeTransfer": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "squadId",
                        "fromAgentId",
                        "toAgentId",
                        "allowManualTrigger",
                        "toolDescription",
                        "variables",
                        "speakBeforeTransfer",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "transferRule"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Transfer rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Squad"
        ],
        "summary": "Delete transfer rule",
        "description": "Hard delete a transfer rule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "squadId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "ruleId",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Transfer rule deleted successfully"
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Transfer rule not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports": {
      "post": {
        "tags": [
          "Reports"
        ],
        "summary": "Create a new report generation job",
        "description": "Creates a new report generation job for exporting AgentCalls data. The report is generated asynchronously.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filters": {
                    "type": "object",
                    "properties": {
                      "callEndedReasons": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "COULD_NOT_CONNECT",
                            "NO_ANSWER",
                            "LEFT_VOICEMAIL",
                            "VOICEMAIL_DETECTED",
                            "SILENCE_TIMEOUT",
                            "BAD_NUMBER",
                            "NOT_INTERESTED",
                            "WARM_TRANSFER",
                            "WARM_TRANSFER_FAILED",
                            "CALENDLY",
                            "DNC",
                            "ENDED",
                            "FRAUD",
                            "LINE_BUSY",
                            "TEXT_CONSENT",
                            "CALL_AGAIN"
                          ]
                        }
                      },
                      "startCallStartedAt": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "endCallStartedAt": {
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "default": {}
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Report generation job created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "organizationId": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "PENDING",
                        "PROCESSING",
                        "COMPLETED",
                        "FAILED"
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "AGENT_CALLS"
                      ]
                    },
                    "filters": {
                      "type": "object",
                      "properties": {
                        "callEndedReasons": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "COULD_NOT_CONNECT",
                              "NO_ANSWER",
                              "LEFT_VOICEMAIL",
                              "VOICEMAIL_DETECTED",
                              "SILENCE_TIMEOUT",
                              "BAD_NUMBER",
                              "NOT_INTERESTED",
                              "WARM_TRANSFER",
                              "WARM_TRANSFER_FAILED",
                              "CALENDLY",
                              "DNC",
                              "ENDED",
                              "FRAUD",
                              "LINE_BUSY",
                              "TEXT_CONSENT",
                              "CALL_AGAIN"
                            ]
                          }
                        },
                        "startCallStartedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endCallStartedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    "fileKey": {
                      "type": "string",
                      "nullable": true
                    },
                    "rowCount": {
                      "type": "number",
                      "nullable": true
                    },
                    "errorMessage": {
                      "type": "string",
                      "nullable": true
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "completedAt": {
                      "type": "string",
                      "nullable": true
                    }
                  },
                  "required": [
                    "id",
                    "organizationId",
                    "status",
                    "type",
                    "filters",
                    "fileKey",
                    "rowCount",
                    "errorMessage",
                    "createdAt",
                    "updatedAt",
                    "completedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "List generated reports",
        "description": "List all reports for the organization with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Number of items per page (default: 10, max: 100)",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "Cursor for pagination (ID of the last item in previous page)",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "PROCESSING",
                "COMPLETED",
                "FAILED"
              ]
            },
            "required": false,
            "description": "Filter by report status",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Reports retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "reports": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "organizationId": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "PROCESSING",
                              "COMPLETED",
                              "FAILED"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "AGENT_CALLS"
                            ]
                          },
                          "filters": {
                            "type": "object",
                            "properties": {
                              "callEndedReasons": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "enum": [
                                    "COULD_NOT_CONNECT",
                                    "NO_ANSWER",
                                    "LEFT_VOICEMAIL",
                                    "VOICEMAIL_DETECTED",
                                    "SILENCE_TIMEOUT",
                                    "BAD_NUMBER",
                                    "NOT_INTERESTED",
                                    "WARM_TRANSFER",
                                    "WARM_TRANSFER_FAILED",
                                    "CALENDLY",
                                    "DNC",
                                    "ENDED",
                                    "FRAUD",
                                    "LINE_BUSY",
                                    "TEXT_CONSENT",
                                    "CALL_AGAIN"
                                  ]
                                }
                              },
                              "startCallStartedAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "endCallStartedAt": {
                                "type": "string",
                                "format": "date-time"
                              }
                            }
                          },
                          "fileKey": {
                            "type": "string",
                            "nullable": true
                          },
                          "rowCount": {
                            "type": "number",
                            "nullable": true
                          },
                          "errorMessage": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "completedAt": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "status",
                          "type",
                          "filters",
                          "fileKey",
                          "rowCount",
                          "errorMessage",
                          "createdAt",
                          "updatedAt",
                          "completedAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "reports",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/{reportId}/download": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Get download URL for a report",
        "description": "Get a presigned URL to download a completed report",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": "The report ID",
            "name": "reportId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Download URL generated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "downloadUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "fileName": {
                      "type": "string"
                    },
                    "expiresIn": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "downloadUrl",
                    "fileName",
                    "expiresIn"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Report not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email-domains": {
      "post": {
        "tags": [
          "Email Domains"
        ],
        "summary": "Create an email domain",
        "description": "Register a new subdomain with Resend and return the DNS records the customer must add to their DNS provider.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subdomain": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 63,
                    "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$"
                  },
                  "domain": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-.]+\\.[a-zA-Z]{2,}$"
                  },
                  "sendFromDomain": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-.]+\\.[a-zA-Z]{2,}$"
                  }
                },
                "required": [
                  "subdomain",
                  "domain"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Email domain created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailDomain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "subdomain": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "fullDomain": {
                          "type": "string"
                        },
                        "emailProvider": {
                          "type": "string",
                          "enum": [
                            "RESEND",
                            "GMAIL",
                            "SENDGRID"
                          ]
                        },
                        "providerDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "gmailConnectionId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridIntegrationId": {
                          "type": "string",
                          "nullable": true,
                          "format": "uuid"
                        },
                        "inboundWebhookUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridSendFromEmail": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "spfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "spfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "mxVerified": {
                          "type": "boolean"
                        },
                        "spfVerified": {
                          "type": "boolean"
                        },
                        "dkimVerified": {
                          "type": "boolean"
                        },
                        "cnameVerified": {
                          "type": "boolean"
                        },
                        "sendFromDomain": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromVerified": {
                          "type": "boolean"
                        },
                        "sendFromMxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromMxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromSpfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromSpfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromMxVerified": {
                          "type": "boolean"
                        },
                        "sendFromSpfVerified": {
                          "type": "boolean"
                        },
                        "sendFromDkimVerified": {
                          "type": "boolean"
                        },
                        "sendFromCnameVerified": {
                          "type": "boolean"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "PENDING",
                            "VERIFYING",
                            "VERIFIED",
                            "FAILED",
                            "SUSPENDED"
                          ]
                        },
                        "verifiedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "lastCheckedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "subdomain",
                        "domain",
                        "fullDomain",
                        "emailProvider",
                        "providerDomainId",
                        "gmailConnectionId",
                        "sendGridIntegrationId",
                        "inboundWebhookUrl",
                        "mxRecord",
                        "mxPriority",
                        "spfHostname",
                        "spfValue",
                        "dkimSelector",
                        "dkimHostname",
                        "dkimValue",
                        "cnameValue",
                        "cnamePriority",
                        "mxVerified",
                        "spfVerified",
                        "dkimVerified",
                        "cnameVerified",
                        "sendFromDomain",
                        "sendFromDomainId",
                        "sendFromVerified",
                        "sendFromMxRecord",
                        "sendFromMxPriority",
                        "sendFromSpfHostname",
                        "sendFromSpfValue",
                        "sendFromDkimSelector",
                        "sendFromDkimHostname",
                        "sendFromDkimValue",
                        "sendFromCnameValue",
                        "sendFromCnamePriority",
                        "sendFromMxVerified",
                        "sendFromSpfVerified",
                        "sendFromDkimVerified",
                        "sendFromCnameVerified",
                        "status",
                        "verifiedAt",
                        "lastCheckedAt",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "emailDomain"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Email Domains"
        ],
        "summary": "List email domains",
        "description": "List all email domains for the organization",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "VERIFYING",
                "VERIFIED",
                "FAILED",
                "SUSPENDED"
              ]
            },
            "required": false,
            "description": "Filter by status",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of email domains",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailDomains": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "organizationId": {
                            "type": "string"
                          },
                          "subdomain": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "fullDomain": {
                            "type": "string"
                          },
                          "emailProvider": {
                            "type": "string",
                            "enum": [
                              "RESEND",
                              "GMAIL",
                              "SENDGRID"
                            ]
                          },
                          "providerDomainId": {
                            "type": "string",
                            "nullable": true
                          },
                          "gmailConnectionId": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendGridIntegrationId": {
                            "type": "string",
                            "nullable": true,
                            "format": "uuid"
                          },
                          "inboundWebhookUrl": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendGridSendFromEmail": {
                            "type": "string",
                            "nullable": true
                          },
                          "mxRecord": {
                            "type": "string",
                            "nullable": true
                          },
                          "mxPriority": {
                            "type": "integer",
                            "nullable": true
                          },
                          "spfHostname": {
                            "type": "string",
                            "nullable": true
                          },
                          "spfValue": {
                            "type": "string",
                            "nullable": true
                          },
                          "dkimSelector": {
                            "type": "string",
                            "nullable": true
                          },
                          "dkimHostname": {
                            "type": "string",
                            "nullable": true
                          },
                          "dkimValue": {
                            "type": "string",
                            "nullable": true
                          },
                          "cnameValue": {
                            "type": "string",
                            "nullable": true
                          },
                          "cnamePriority": {
                            "type": "integer",
                            "nullable": true
                          },
                          "mxVerified": {
                            "type": "boolean"
                          },
                          "spfVerified": {
                            "type": "boolean"
                          },
                          "dkimVerified": {
                            "type": "boolean"
                          },
                          "cnameVerified": {
                            "type": "boolean"
                          },
                          "sendFromDomain": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromDomainId": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromVerified": {
                            "type": "boolean"
                          },
                          "sendFromMxRecord": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromMxPriority": {
                            "type": "integer",
                            "nullable": true
                          },
                          "sendFromSpfHostname": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromSpfValue": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromDkimSelector": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromDkimHostname": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromDkimValue": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromCnameValue": {
                            "type": "string",
                            "nullable": true
                          },
                          "sendFromCnamePriority": {
                            "type": "integer",
                            "nullable": true
                          },
                          "sendFromMxVerified": {
                            "type": "boolean"
                          },
                          "sendFromSpfVerified": {
                            "type": "boolean"
                          },
                          "sendFromDkimVerified": {
                            "type": "boolean"
                          },
                          "sendFromCnameVerified": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "VERIFYING",
                              "VERIFIED",
                              "FAILED",
                              "SUSPENDED"
                            ]
                          },
                          "verifiedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "lastCheckedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "subdomain",
                          "domain",
                          "fullDomain",
                          "emailProvider",
                          "providerDomainId",
                          "gmailConnectionId",
                          "sendGridIntegrationId",
                          "inboundWebhookUrl",
                          "mxRecord",
                          "mxPriority",
                          "spfHostname",
                          "spfValue",
                          "dkimSelector",
                          "dkimHostname",
                          "dkimValue",
                          "cnameValue",
                          "cnamePriority",
                          "mxVerified",
                          "spfVerified",
                          "dkimVerified",
                          "cnameVerified",
                          "sendFromDomain",
                          "sendFromDomainId",
                          "sendFromVerified",
                          "sendFromMxRecord",
                          "sendFromMxPriority",
                          "sendFromSpfHostname",
                          "sendFromSpfValue",
                          "sendFromDkimSelector",
                          "sendFromDkimHostname",
                          "sendFromDkimValue",
                          "sendFromCnameValue",
                          "sendFromCnamePriority",
                          "sendFromMxVerified",
                          "sendFromSpfVerified",
                          "sendFromDkimVerified",
                          "sendFromCnameVerified",
                          "status",
                          "verifiedAt",
                          "lastCheckedAt",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "emailDomains"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email-domains/gmail": {
      "post": {
        "tags": [
          "Email Domains"
        ],
        "summary": "Create a Gmail-backed email domain",
        "description": "Link a connected Gmail account as an email domain. No DNS setup required — the agent reads and sends via the Gmail API.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gmailConnectionId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "gmailConnectionId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Gmail email domain created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailDomain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "subdomain": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "fullDomain": {
                          "type": "string"
                        },
                        "emailProvider": {
                          "type": "string",
                          "enum": [
                            "RESEND",
                            "GMAIL",
                            "SENDGRID"
                          ]
                        },
                        "providerDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "gmailConnectionId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridIntegrationId": {
                          "type": "string",
                          "nullable": true,
                          "format": "uuid"
                        },
                        "inboundWebhookUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridSendFromEmail": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "spfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "spfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "mxVerified": {
                          "type": "boolean"
                        },
                        "spfVerified": {
                          "type": "boolean"
                        },
                        "dkimVerified": {
                          "type": "boolean"
                        },
                        "cnameVerified": {
                          "type": "boolean"
                        },
                        "sendFromDomain": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromVerified": {
                          "type": "boolean"
                        },
                        "sendFromMxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromMxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromSpfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromSpfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromMxVerified": {
                          "type": "boolean"
                        },
                        "sendFromSpfVerified": {
                          "type": "boolean"
                        },
                        "sendFromDkimVerified": {
                          "type": "boolean"
                        },
                        "sendFromCnameVerified": {
                          "type": "boolean"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "PENDING",
                            "VERIFYING",
                            "VERIFIED",
                            "FAILED",
                            "SUSPENDED"
                          ]
                        },
                        "verifiedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "lastCheckedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "subdomain",
                        "domain",
                        "fullDomain",
                        "emailProvider",
                        "providerDomainId",
                        "gmailConnectionId",
                        "sendGridIntegrationId",
                        "inboundWebhookUrl",
                        "mxRecord",
                        "mxPriority",
                        "spfHostname",
                        "spfValue",
                        "dkimSelector",
                        "dkimHostname",
                        "dkimValue",
                        "cnameValue",
                        "cnamePriority",
                        "mxVerified",
                        "spfVerified",
                        "dkimVerified",
                        "cnameVerified",
                        "sendFromDomain",
                        "sendFromDomainId",
                        "sendFromVerified",
                        "sendFromMxRecord",
                        "sendFromMxPriority",
                        "sendFromSpfHostname",
                        "sendFromSpfValue",
                        "sendFromDkimSelector",
                        "sendFromDkimHostname",
                        "sendFromDkimValue",
                        "sendFromCnameValue",
                        "sendFromCnamePriority",
                        "sendFromMxVerified",
                        "sendFromSpfVerified",
                        "sendFromDkimVerified",
                        "sendFromCnameVerified",
                        "status",
                        "verifiedAt",
                        "lastCheckedAt",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "emailDomain"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email-domains/sendgrid": {
      "post": {
        "tags": [
          "Email Domains"
        ],
        "summary": "Create SendGrid email integration",
        "description": "Store SendGrid API credentials and create a verified email domain. Assign the domain to an agent under Agent Builder → Email Settings. Returns the inbound webhook URL for SendGrid Inbound Parse.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "inboundEmail": {
                    "type": "string",
                    "format": "email"
                  },
                  "sendFromEmail": {
                    "type": "string",
                    "format": "email"
                  },
                  "sendgridApiKey": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "inboundEmail",
                  "sendFromEmail",
                  "sendgridApiKey"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "SendGrid integration created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailDomain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "subdomain": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "fullDomain": {
                          "type": "string"
                        },
                        "emailProvider": {
                          "type": "string",
                          "enum": [
                            "RESEND",
                            "GMAIL",
                            "SENDGRID"
                          ]
                        },
                        "providerDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "gmailConnectionId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridIntegrationId": {
                          "type": "string",
                          "nullable": true,
                          "format": "uuid"
                        },
                        "inboundWebhookUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridSendFromEmail": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "spfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "spfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "mxVerified": {
                          "type": "boolean"
                        },
                        "spfVerified": {
                          "type": "boolean"
                        },
                        "dkimVerified": {
                          "type": "boolean"
                        },
                        "cnameVerified": {
                          "type": "boolean"
                        },
                        "sendFromDomain": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromVerified": {
                          "type": "boolean"
                        },
                        "sendFromMxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromMxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromSpfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromSpfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromMxVerified": {
                          "type": "boolean"
                        },
                        "sendFromSpfVerified": {
                          "type": "boolean"
                        },
                        "sendFromDkimVerified": {
                          "type": "boolean"
                        },
                        "sendFromCnameVerified": {
                          "type": "boolean"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "PENDING",
                            "VERIFYING",
                            "VERIFIED",
                            "FAILED",
                            "SUSPENDED"
                          ]
                        },
                        "verifiedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "lastCheckedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "subdomain",
                        "domain",
                        "fullDomain",
                        "emailProvider",
                        "providerDomainId",
                        "gmailConnectionId",
                        "sendGridIntegrationId",
                        "inboundWebhookUrl",
                        "mxRecord",
                        "mxPriority",
                        "spfHostname",
                        "spfValue",
                        "dkimSelector",
                        "dkimHostname",
                        "dkimValue",
                        "cnameValue",
                        "cnamePriority",
                        "mxVerified",
                        "spfVerified",
                        "dkimVerified",
                        "cnameVerified",
                        "sendFromDomain",
                        "sendFromDomainId",
                        "sendFromVerified",
                        "sendFromMxRecord",
                        "sendFromMxPriority",
                        "sendFromSpfHostname",
                        "sendFromSpfValue",
                        "sendFromDkimSelector",
                        "sendFromDkimHostname",
                        "sendFromDkimValue",
                        "sendFromCnameValue",
                        "sendFromCnamePriority",
                        "sendFromMxVerified",
                        "sendFromSpfVerified",
                        "sendFromDkimVerified",
                        "sendFromCnameVerified",
                        "status",
                        "verifiedAt",
                        "lastCheckedAt",
                        "createdAt",
                        "updatedAt"
                      ]
                    },
                    "sendGridIntegrationId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "inboundWebhookUrl": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "emailDomain",
                    "sendGridIntegrationId",
                    "inboundWebhookUrl"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email-domains/{domainId}": {
      "get": {
        "tags": [
          "Email Domains"
        ],
        "summary": "Get an email domain",
        "description": "Retrieve a single email domain by ID",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "domainId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Email domain",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailDomain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "subdomain": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "fullDomain": {
                          "type": "string"
                        },
                        "emailProvider": {
                          "type": "string",
                          "enum": [
                            "RESEND",
                            "GMAIL",
                            "SENDGRID"
                          ]
                        },
                        "providerDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "gmailConnectionId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridIntegrationId": {
                          "type": "string",
                          "nullable": true,
                          "format": "uuid"
                        },
                        "inboundWebhookUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridSendFromEmail": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "spfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "spfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "mxVerified": {
                          "type": "boolean"
                        },
                        "spfVerified": {
                          "type": "boolean"
                        },
                        "dkimVerified": {
                          "type": "boolean"
                        },
                        "cnameVerified": {
                          "type": "boolean"
                        },
                        "sendFromDomain": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromVerified": {
                          "type": "boolean"
                        },
                        "sendFromMxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromMxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromSpfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromSpfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromMxVerified": {
                          "type": "boolean"
                        },
                        "sendFromSpfVerified": {
                          "type": "boolean"
                        },
                        "sendFromDkimVerified": {
                          "type": "boolean"
                        },
                        "sendFromCnameVerified": {
                          "type": "boolean"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "PENDING",
                            "VERIFYING",
                            "VERIFIED",
                            "FAILED",
                            "SUSPENDED"
                          ]
                        },
                        "verifiedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "lastCheckedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "subdomain",
                        "domain",
                        "fullDomain",
                        "emailProvider",
                        "providerDomainId",
                        "gmailConnectionId",
                        "sendGridIntegrationId",
                        "inboundWebhookUrl",
                        "mxRecord",
                        "mxPriority",
                        "spfHostname",
                        "spfValue",
                        "dkimSelector",
                        "dkimHostname",
                        "dkimValue",
                        "cnameValue",
                        "cnamePriority",
                        "mxVerified",
                        "spfVerified",
                        "dkimVerified",
                        "cnameVerified",
                        "sendFromDomain",
                        "sendFromDomainId",
                        "sendFromVerified",
                        "sendFromMxRecord",
                        "sendFromMxPriority",
                        "sendFromSpfHostname",
                        "sendFromSpfValue",
                        "sendFromDkimSelector",
                        "sendFromDkimHostname",
                        "sendFromDkimValue",
                        "sendFromCnameValue",
                        "sendFromCnamePriority",
                        "sendFromMxVerified",
                        "sendFromSpfVerified",
                        "sendFromDkimVerified",
                        "sendFromCnameVerified",
                        "status",
                        "verifiedAt",
                        "lastCheckedAt",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "emailDomain"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Email Domains"
        ],
        "summary": "Delete an email domain",
        "description": "Delete an email domain. Fails if any agent version is currently using this domain.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "domainId",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted successfully"
          },
          "400": {
            "description": "Domain is in use by one or more agent versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email-domains/{domainId}/verify": {
      "post": {
        "tags": [
          "Email Domains"
        ],
        "summary": "Verify an email domain",
        "description": "Trigger Resend domain verification and update per-record verification state. Returns the updated domain with mxVerified, spfVerified, dkimVerified, cnameVerified flags.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "domainId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailDomain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "subdomain": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "fullDomain": {
                          "type": "string"
                        },
                        "emailProvider": {
                          "type": "string",
                          "enum": [
                            "RESEND",
                            "GMAIL",
                            "SENDGRID"
                          ]
                        },
                        "providerDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "gmailConnectionId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridIntegrationId": {
                          "type": "string",
                          "nullable": true,
                          "format": "uuid"
                        },
                        "inboundWebhookUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendGridSendFromEmail": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "mxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "spfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "spfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "dkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "cnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "mxVerified": {
                          "type": "boolean"
                        },
                        "spfVerified": {
                          "type": "boolean"
                        },
                        "dkimVerified": {
                          "type": "boolean"
                        },
                        "cnameVerified": {
                          "type": "boolean"
                        },
                        "sendFromDomain": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDomainId": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromVerified": {
                          "type": "boolean"
                        },
                        "sendFromMxRecord": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromMxPriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromSpfHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromSpfValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimSelector": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimHostname": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromDkimValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnameValue": {
                          "type": "string",
                          "nullable": true
                        },
                        "sendFromCnamePriority": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sendFromMxVerified": {
                          "type": "boolean"
                        },
                        "sendFromSpfVerified": {
                          "type": "boolean"
                        },
                        "sendFromDkimVerified": {
                          "type": "boolean"
                        },
                        "sendFromCnameVerified": {
                          "type": "boolean"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "PENDING",
                            "VERIFYING",
                            "VERIFIED",
                            "FAILED",
                            "SUSPENDED"
                          ]
                        },
                        "verifiedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "lastCheckedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "organizationId",
                        "subdomain",
                        "domain",
                        "fullDomain",
                        "emailProvider",
                        "providerDomainId",
                        "gmailConnectionId",
                        "sendGridIntegrationId",
                        "inboundWebhookUrl",
                        "mxRecord",
                        "mxPriority",
                        "spfHostname",
                        "spfValue",
                        "dkimSelector",
                        "dkimHostname",
                        "dkimValue",
                        "cnameValue",
                        "cnamePriority",
                        "mxVerified",
                        "spfVerified",
                        "dkimVerified",
                        "cnameVerified",
                        "sendFromDomain",
                        "sendFromDomainId",
                        "sendFromVerified",
                        "sendFromMxRecord",
                        "sendFromMxPriority",
                        "sendFromSpfHostname",
                        "sendFromSpfValue",
                        "sendFromDkimSelector",
                        "sendFromDkimHostname",
                        "sendFromDkimValue",
                        "sendFromCnameValue",
                        "sendFromCnamePriority",
                        "sendFromMxVerified",
                        "sendFromSpfVerified",
                        "sendFromDkimVerified",
                        "sendFromCnameVerified",
                        "status",
                        "verifiedAt",
                        "lastCheckedAt",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "emailDomain"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email/threads": {
      "post": {
        "tags": [
          "Email"
        ],
        "summary": "Create an email thread",
        "description": "Initialize an outbound email thread for the given agent version. The version must be deployed and have a verified email domain configured.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentVersionId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "toEmail": {
                    "type": "string",
                    "format": "email"
                  },
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 998
                  },
                  "firstMessage": {
                    "type": "string",
                    "minLength": 1
                  },
                  "leadId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "variables": {
                    "type": "object",
                    "additionalProperties": {
                      "nullable": true
                    }
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "nullable": true
                    }
                  }
                },
                "required": [
                  "agentVersionId",
                  "toEmail"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Email thread created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "agentId": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "emailDomainId": {
                          "type": "string"
                        },
                        "fromEmail": {
                          "type": "string",
                          "nullable": true
                        },
                        "fromName": {
                          "type": "string",
                          "nullable": true
                        },
                        "toEmail": {
                          "type": "string"
                        },
                        "subject": {
                          "type": "string",
                          "nullable": true
                        },
                        "leadId": {
                          "type": "string",
                          "nullable": true
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "agentId",
                        "agentVersionId",
                        "organizationId",
                        "emailDomainId",
                        "fromEmail",
                        "fromName",
                        "toEmail",
                        "subject",
                        "leadId",
                        "isActive",
                        "createdAt"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Email"
        ],
        "summary": "List email threads",
        "description": "List email threads with cursor-based pagination and optional filters",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "agentId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "email"
            },
            "required": false,
            "name": "toEmail",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "isActive",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "OPTED_OUT",
                "DNC",
                "FRAUD",
                "CONTACT_AGAIN",
                "WRONG_NUMBER",
                "NOT_INTERESTED",
                "APPOINTMENT_BOOKED",
                "ENDED",
                "WORKFLOW_ONE_OFF_TEXT",
                "FILTERED_SPAM",
                "FILTERED_OOO",
                "FILTERED_AUTO_REPLY"
              ]
            },
            "required": false,
            "name": "chatEndedReason",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "hasDraft",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "CLOSED",
                "TERMINATED"
              ]
            },
            "required": false,
            "name": "closedReason",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of email threads",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "organizationId": {
                            "type": "string"
                          },
                          "agentId": {
                            "type": "string"
                          },
                          "agentVersionId": {
                            "type": "string"
                          },
                          "emailDomainId": {
                            "type": "string",
                            "nullable": true
                          },
                          "leadId": {
                            "type": "string",
                            "nullable": true
                          },
                          "fromEmail": {
                            "type": "string",
                            "nullable": true
                          },
                          "fromName": {
                            "type": "string",
                            "nullable": true
                          },
                          "toEmail": {
                            "type": "string"
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "chatEndedReason": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "OPTED_OUT",
                              "DNC",
                              "FRAUD",
                              "CONTACT_AGAIN",
                              "WRONG_NUMBER",
                              "NOT_INTERESTED",
                              "APPOINTMENT_BOOKED",
                              "ENDED",
                              "WORKFLOW_ONE_OFF_TEXT",
                              "FILTERED_SPAM",
                              "FILTERED_OOO",
                              "FILTERED_AUTO_REPLY"
                            ]
                          },
                          "closedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "closedReason": {
                            "type": "string",
                            "nullable": true
                          },
                          "lastActivityAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "reopenedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "emailTags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "default": []
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "organizationId",
                          "agentId",
                          "agentVersionId",
                          "emailDomainId",
                          "leadId",
                          "fromEmail",
                          "fromName",
                          "toEmail",
                          "subject",
                          "isActive",
                          "chatEndedReason",
                          "closedAt",
                          "closedReason",
                          "lastActivityAt",
                          "reopenedAt",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "threads",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email/threads/{threadId}/messages": {
      "get": {
        "tags": [
          "Email"
        ],
        "summary": "Get messages for an email thread",
        "description": "Get messages for a specific email thread with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "INBOUND",
                "OUTBOUND"
              ]
            },
            "required": false,
            "name": "direction",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "QUEUED",
                "SENDING",
                "SENT",
                "DELIVERED",
                "OPENED",
                "BOUNCED",
                "FAILED",
                "SPAM",
                "RECEIVED",
                "DRAFT"
              ]
            },
            "required": false,
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Email thread messages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "agentId": {
                          "type": "string"
                        },
                        "agentVersionId": {
                          "type": "string"
                        },
                        "organizationId": {
                          "type": "string"
                        },
                        "toEmail": {
                          "type": "string"
                        },
                        "fromEmail": {
                          "type": "string",
                          "nullable": true
                        },
                        "fromName": {
                          "type": "string",
                          "nullable": true
                        },
                        "subject": {
                          "type": "string",
                          "nullable": true
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "reopenedAt": {
                          "type": "string",
                          "nullable": true
                        },
                        "messages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "threadId": {
                                "type": "string"
                              },
                              "direction": {
                                "type": "string",
                                "enum": [
                                  "INBOUND",
                                  "OUTBOUND"
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "QUEUED",
                                  "SENDING",
                                  "SENT",
                                  "DELIVERED",
                                  "OPENED",
                                  "BOUNCED",
                                  "FAILED",
                                  "SPAM",
                                  "RECEIVED",
                                  "DRAFT"
                                ]
                              },
                              "messageId": {
                                "type": "string",
                                "nullable": true
                              },
                              "fromAddress": {
                                "type": "string",
                                "nullable": true
                              },
                              "toAddress": {
                                "type": "string",
                                "nullable": true
                              },
                              "ccAddresses": {
                                "type": "string",
                                "nullable": true
                              },
                              "subject": {
                                "type": "string",
                                "nullable": true
                              },
                              "inReplyTo": {
                                "type": "string",
                                "nullable": true
                              },
                              "bodyText": {
                                "type": "string",
                                "nullable": true
                              },
                              "bodyHtml": {
                                "type": "string",
                                "nullable": true
                              },
                              "providerMessageId": {
                                "type": "string",
                                "nullable": true
                              },
                              "errorCode": {
                                "type": "string",
                                "nullable": true
                              },
                              "errorMessage": {
                                "type": "string",
                                "nullable": true
                              },
                              "bounceType": {
                                "type": "string",
                                "nullable": true
                              },
                              "sentAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "deliveredAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "openedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "bouncedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "classification": {
                                "type": "string",
                                "nullable": true
                              },
                              "classificationScore": {
                                "type": "number",
                                "nullable": true
                              },
                              "classifiedAt": {
                                "type": "string",
                                "nullable": true
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "updatedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "threadId",
                              "direction",
                              "status",
                              "messageId",
                              "fromAddress",
                              "toAddress",
                              "ccAddresses",
                              "subject",
                              "inReplyTo",
                              "bodyText",
                              "bodyHtml",
                              "providerMessageId",
                              "errorCode",
                              "errorMessage",
                              "bounceType",
                              "sentAt",
                              "deliveredAt",
                              "openedAt",
                              "bouncedAt",
                              "classification",
                              "classificationScore",
                              "classifiedAt",
                              "createdAt",
                              "updatedAt"
                            ]
                          }
                        },
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "limit": {
                              "type": "number",
                              "minimum": 1,
                              "maximum": 100,
                              "default": 10
                            },
                            "nextCursor": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "required": [
                        "id",
                        "agentId",
                        "agentVersionId",
                        "organizationId",
                        "toEmail",
                        "fromEmail",
                        "fromName",
                        "subject",
                        "isActive",
                        "reopenedAt",
                        "messages",
                        "pagination"
                      ]
                    }
                  },
                  "required": [
                    "thread"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/internal/email/classify": {
      "post": {
        "tags": [
          "Email Internal"
        ],
        "summary": "Classify an inbound email via tags",
        "description": "Internal endpoint called by ai-texting to evaluate user-defined email tags and determine routing action.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "threadId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "messageId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "subject": {
                    "type": "string"
                  },
                  "bodyText": {
                    "type": "string"
                  },
                  "fromAddress": {
                    "type": "string"
                  }
                },
                "required": [
                  "threadId",
                  "messageId",
                  "bodyText",
                  "fromAddress"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tag evaluation result with routing action",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "matchedTags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "action": {
                      "type": "string",
                      "enum": [
                        "FILTER",
                        "PROCEED",
                        "BLOCKED"
                      ]
                    },
                    "responseMode": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "matchedTags",
                    "action"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 401
                    },
                    "message": {
                      "type": "string",
                      "default": "Unauthorized"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "UNAUTHORIZED"
                      ],
                      "default": "UNAUTHORIZED"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread or message not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email/drafts": {
      "get": {
        "tags": [
          "Email"
        ],
        "summary": "List email drafts",
        "description": "List email draft messages pending human review with cursor-based pagination",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "agentId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of email drafts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "drafts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "threadId": {
                            "type": "string"
                          },
                          "direction": {
                            "type": "string",
                            "enum": [
                              "INBOUND",
                              "OUTBOUND"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "QUEUED",
                              "SENDING",
                              "SENT",
                              "DELIVERED",
                              "OPENED",
                              "BOUNCED",
                              "FAILED",
                              "SPAM",
                              "RECEIVED",
                              "DRAFT"
                            ]
                          },
                          "messageId": {
                            "type": "string",
                            "nullable": true
                          },
                          "fromAddress": {
                            "type": "string",
                            "nullable": true
                          },
                          "toAddress": {
                            "type": "string",
                            "nullable": true
                          },
                          "ccAddresses": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          },
                          "inReplyTo": {
                            "type": "string",
                            "nullable": true
                          },
                          "bodyText": {
                            "type": "string",
                            "nullable": true
                          },
                          "bodyHtml": {
                            "type": "string",
                            "nullable": true
                          },
                          "classification": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "SPAM",
                              "OUT_OF_OFFICE",
                              "AUTO_REPLY",
                              "LEGITIMATE"
                            ]
                          },
                          "classificationScore": {
                            "type": "number",
                            "nullable": true
                          },
                          "classifiedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "thread": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "agentId": {
                                "type": "string"
                              },
                              "agentVersionId": {
                                "type": "string"
                              },
                              "toEmail": {
                                "type": "string"
                              },
                              "fromEmail": {
                                "type": "string",
                                "nullable": true
                              },
                              "fromName": {
                                "type": "string",
                                "nullable": true
                              },
                              "subject": {
                                "type": "string",
                                "nullable": true
                              }
                            },
                            "required": [
                              "id",
                              "agentId",
                              "agentVersionId",
                              "toEmail",
                              "fromEmail",
                              "fromName",
                              "subject"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "threadId",
                          "direction",
                          "status",
                          "messageId",
                          "fromAddress",
                          "toAddress",
                          "ccAddresses",
                          "subject",
                          "inReplyTo",
                          "bodyText",
                          "bodyHtml",
                          "classification",
                          "classificationScore",
                          "classifiedAt",
                          "createdAt",
                          "updatedAt",
                          "thread"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 100,
                          "default": 10
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "drafts",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email/drafts/{messageId}/approve": {
      "post": {
        "tags": [
          "Email"
        ],
        "summary": "Approve an email draft",
        "description": "Approve a draft email message and send it",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "messageId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Draft approved and sent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "threadId": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "threadId",
                        "status"
                      ]
                    },
                    "sent": {
                      "type": "boolean"
                    },
                    "providerMessageId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message",
                    "sent"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Draft not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email/drafts/{messageId}": {
      "patch": {
        "tags": [
          "Email"
        ],
        "summary": "Edit an email draft",
        "description": "Edit the body of a draft email message",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "messageId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bodyText": {
                    "type": "string"
                  },
                  "bodyHtml": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Draft updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "threadId": {
                      "type": "string"
                    },
                    "direction": {
                      "type": "string",
                      "enum": [
                        "INBOUND",
                        "OUTBOUND"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "QUEUED",
                        "SENDING",
                        "SENT",
                        "DELIVERED",
                        "OPENED",
                        "BOUNCED",
                        "FAILED",
                        "SPAM",
                        "RECEIVED",
                        "DRAFT"
                      ]
                    },
                    "bodyText": {
                      "type": "string",
                      "nullable": true
                    },
                    "bodyHtml": {
                      "type": "string",
                      "nullable": true
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "threadId",
                    "direction",
                    "status",
                    "bodyText",
                    "bodyHtml",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Draft not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Email"
        ],
        "summary": "Discard an email draft",
        "description": "Discard (delete) a draft email message",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "messageId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Draft discarded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "messageId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "messageId"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Draft not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/email/threads/{threadId}/terminate": {
      "patch": {
        "tags": [
          "Email Threads"
        ],
        "summary": "Terminate an email thread",
        "description": "Permanently close an email thread. Terminated threads cannot be reopened by inbound replies — new replies create a fresh thread instead.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "threadId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Thread terminated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "closedReason": {
                      "type": "string"
                    },
                    "closedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "isActive",
                    "closedReason",
                    "closedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Thread not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/available-voices": {
      "get": {
        "tags": [
          "Configuration"
        ],
        "summary": "Get available voices",
        "description": "Get all available voices",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "DEEPGRAM",
                "CARTESIA",
                "AMAZON",
                "ELEVEN_LABS",
                "PLAY_HT",
                "RIME",
                "OPENAI",
                "INWORLD",
                "SESAME"
              ]
            },
            "required": false,
            "name": "provider",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "model",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Available voices retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "voices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string",
                            "nullable": true
                          },
                          "voiceId": {
                            "type": "string"
                          },
                          "voiceSampleUrl": {
                            "type": "string"
                          },
                          "photoUrl": {
                            "type": "string",
                            "nullable": true
                          },
                          "provider": {
                            "type": "string",
                            "enum": [
                              "DEEPGRAM",
                              "CARTESIA",
                              "AMAZON",
                              "ELEVEN_LABS",
                              "PLAY_HT",
                              "RIME",
                              "OPENAI",
                              "INWORLD",
                              "SESAME"
                            ]
                          },
                          "model": {
                            "type": "string"
                          },
                          "gender": {
                            "type": "string",
                            "enum": [
                              "MALE",
                              "FEMALE"
                            ]
                          },
                          "languages": {
                            "type": "string"
                          },
                          "accent": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "languageId": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "voiceId",
                          "voiceSampleUrl",
                          "photoUrl",
                          "provider",
                          "model",
                          "gender",
                          "languages",
                          "accent",
                          "createdAt",
                          "updatedAt",
                          "languageId"
                        ]
                      }
                    }
                  },
                  "required": [
                    "voices"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/elevenlabs-voices": {
      "post": {
        "tags": [
          "Configuration"
        ],
        "summary": "Add an ElevenLabs voice to collection and database",
        "description": "Adds a voice to the Feather ElevenLabs account collection, then upserts a single AvailableVoice row for the given model and languageId.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "voiceId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "languageId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "model": {
                    "type": "string",
                    "enum": [
                      "eleven_flash_v2",
                      "eleven_flash_v2_5",
                      "eleven_multilingual_v2"
                    ]
                  },
                  "publicUserId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "voiceId",
                  "languageId",
                  "model"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Voice added successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "voice": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "voiceId": {
                          "type": "string"
                        },
                        "voiceSampleUrl": {
                          "type": "string"
                        },
                        "photoUrl": {
                          "type": "string",
                          "nullable": true
                        },
                        "provider": {
                          "type": "string",
                          "enum": [
                            "DEEPGRAM",
                            "CARTESIA",
                            "AMAZON",
                            "ELEVEN_LABS",
                            "PLAY_HT",
                            "RIME",
                            "OPENAI",
                            "INWORLD",
                            "SESAME"
                          ]
                        },
                        "model": {
                          "type": "string"
                        },
                        "gender": {
                          "type": "string",
                          "enum": [
                            "MALE",
                            "FEMALE"
                          ]
                        },
                        "languages": {
                          "type": "string"
                        },
                        "accent": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "languageId": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "description",
                        "voiceId",
                        "voiceSampleUrl",
                        "photoUrl",
                        "provider",
                        "model",
                        "gender",
                        "languages",
                        "accent",
                        "createdAt",
                        "updatedAt",
                        "languageId"
                      ]
                    },
                    "elevenLabsVoiceId": {
                      "type": "string"
                    },
                    "addedToCollection": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "voice",
                    "elevenLabsVoiceId",
                    "addedToCollection"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Voice not found in ElevenLabs voice library",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/languages": {
      "get": {
        "tags": [
          "Configuration"
        ],
        "summary": "Get supported languages",
        "description": "Get all active supported languages",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved supported languages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "languages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "languageId": {
                            "type": "string"
                          },
                          "languageCode": {
                            "type": "string"
                          },
                          "languageDisplayName": {
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "languageId",
                          "languageCode",
                          "languageDisplayName",
                          "isActive"
                        ]
                      }
                    }
                  },
                  "required": [
                    "languages"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars": {
      "post": {
        "tags": [
          "Calendars"
        ],
        "summary": "Create a calendar",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "userId": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Calendar created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Calendar"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Calendars"
        ],
        "summary": "List calendars",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of calendars",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "calendars": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Calendar"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "limit"
                      ]
                    }
                  },
                  "required": [
                    "calendars",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}": {
      "get": {
        "tags": [
          "Calendars"
        ],
        "summary": "Get a calendar",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Calendar details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Calendar"
                }
              }
            }
          },
          "404": {
            "description": "Calendar not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Calendars"
        ],
        "summary": "Update a calendar",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "description": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 1000
                  },
                  "userId": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calendar updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Calendar"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Calendar not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Calendars"
        ],
        "summary": "Delete a calendar",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Calendar deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Calendar not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/schedules": {
      "post": {
        "tags": [
          "Calendar Schedules"
        ],
        "summary": "Create a schedule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255,
                    "default": "Default"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "isDefault": {
                    "type": "boolean",
                    "default": false
                  },
                  "availability": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "days": {
                          "type": "array",
                          "items": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 6
                          },
                          "default": []
                        },
                        "startTime": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1440
                        },
                        "endTime": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1440
                        },
                        "date": {
                          "type": "string",
                          "format": "date"
                        }
                      },
                      "required": [
                        "startTime",
                        "endTime"
                      ]
                    },
                    "default": []
                  }
                },
                "required": [
                  "timezone"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Schedule created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Calendar not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Calendar Schedules"
        ],
        "summary": "List schedules",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "List of schedules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schedules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CalendarSchedule"
                      }
                    }
                  },
                  "required": [
                    "schedules"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Calendar not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/schedules/{scheduleId}": {
      "get": {
        "tags": [
          "Calendar Schedules"
        ],
        "summary": "Get a schedule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "scheduleId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Schedule details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarSchedule"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Calendar Schedules"
        ],
        "summary": "Update a schedule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "scheduleId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "isDefault": {
                    "type": "boolean"
                  },
                  "availability": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "days": {
                          "type": "array",
                          "items": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 6
                          },
                          "default": []
                        },
                        "startTime": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1440
                        },
                        "endTime": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1440
                        },
                        "date": {
                          "type": "string",
                          "format": "date"
                        }
                      },
                      "required": [
                        "startTime",
                        "endTime"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Schedule updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Calendar Schedules"
        ],
        "summary": "Delete a schedule",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "scheduleId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Schedule deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/event-types": {
      "post": {
        "tags": [
          "Calendar Event Types"
        ],
        "summary": "Create an event type",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "slug": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "duration": {
                    "type": "number",
                    "minimum": 1
                  },
                  "slotInterval": {
                    "type": "number",
                    "minimum": 1
                  },
                  "minimumBookingNotice": {
                    "type": "number",
                    "minimum": 0,
                    "default": 120
                  },
                  "beforeEventBuffer": {
                    "type": "number",
                    "minimum": 0,
                    "default": 0
                  },
                  "afterEventBuffer": {
                    "type": "number",
                    "minimum": 0,
                    "default": 0
                  },
                  "periodType": {
                    "type": "string",
                    "enum": [
                      "UNLIMITED",
                      "ROLLING",
                      "RANGE"
                    ],
                    "default": "UNLIMITED"
                  },
                  "periodDays": {
                    "type": "number",
                    "minimum": 1
                  },
                  "periodStartDate": {
                    "type": "string",
                    "format": "date"
                  },
                  "periodEndDate": {
                    "type": "string",
                    "format": "date"
                  },
                  "scheduleId": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "addGoogleMeet": {
                    "type": "boolean",
                    "default": false
                  },
                  "metadata": {
                    "nullable": true
                  }
                },
                "required": [
                  "name",
                  "slug",
                  "duration"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Event type created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarEventType"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Calendar not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Calendar Event Types"
        ],
        "summary": "List event types",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of event types",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "eventTypes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CalendarEventType"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "limit"
                      ]
                    }
                  },
                  "required": [
                    "eventTypes",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Calendar not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/event-types/{eventTypeId}": {
      "get": {
        "tags": [
          "Calendar Event Types"
        ],
        "summary": "Get an event type",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "eventTypeId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Event type details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarEventType"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Calendar Event Types"
        ],
        "summary": "Update an event type",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "eventTypeId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "slug": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "description": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 1000
                  },
                  "duration": {
                    "type": "number",
                    "minimum": 1
                  },
                  "slotInterval": {
                    "type": "number",
                    "nullable": true,
                    "minimum": 1
                  },
                  "minimumBookingNotice": {
                    "type": "number",
                    "minimum": 0
                  },
                  "beforeEventBuffer": {
                    "type": "number",
                    "minimum": 0
                  },
                  "afterEventBuffer": {
                    "type": "number",
                    "minimum": 0
                  },
                  "periodType": {
                    "type": "string",
                    "enum": [
                      "UNLIMITED",
                      "ROLLING",
                      "RANGE"
                    ]
                  },
                  "periodDays": {
                    "type": "number",
                    "nullable": true,
                    "minimum": 1
                  },
                  "periodStartDate": {
                    "type": "string",
                    "nullable": true,
                    "format": "date"
                  },
                  "periodEndDate": {
                    "type": "string",
                    "nullable": true,
                    "format": "date"
                  },
                  "scheduleId": {
                    "type": "string",
                    "nullable": true
                  },
                  "location": {
                    "type": "string",
                    "nullable": true
                  },
                  "addGoogleMeet": {
                    "type": "boolean"
                  },
                  "metadata": {
                    "nullable": true
                  },
                  "active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event type updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarEventType"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Calendar Event Types"
        ],
        "summary": "Delete an event type",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "eventTypeId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Event type deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/event-types/{eventTypeId}/slots": {
      "get": {
        "tags": [
          "Calendar Event Types"
        ],
        "summary": "Get available slots",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "eventTypeId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "date"
            },
            "required": true,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date"
            },
            "required": true,
            "name": "endDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "America/Los_Angeles"
            },
            "required": false,
            "name": "timezone",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Available slots",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AvailableSlots"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendar-bookings": {
      "post": {
        "tags": [
          "Calendar Bookings"
        ],
        "summary": "Create a booking",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "calendarId": {
                    "type": "string"
                  },
                  "eventTypeId": {
                    "type": "string"
                  },
                  "startTime": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "timezone": {
                    "type": "string",
                    "default": "America/Los_Angeles"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "attendeeName": {
                    "type": "string"
                  },
                  "attendeeEmail": {
                    "type": "string",
                    "format": "email"
                  },
                  "attendeePhone": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "metadata": {
                    "nullable": true
                  },
                  "agentCallId": {
                    "type": "string"
                  },
                  "leadId": {
                    "type": "string"
                  }
                },
                "required": [
                  "calendarId",
                  "eventTypeId",
                  "startTime",
                  "title"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Booking created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarBooking"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Calendar Bookings"
        ],
        "summary": "List bookings",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "default": "10"
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "calendarId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "CONFIRMED",
                "CANCELLED",
                "RESCHEDULED",
                "NO_SHOW"
              ]
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date"
            },
            "required": false,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date"
            },
            "required": false,
            "name": "endDate",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "List of bookings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bookings": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CalendarBooking"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "nextCursor": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "limit"
                      ]
                    }
                  },
                  "required": [
                    "bookings",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendar-bookings/{bookingId}": {
      "get": {
        "tags": [
          "Calendar Bookings"
        ],
        "summary": "Get a booking",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "bookingId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Booking details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarBooking"
                }
              }
            }
          },
          "404": {
            "description": "Booking not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendar-bookings/{bookingId}/cancel": {
      "post": {
        "tags": [
          "Calendar Bookings"
        ],
        "summary": "Cancel a booking",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "bookingId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cancellationReason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Booking cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarBooking"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Booking not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendar-bookings/{bookingId}/reschedule": {
      "post": {
        "tags": [
          "Calendar Bookings"
        ],
        "summary": "Reschedule a booking",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "bookingId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "startTime": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "cancellationReason": {
                    "type": "string",
                    "maxLength": 1000
                  }
                },
                "required": [
                  "startTime"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Booking rescheduled — returns the new booking",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarBooking"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Booking not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict — booking has already been rescheduled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/connections/oauth-url": {
      "get": {
        "tags": [
          "Calendar Connections"
        ],
        "summary": "Get OAuth URL for external calendar",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "GOOGLE",
                "OUTLOOK"
              ]
            },
            "required": true,
            "name": "provider",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OAuth URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendar-connections/oauth/callback": {
      "get": {
        "tags": [
          "Calendar Connections"
        ],
        "summary": "OAuth callback for external calendar",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "code",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "state",
            "in": "query"
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to frontend"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/connections": {
      "get": {
        "tags": [
          "Calendar Connections"
        ],
        "summary": "List calendar connections",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "List of connections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connections": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CalendarConnection"
                      }
                    }
                  },
                  "required": [
                    "connections"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/connections/{connectionId}": {
      "delete": {
        "tags": [
          "Calendar Connections"
        ],
        "summary": "Delete a calendar connection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "connectionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Connection deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Calendar Connections"
        ],
        "summary": "Update a calendar connection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "connectionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "externalCalendarId": {
                    "type": "string"
                  }
                },
                "required": [
                  "externalCalendarId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Connection updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarConnection"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calendars/{calendarId}/connections/{connectionId}/external-calendars": {
      "get": {
        "tags": [
          "Calendar Connections"
        ],
        "summary": "List external calendars from a connected account",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "calendarId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "connectionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "List of external calendars",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "calendars": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "primary": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "primary"
                        ]
                      }
                    }
                  },
                  "required": [
                    "calendars"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gmail/connections/oauth-url": {
      "get": {
        "tags": [
          "Gmail Connections"
        ],
        "summary": "Get OAuth URL for Gmail connection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OAuth URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gmail/oauth/callback": {
      "get": {
        "tags": [
          "Gmail Connections"
        ],
        "summary": "OAuth callback for Gmail connection",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "code",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "state",
            "in": "query"
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to frontend"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gmail/connections": {
      "get": {
        "tags": [
          "Gmail Connections"
        ],
        "summary": "List Gmail connections for organization",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of Gmail connections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "accountEmail": {
                            "type": "string"
                          },
                          "invalid": {
                            "type": "boolean"
                          },
                          "historyId": {
                            "type": "string",
                            "nullable": true
                          },
                          "watchExpiration": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "accountEmail",
                          "invalid",
                          "historyId",
                          "watchExpiration",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    }
                  },
                  "required": [
                    "connections"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gmail/connections/{connectionId}": {
      "delete": {
        "tags": [
          "Gmail Connections"
        ],
        "summary": "Delete a Gmail connection",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "connectionId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Connection deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 400
                    },
                    "message": {
                      "type": "string",
                      "default": "Bad request"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BAD_REQUEST"
                      ],
                      "default": "BAD_REQUEST"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 404
                    },
                    "message": {
                      "type": "string",
                      "default": "Not found"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "NOT_FOUND"
                      ],
                      "default": "NOT_FOUND"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "default": 500
                    },
                    "message": {
                      "type": "string",
                      "default": "Internal server error"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "INTERNAL_SERVER_ERROR"
                      ],
                      "default": "INTERNAL_SERVER_ERROR"
                    },
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ],
                      "default": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
